[Top][All Lists]

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

Re: Adding major-mode selection to new buffer

From: Jean Louis
Subject: Re: Adding major-mode selection to new buffer
Date: Wed, 29 Jun 2022 13:57:43 +0300
User-agent: Mutt/+ () (2022-05-21)

* Christopher Dimech <> [2022-06-29 01:06]:
> How can the code be modified to have filename saved with the following format?
> %Y-%m-%d-T%H:%M:%S--<rcd-temp-buffer-name>-<name>.txt

My variable is this one: rcd-temp-buffer-name ⇒ "RCD TEMPORARY BUFFER"

And I rarely save it as such, but files are connected to temporary
buffers. It is very handy, as it is temporary note, and if I wish to
exit Emacs I will be notified there is maybe still something to be

You are right, your suggestion is much better for sorting and visual review.

(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-")
         (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 (completing-read
                      "Mode: "
                      (map-keys rcd-temp-buffer-modes) nil t nil
          (funcall (intern mode)))
      (funcall (intern (or mode "fundamental-mode"))))


Take action in Free Software Foundation campaigns:

In support of Richard M. Stallman

reply via email to

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