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

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

Re: Adding major-mode selection to new buffer


From: carlmarcos
Subject: Re: Adding major-mode selection to new buffer
Date: Wed, 29 Jun 2022 18:05:11 +0200 (CEST)

Jun 29, 2022, 10:57 by bugs@gnu.support:

> * Christopher Dimech <dimech@gmx.com> [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
>>

That format would be very convenient.  How can I add name as well to the 
`file-name'?


> My variable is this one: rcd-temp-buffer-name ⇒ "RCD TEMPORARY BUFFER"
>
> You are right, your suggestion is much better for sorting and visual review.
>

Have tried it and works really well.  Is the numeric prefix argument really 
necessary?


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