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

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

Re: How users start programming in Emacs Lisp...


From: Jean Louis
Subject: Re: How users start programming in Emacs Lisp...
Date: Sun, 30 May 2021 18:54:11 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

* Christopher Dimech <dimech@gmx.com> [2021-05-30 16:55]:
> > How exactly do you wish to play with the name? Which name? Is it
> > buffer name?
> 
> The first optional parameter "name", which looks like it is the
> buffer name.

Sorry, I was using that long time without observing.

> When I use "C-u F5" you can only set the mode, but if name is
> already set, the code suggests that it will use it.  But does not,
> because the let variable "buffer" is not set.

There is main name and sub-name.

Here now you can customize it:

;;;; ↝ RCD TEMPORARY BUFFERS

(defvar rcd-temp-buffer-mode-history nil)

;; You may customize the main name here:
(defvar rcd-temp-buffer-name "RCD TEMPORARY BUFFER")

;; You may customize the modes you wish to get asked with prefix C-u:
(defvar rcd-temp-buffer-modes '("adoc-mode" "emacs-lisp-mode" "lisp-mode" 
"markdown-mode"
                                "org-mode" "sql-mode" "fundamental-mode" 
"html-mode"))

(defun rcd-temp-buffer (&optional name mode)
  (interactive "p")
  (let* ((format (concat "*" rcd-temp-buffer-name "%s%s*"))
         (buffer (if name (format format ": " name) (format format "" ""))))
    (switch-to-buffer (generate-new-buffer buffer))
    (if current-prefix-arg
        (let* ((mode (completing-read
                      "Mode: "
                      rcd-temp-buffer-modes nil t nil 
'rcd-temp-buffer-mode-history)))
          (funcall (intern mode)))
      (funcall (intern (or mode "fundamental-mode"))))))

(defun rcd-temp-buffer-destroy-em ()
  (interactive)
  (kill-matching-buffers "RCD TEMPORARY BUFFER"))



-- 
Jean

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

Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

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