From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: How users start programming in Emacs Lisp... Date: Tue, 1 Jun 2021 00:53:46 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22282"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0.7+183 (3d24855) (2021-05-28) Cc: help-gnu-emacs@gnu.org To: Christopher Dimech Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 31 23:58:03 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lnpv9-0005Vb-Kj for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 23:58:03 +0200 Original-Received: from localhost ([::1]:46494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnpv7-000195-SX for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 17:58:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnpuo-00018h-8J for help-gnu-emacs@gnu.org; Mon, 31 May 2021 17:57:42 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:59837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnpum-00025U-Cw for help-gnu-emacs@gnu.org; Mon, 31 May 2021 17:57:41 -0400 Original-Received: from localhost ([::ffff:197.157.0.35]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 00000000000ADF02.0000000060B55BD1.00007BBD; Mon, 31 May 2021 14:57:37 -0700 Mail-Followup-To: Christopher Dimech , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:130395 Archived-At: * Christopher Dimech [2021-05-31 23:31]: > I would like to be able to decide the name from the mini-buffer. > How can that be done? Here is the set of improved functions: - your main buffer name is in variable `rcd-temp-buffer-name'; your main buffer name should be something unique, descriptive so that it can be destroyed easily (when necessarily) or followed up; - run M-x rcd-temp-buffer-ask-name or bind it to key if you wish to get asked for sub-name - use C-u prefix to get asked for mode - if you have many temporary buffers you maybe wish to browse through such buffers, because they got their main name, the function M-x rcd-temp-buffer-next will go through such. Bind it to a simple key and you can press key and browse through temporary buffers quicker. ;;;; ↝ RCD TEMPORARY BUFFERS (defvar rcd-temp-buffer-mode-history nil) (defvar rcd-temp-file-directory "~/tmp/") (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 name mode) "Generate new temporary buffer." (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: " (map-keys 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-ask-name () "Generate new temporary buffer by asking for buffer name." (interactive) (rcd-temp-buffer (read-from-minibuffer "Buffer name: "))) (defun rcd-temp-file (&optional name mode) "Quickly open temporary file. Using C-u as prefix will ask you for the mode of the file and will influence the extension. NAME may be provided programmatically. MODE may be provided as string programmatically." (interactive) (let* ((mode (or mode (if current-prefix-arg (let* ((mode (completing-read "Mode: " (map-keys rcd-temp-buffer-modes) nil t nil 'rcd-temp-buffer-mode-history))) mode) "fundamental-mode"))) (file (concat rcd-temp-file-directory (or name (format-time-string "%A-%B-%e-%Y-%T.")) (cdr (assoc-string mode rcd-temp-buffer-modes))))) (find-file file) (save-buffer) (funcall (intern mode)))) (defvar rcd-temp-buffer-list nil) (defun rcd-temp-buffer-next () (interactive) (unless rcd-temp-buffer-list (setq rcd-temp-buffer-list (reverse (rcd-list-matching-buffers rcd-temp-buffer-name)))) (let ((rcd-buffer (pop rcd-temp-buffer-list)) (buffer (current-buffer))) (if rcd-buffer (if (buffer-live-p rcd-buffer) (switch-to-buffer rcd-buffer) (rcd-temp-buffer-next)) (message "No temporary buffers")))) (defun rcd-temp-buffer-destroy-em () (interactive) (kill-matching-buffers "RCD TEMPORARY BUFFER")) (defun rcd-list-matching-buffers (query) "Return list of matching buffers." (let ((list)) (mapc (lambda (buffer) (when (string-match query (buffer-name buffer)) (push buffer list))) (buffer-list)) list)) -- 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/