From: Marcin Borkowski <mbork@mbork.pl>
To: Jean Louis <bugs@gnu.support>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to reliably edit a file from within Emacs Lisp and return a string?
Date: Fri, 23 Aug 2019 23:44:06 +0200 [thread overview]
Message-ID: <877e73tv4p.fsf@mbork.pl> (raw)
In-Reply-To: <20190823140145.GA28153@protected.rcdrun.com>
On 2019-08-23, at 16:01, Jean Louis <bugs@gnu.support> wrote:
> Anything, any solution is fine, but I would not like to rely on
> C-M-c, rather on killing of the buffer to which the file is
> related.
I have not followed this thread very closely, so maybe I'm
misunderstanding something. Nevertheless, here are my 2 cents.
Cent number 1 is: I had a similar problem. I wanted to be able to edit
something in Emacs and I wanted Emacs to do something when I finish it.
So, I created a dedicated minor mode, with C-c C-c bound to
a "finishing" function. (I'm 99% sure I haven't blogged about it.
Should I?)
Cent number 2 is: why don't you just do the same, and rebind C-x k in
your minor mode to do something useful? It's not bullet-proof, of
course, since you might kill the buffer in some other way, but if your
habit is one part of the problem - that should help, no? I would even
go as far as making C-x k play the "sad trombone" sound and tell you
(possibly with dancing elephants™) that you should use C-c C-c instead
(which is a customary way of telling Emacs "I'm done with whatever I've
been doing in this buffer" - it works this way in WDired, message-mode,
Magit and many other places)? Of course, you should then bind C-c C-c
in *your* minor mode to *your* finishing ("commit") function.
This way, instead of fixing Emacs, you would fix yourself instead - but
still, the problem would be fixed.
Bonus cent (related to emacs client/server): I have this in my init.el:
--8<---------------cut here---------------start------------->8---
(require 'server)
(if (server-running-p)
(load-theme 'green-phosphor t)
(setq confirm-kill-emacs #'yes-or-no-p)
(server-start)
(global-set-key (kbd "C-x C-3") 'server-edit))
--8<---------------cut here---------------end--------------->8---
What this does is:
- it starts the server by default,
- if makes every other Emacs instance _not_ start the server (this
wouldn't work anyway), and make it stand out using a very distnictive
theme (so that I do not accidentally spawn another Emacs session, forget
about it and try to use it for my normal tasks),
- make exiting from my main session hard and leave exiting from other
ones easy,
- and fix the terrible C-x # binding (which requires using the control
key first and shift next).
(I blogged about this setup here:
http://mbork.pl/2019-01-06_Emacs_server_and_other_Emacs_instances).
Hth,
--
Marcin Borkowski
http://mbork.pl
next prev parent reply other threads:[~2019-08-23 21:44 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-22 21:31 How to reliably edit a file from within Emacs Lisp and return a string? Jean Louis
2019-08-22 22:01 ` Noam Postavsky
2019-08-22 22:46 ` Jean Louis
2019-08-22 23:10 ` Óscar Fuentes
2019-08-22 23:22 ` Noam Postavsky
2019-08-23 1:19 ` Jean Louis
2019-08-23 1:27 ` Noam Postavsky
2019-08-23 7:49 ` Eli Zaretskii
2019-08-23 14:01 ` Jean Louis
2019-08-23 14:14 ` Robert Pluim
2019-08-24 12:20 ` Jean Louis
2019-08-24 12:24 ` Jean Louis
2019-08-23 14:25 ` Eli Zaretskii
2019-08-24 12:19 ` Jean Louis
2019-08-24 12:30 ` Eli Zaretskii
2019-08-24 12:41 ` Jean Louis
2019-08-24 13:17 ` Eli Zaretskii
2019-08-24 14:14 ` Jean Louis
2019-08-24 14:55 ` Jean Louis
2019-08-24 15:10 ` Eli Zaretskii
2019-08-24 15:51 ` Jean Louis
2019-08-24 16:11 ` Eli Zaretskii
2019-08-24 16:44 ` Jean Louis
2019-08-24 16:55 ` Eli Zaretskii
2019-08-24 17:02 ` Eli Zaretskii
2019-08-24 17:17 ` Jean Louis
2019-08-24 17:23 ` Eli Zaretskii
2019-08-24 17:37 ` Jean Louis
2019-08-24 18:25 ` Eli Zaretskii
2019-08-24 18:50 ` Jean Louis
2019-08-24 19:03 ` Eli Zaretskii
2019-08-24 21:30 ` Jean Louis
2019-08-24 17:15 ` Jean Louis
2019-08-24 17:22 ` Eli Zaretskii
2019-08-24 16:18 ` Yuri Khan
2019-08-24 17:07 ` Jean Louis
2019-08-24 13:08 ` Jean Louis
2019-08-23 21:44 ` Marcin Borkowski [this message]
2019-08-24 12:15 ` Jean Louis
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877e73tv4p.fsf@mbork.pl \
--to=mbork@mbork.pl \
--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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.