From: Christopher Dimech <dimech@gmx.com>
To: Jean Louis <bugs@gnu.support>
Cc: help-gnu-emacs@gnu.org
Subject: How users start programming in Emacs Lisp...
Date: Mon, 31 May 2021 22:30:42 +0200 [thread overview]
Message-ID: <trinity-b909c76a-ecf6-40aa-84ab-1a0ed9a5b419-1622493042031@3c-app-mailcom-bs01> (raw)
In-Reply-To: <YLPr/CMDiJEMetjA@protected.localdomain>
I would like to be able to decide the name from the mini-buffer.
How can that be done?
----- Christopher Dimech
Society has became too quick to pass judgement and declare someone Persona Non-Grata,
the most extreme form of censure a country can bestow.
In a new era of destructive authoritarianism, I support Richard Stallman. Times of great
crisis are also times of great opportunity. I call upon you to make this struggle yours as well !
https://stallmansupport.org/ https://www.fsf.org/ https://www.gnu.org/
> Sent: Monday, May 31, 2021 at 7:48 AM
> From: "Jean Louis" <bugs@gnu.support>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: How users start programming in Emacs Lisp...
>
> * Christopher Dimech <dimech@gmx.com> [2021-05-30 20:22]:
> > I am having some problem figuring out what the following does, having format
> > repeated twice.
> >
> > (format format ": " name)
>
> It could be all simpler, it just adds the sub-name to the main name.
>
> M-x rcd-temp-buffer would create *RCD TEMPORARY BUFFER: 1*
>
> but (rcd-temp-buffer "Lisp") would create *RCD TEMPORARY BUFFER: Lisp*
>
> Myself I don't know why I made it so complex, but it just works and I
> use temporary or scratch buffers that way often.
>
> Simpler way to open temporary buffer is just:
>
> C-x b NAME-OF-YOUR-BUFFER
>
> but when function is tied to key binding it becomes simple, press F5
> or other key how you bind it, and you are already in clean empty new
> temporary buffer. Or invoke C-u prefix to be asked for the mode.
>
> As Eduardo mentioned maybe it is good to keep those notes, but because
> in my mind there is distinction on what is temporary and what is not,
> for me it is fine that way as I use the database and it is trivial to
> make a function to just open quickly buffer, write anything and have
> it saved for future.
>
> So I made this one...
>
> (defun hyperscope-quick-emacs-lisp ()
> (interactive)
> (let* ((id (hlink-add-generic (concat "Emacs Lisp: " (rcd-timestamp-literate)) "" 50 33))
> (template (rcd-db-get-entry "hlinktypes" "hlinktypes_template" 50 hs-db)))
> (when template
> (rcd-db-update-entry "hyobjects" "hyobjects_text" id template hs-db))
> (hyperscope-edit-with-mode id "hyobjects_text")))
>
> The "name" of the note should be something quick:
>
> (concat "Emacs Lisp: " (rcd-timestamp-literate)) ⇒ "Emacs Lisp: Sunday, May 30 2021, 22:21:26"
>
> Function `hlink-add-generic' just adds generic object with type 50
> (Emacs Lisp in description, text and report of the object) with the
> parent node 33 which is "Emacs Lisp" set or category.
>
> A type can have a template, why not, it is inserted as value of the
> column "hyobjects_text", and finally edited in the last line.
>
> Automatic saving is not a big deal, and automatic revision system
> also.
>
> What really matters is integration that brings speed to user without
> thinking, and so the workflow is:
>
> 1. Press F5, edit Emacs Lisp (forget about anything else)
>
> When editing database stuff, then things like byte compiling will not
> work as it is not tied to buffer, but is not impossible to byte
> compile and keep what is compiled in the database. I did not manage to
> make it.
>
> I am aware that little of this makes sense to people who edit mostly
> files. Some functionality can be for files:
>
> ;;;; ↝ 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)
> (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-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)
> (auto-save-mode 1)
> (funcall (intern mode))))
>
> (defun rcd-temp-buffer-destroy-em ()
> (interactive)
> (kill-matching-buffers "RCD TEMPORARY BUFFER"))
>
>
> Then calling `rcd-temp-file' with C-u prefix will create and save the
> file with chosen mode, it will automatically generate name based on
> the time stamp and it will be in the chosen mode, like:
>
> /home/data1/protected/tmp/Sunday-May-30-2021-22:44:11.sql
>
> Defining a key globally:
>
> (global-set-key [f5] 'rcd-temp-file)
>
> That could be one way to just press a key like F5 and to create a
> note with the timestamp on a file system without thinking of its
> file name, opening of file, saving, etc.
>
>
> --
> 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/
>
next prev parent reply other threads:[~2021-05-31 20:30 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-29 20:08 Fortran Topics (outline-minor-mode, require, fixed format) ludvig-faddeev
2021-05-29 20:14 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-29 20:48 ` Jean Louis
2021-05-29 21:26 ` Christopher Dimech
2021-05-29 21:56 ` Jean Louis
2021-05-29 22:07 ` Christopher Dimech
2021-05-29 22:37 ` How users start programming in Emacs Lisp Jean Louis
2021-05-30 1:06 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 2:11 ` Christopher Dimech
2021-05-30 4:32 ` Eduardo Ochs
2021-05-30 7:05 ` Jean Louis
2021-05-30 7:51 ` Eduardo Ochs
2021-05-30 8:31 ` Jean Louis
2021-05-30 19:27 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 22:27 ` Jean Louis
2021-05-30 22:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 22:52 ` Jean Louis
2021-05-30 11:43 ` Arthur Miller
2021-05-30 12:08 ` Christopher Dimech
2021-05-30 19:35 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 21:54 ` Jean Louis
2021-05-30 22:06 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 22:38 ` Jean Louis
2021-05-30 22:46 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 22:56 ` Jean Louis
2021-05-30 23:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 23:35 ` Jean Louis
2021-05-31 0:21 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-01 14:09 ` Arthur Miller
2021-06-01 21:09 ` Christopher Dimech
2021-06-01 21:54 ` Christopher Dimech
2021-05-30 14:44 ` Tomas Hlavaty
2021-05-30 15:23 ` Eduardo Ochs
2021-05-30 19:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 19:59 ` Eduardo Ochs
2021-05-31 17:59 ` Tomas Hlavaty
2021-05-30 19:37 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-01 10:29 ` Arthur Miller
2021-06-01 11:40 ` Eduardo Ochs
2021-06-01 16:30 ` Jean Louis
2021-06-02 0:54 ` Eduardo Ochs
2021-06-02 3:43 ` Jean Louis
2021-05-30 15:35 ` Eduardo Ochs
2021-05-30 19:42 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-01 10:23 ` Arthur Miller
2021-05-30 19:31 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-01 10:22 ` Arthur Miller
2021-06-01 10:30 ` Christopher Dimech
2021-05-30 19:23 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 21:33 ` Jean Louis
2021-05-30 21:43 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 22:05 ` Jean Louis
2021-05-30 22:16 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 22:41 ` Jean Louis
2021-05-30 22:49 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 23:01 ` Jean Louis
2021-05-30 23:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 23:36 ` Jean Louis
2021-05-31 0:25 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-31 0:34 ` Eduardo Ochs
2021-05-31 8:09 ` Jean Louis
2021-05-30 22:49 ` Tomas Hlavaty
2021-05-30 22:18 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 22:50 ` Jean Louis
2021-05-30 22:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-30 23:25 ` Jean Louis
2021-05-30 5:46 ` Jean Louis
2021-05-30 10:32 ` Christopher Dimech
2021-05-30 10:35 ` Jean Louis
2021-05-30 11:08 ` Christopher Dimech
2021-05-30 11:19 ` Jean Louis
2021-05-30 13:55 ` Christopher Dimech
2021-05-30 15:54 ` Jean Louis
2021-05-30 17:22 ` Christopher Dimech
2021-05-30 18:57 ` Jean Louis
2021-05-30 19:48 ` Jean Louis
2021-05-31 20:30 ` Christopher Dimech [this message]
2021-05-31 21:53 ` Jean Louis
2021-05-29 20:36 ` Fortran Topics (outline-minor-mode, require, fixed format) Jean Louis
2021-05-29 20:51 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-29 21:00 ` Jean Louis
2021-05-29 21:27 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-29 22:00 ` Jean Louis
2021-05-30 2:04 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-30 2:06 ` Stefan Monnier via Users list for the GNU Emacs text editor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=trinity-b909c76a-ecf6-40aa-84ab-1a0ed9a5b419-1622493042031@3c-app-mailcom-bs01 \
--to=dimech@gmx.com \
--cc=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).