From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher Dimech Newsgroups: gmane.emacs.help Subject: How users start programming in Emacs Lisp... Date: Mon, 31 May 2021 22:30:42 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19768"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 31 22:32:14 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 1lnoa6-0004vC-CS for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 22:32:14 +0200 Original-Received: from localhost ([::1]:36910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnoa5-0005Bm-EH for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 16:32:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnoZC-0005As-OT for help-gnu-emacs@gnu.org; Mon, 31 May 2021 16:31:18 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:36813) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnoZ8-00066s-Pd for help-gnu-emacs@gnu.org; Mon, 31 May 2021 16:31:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1622493042; bh=5iGScB6HYvrBowxh4BUDpyfGANdWMhE3QIvqBK7wHY0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=RgxjvlVXTNe8eAPHFoRrOMgq8KAewv2P7iBkVb15QRdObcyVKF65n5iS4HAYRDaJ9 cmXMXgLnnROfKOihV1M+yEn8fh0OR3O5T4OCrlboAD59sBvDPfxgkFzmKmHyYrLWeA XfnMZ/hc8RDf/vjJ54gANdHvrHvKe8V1/BJTj1HU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs01.server.lan [172.19.170.58]) (via HTTP); Mon, 31 May 2021 22:30:42 +0200 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:Yh4dBgUGKsyJWGfNcZKUaeV3Kv6yh9PpyDn/OuEaNP/pADg6qh8LX4cFMwEiYUEMiE3/S 9wsbsl6B4k9njxls4C+Dtl0aXwY7MMhMFNzuTqUibMBxf9N/zvZWCqMe8l3e2/1aaamea0mYkOnM zGlSBVfNOXIYMljSTU8ksCSdocfB2b+4ntqpOpHUJKt6OWUsl8+ePU0ZCuiPZoyfdj7YamoUOY8/ 74pfL13Qa2FCSXIGIgc1hQC+i1PfE6eLHpCCMIhNvnZg8MdyeUExetg/EIn1TlseK3LXxyTjEqex Z4= X-UI-Out-Filterresults: notjunk:1;V03:K0:8Wh4xL1u8Zc=:7nPlDUjuR7RjY1Ywm/frqE t/A9SytAiKA/kDF5oV5qhziyPPrvdzgIzMd1YLpqhjSM1uxu3thzacdxksCh0+YNpqXeR9nsE jSiipYIWEi619zTYw7XCXVfVTxXDR7uWnJO3EJSAfOo/TD4xn137zmQ5ki/cTh2xq1aLiaShp T/g8qkcO7jzfoJkrdbQS5KkZLnk7OB9ZiLqvpuWHF2uU6M2kL7TfVPZ4j0R4za4R2hwAz1K8s M3ACrOXGFY4YhmRReuv79oB5jFCzQ/RLYlpZWu8V99EZU9GBuuWKNNRFAewVxm783euCHcFYf kaxmUcjDAGbPxvmvlk20SDtaEoag47Jo0moWLUz8ZUa8mLLCu1rLpY1jGOxmFNvBNpHd/gn7F tjVwic/hwF+Xzv9XHEIFz/xSbZhQFrcuE4QFmSZd/4Rf7FkzpTPc5b6pRS7//jAgMGGQNW+GR BZ2HyNUQOOB9jpchTuh40sDK3tUJCtvk3OYRdt51otUzWceJPMXPTCT1FdZn25le+q0ae/lwR PJD/tE5UrqzCwgfi9aP4n7tuVWEwR/ljPPiPeRruqzr9efZe8MccqrSCsNcJ4uFp/QptOpfJM h4hv2HezaNSNRofRMKNOS2GOUs4zInZ2BNyBUM0KwpnElH9wqH5GQ3fBEeK5UdWqYRqyuNQde mtEmNXgrYy1xVwMxWhOmBZI0szCaWvUJvtVk8VvoEXf6SC2GiDUhB6cfYdV5wIpSKHUlsLbKF zjHVpI1WiUq04C9n55G5oHhHrb5jteFqoAIrPkH6jDc6/Ap+0Fvx0aPv3Vuh6/jMXKVDFgiT Received-SPF: pass client-ip=212.227.17.22; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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:130391 Archived-At: I would like to be able to decide the name from the mini-buffer=2E How can that be done? ----- Christopher Dimech Society has became too quick to pass judgement and declare someone Persona= Non-Grata,=20 the most extreme form of censure a country can bestow=2E=20 In a new era of destructive authoritarianism, I support Richard Stallman= =2E Times of great=20 crisis are also times of great opportunity=2E I call upon you to make this= struggle yours as well ! https://stallmansupport=2Eorg/ https://www=2Efsf=2Eorg/ https://ww= w=2Egnu=2Eorg/ > Sent: Monday, May 31, 2021 at 7:48 AM > From: "Jean Louis" > To: "Christopher Dimech" > Cc: help-gnu-emacs@gnu=2Eorg > Subject: Re: How users start programming in Emacs Lisp=2E=2E=2E > > * Christopher Dimech [2021-05-30 20:22]: > > I am having some problem figuring out what the following does, having = format=20 > > repeated twice=2E > >=20 > > (format format ": " name) >=20 > It could be all simpler, it just adds the sub-name to the main name=2E >=20 > M-x rcd-temp-buffer would create *RCD TEMPORARY BUFFER: 1* >=20 > but (rcd-temp-buffer "Lisp") would create *RCD TEMPORARY BUFFER: Lisp* >=20 > 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=2E >=20 > Simpler way to open temporary buffer is just: >=20 > C-x b NAME-OF-YOUR-BUFFER >=20 > 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=2E Or invoke C-u prefix to be asked for the mode=2E >=20 > 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=2E >=20 > So I made this one=2E=2E=2E >=20 > (defun hyperscope-quick-emacs-lisp () > (interactive) > (let* ((id (hlink-add-generic (concat "Emacs Lisp: " (rcd-timestamp-li= terate)) "" 50 33)) > (template (rcd-db-get-entry "hlinktypes" "hlinktypes_template" 50 hs-d= b))) > (when template > (rcd-db-update-entry "hyobjects" "hyobjects_text" id template hs-d= b)) > (hyperscope-edit-with-mode id "hyobjects_text"))) >=20 > The "name" of the note should be something quick: >=20 > (concat "Emacs Lisp: " (rcd-timestamp-literate)) =E2=87=92 "Emacs Lisp: = Sunday, May 30 2021, 22:21:26" >=20 > 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=2E >=20 > 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=2E >=20 > Automatic saving is not a big deal, and automatic revision system > also=2E >=20 > What really matters is integration that brings speed to user without > thinking, and so the workflow is: >=20 > 1=2E Press F5, edit Emacs Lisp (forget about anything else) >=20 > 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=2E I did not manage to > make it=2E >=20 > I am aware that little of this makes sense to people who edit mostly > files=2E Some functionality can be for files: >=20 > ;;;; =E2=86=9D RCD TEMPORARY BUFFERS >=20 > (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" =2E "adoc") > ("emacs-lisp-mode" =2E "el") > ("lisp-mode" =2E "=2Elisp") > ("markdown-mode" =2E "=2Emd") > ("org-mode" =2E "org") > ("sql-mode" =2E "sql") > ("fundamental-mode" =2E "txt") > ("html-mode" =2E "html"))) >=20 > (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")))))) >=20 > (defun rcd-temp-file (&optional name mode) > "Quickly open temporary file=2E > Using C-u as prefix will ask you for the mode of the file and > will influence the extension=2E >=20 > NAME may be provided programmatically=2E > MODE may be provided as string programmatically=2E" > (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=2E")) > (cdr (assoc-string mode rcd-temp-buffer-modes))))) > (find-file file) > (save-buffer) > (auto-save-mode 1) > (funcall (intern mode)))) >=20 > (defun rcd-temp-buffer-destroy-em () > (interactive) > (kill-matching-buffers "RCD TEMPORARY BUFFER")) >=20 >=20 > 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: >=20 > /home/data1/protected/tmp/Sunday-May-30-2021-22:44:11=2Esql >=20 > Defining a key globally: >=20 > (global-set-key [f5] 'rcd-temp-file) >=20 > 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=2E >=20 >=20 > --=20 > Jean >=20 > Take action in Free Software Foundation campaigns: > https://www=2Efsf=2Eorg/campaigns >=20 > Sign an open letter in support of Richard M=2E Stallman > https://stallmansupport=2Eorg/ >