From: Michal Nazarewicz <mina86@mina86.com>
To: Juanma Barranquero <lekktu@gmail.com>
Cc: Ted Zlatanov <tzz@lifelogs.com>,
Stefan Monnier <monnier@iro.umontreal.ca>,
Emacs developers <emacs-devel@gnu.org>
Subject: Re: [PATCH] Add `notes' function to store random notes across Emacs restarts.
Date: Mon, 17 Jun 2013 22:39:40 +0200 [thread overview]
Message-ID: <xa1tobb4o4j7.fsf@mina86.com> (raw)
In-Reply-To: <CAAeL0SR6kxtuMpco2=MXOYcbFBoDN1cHqmVWXu9c+mVkos7uJw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2233 bytes --]
On Mon, Jun 17 2013, Juanma Barranquero wrote:
>> +only one C-c C-c binding which saves and buries the buffer.
>
> Use \\[notes-save-and-bury] instead of hard-coded C-c C-c
I'm not certain how that's supposed to work. The binding is not in
global key map after all.
>> + ;; We don't want a "Buffer modified" prompt from kill-buffer so
>> + ;; we have to use advice rather than a hook.
>> + (advice-add 'kill-buffer :around 'notes--kill-buffer-advice)
>
> Why cannot that be done from kill-buffer-hook?
Because kill-buffer-hook is called after kill-buffer checks whether file
is modified:
DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ",
doc: /* … */)
(Lisp_Object buffer_or_name)
/* … */
/* Query if the buffer is still modified. */
if (INTERACTIVE && !NILP (BVAR (b, filename))
&& BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
{
GCPRO1 (buffer);
tem = do_yes_or_no_p (format2 ("Buffer %s modified; kill anyway? ",
BVAR (b, name), make_number (0)));
UNGCPRO;
if (NILP (tem))
return Qnil;
}
/* Run hooks with the buffer to be killed the current buffer. */
{
ptrdiff_t count = SPECPDL_INDEX ();
Lisp_Object arglist[1];
record_unwind_protect (save_excursion_restore, save_excursion_save ());
set_buffer_internal (b);
/* First run the query functions; if any query is answered no,
don't kill the buffer. */
arglist[0] = Qkill_buffer_query_functions;
tem = Frun_hook_with_args_until_failure (1, arglist);
if (NILP (tem))
return unbind_to (count, Qnil);
/* Then run the hooks. */
Frun_hooks (1, &Qkill_buffer_hook);
unbind_to (count, Qnil);
}
/* … */
}
I'll add some more explanation to the comment but other than that, short
of creating a new hook, I see no other satisfactory solution.
(All other comments applied to the code).
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--
[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]
next prev parent reply other threads:[~2013-06-17 20:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-17 16:13 [PATCH] Add `notes' function to store random notes across Emacs restarts Michal Nazarewicz
2013-06-17 16:44 ` Stefan Monnier
2013-06-17 20:24 ` Michal Nazarewicz
2013-06-17 17:00 ` Juanma Barranquero
2013-06-17 20:39 ` Michal Nazarewicz [this message]
2013-06-17 21:06 ` Juanma Barranquero
2013-06-17 23:47 ` Michal Nazarewicz
2013-06-18 7:20 ` martin rudalics
2013-06-18 12:24 ` Michal Nazarewicz
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=xa1tobb4o4j7.fsf@mina86.com \
--to=mina86@mina86.com \
--cc=emacs-devel@gnu.org \
--cc=lekktu@gmail.com \
--cc=monnier@iro.umontreal.ca \
--cc=tzz@lifelogs.com \
/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.