help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [External] : Make new buffer from menu


From: Jean Louis
Subject: Re: [External] : Make new buffer from menu
Date: Sun, 4 Dec 2022 15:39:06 +0300
User-agent: Mutt/2.2.9+50 (c79959e) (2022-11-21)

* Heime <heimeborgia@protonmail.com> [2022-12-04 15:34]:
> So tell me about this.  Can I make a new untitled buffer that I can later 
> save if I want to, from the File Menu, in the Menu Bar ?

I have sent my functions to you, that is exactly what I do every
day. I press F5 for that.

Install RCD Utilities and use this:

;;; RCD TEMPORARY BUFFERS

(defvar rcd-temp-buffer-name "RCD TEMPORARY BUFFER")
(defvar rcd-temp-buffer-modes '(("adoc-mode" . "adoc")
                                ("emacs-lisp-mode" . "el")
                                ("lisp-mode" . ".lisp")
                                ("markdown-mode" . ".md")
                                ("org-mode" . "org")
                                ("sql-mode" . "sql")
                                ("fundamental-mode" . "txt")
                                ("html-mode" . "html")))

(defun rcd-temp-buffer (&optional prefix name mode)
  "Generate new temporary buffer."
  (interactive "p")
  (let* ((file-name (concat rcd-temp-file-directory 
                            (format-time-string "%Y-%m-%d-%H:%M:%S-")
                            rcd-temp-buffer-name
                            ".txt"))
         (buffer (or name (concat "*" rcd-temp-buffer-name "*"))))
    (switch-to-buffer (generate-new-buffer buffer))
    (setq buffer-file-name file-name)
    (if current-prefix-arg
        (let ((mode (rcd-choose (map-keys rcd-temp-buffer-modes) "Major mode: 
")))
          (funcall (intern mode)))
      (funcall (intern (or mode "fundamental-mode"))))
    buffer-file-name))

(global-set-key (kbd "<f5>") #'rcd-temp-buffer)


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]