मैं Elisp Cookbook से कुछ कोड कोशिश कर रहा था की सामग्री से अज्ञात बफर बनाते हैं, और मैं शुरू में tought कि इस कोड:elisp फ़ाइल
(defun process-file (file)
"Read the contents of a file into a temp buffer and then do
something there."
(when (file-readable-p file)
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
(while (not (eobp))
;; do something here with buffer content
(forward-line)))))
आएगी एक नया (बेनाम/सहेजे गए) मेरी Emacs खिड़की पर बफ़र, होने उस फ़ाइल की सामग्री (और शायद इसे अग्रभूमि में खोलें)। हालांकि, ऐसा नहीं होता है। क्या आप मुझे इसकी दिशा में मार्गदर्शन कर सकते हैं?
संपादित करें: मैं एक छोटे से प्रयोग किया, और यह करने के लिए मिल गया:
(defun myTest (file)
(interactive "f")
; check if file is readable
(when (file-readable-p file)
; create a new "untitled" buffer
(let ((myBuf (get-buffer-create "untitled")))
; make it the current displayed buffer
(switch-to-buffer myBuf)
(insert "Hello"))))
इस तरह से यह करने के लिए है?
चूंकि यह "शीर्षक रहित" नामक बफर है, इसलिए मेरे पास केवल सत्र में इनमें से एक हो सकता है। क्या यादृच्छिक संख्याओं का उपयोग किए बिना, एक से अधिक होने के लिए मैं कुछ उपयोग कर सकता हूं?