all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Filipe Silva <filipe.silva@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: Seeking Advice about refactoring and advice snippet
Date: Fri, 10 Feb 2017 21:12:34 -0200	[thread overview]
Message-ID: <CAEwkUWPMqEZfi08fQmLA=TKMfWA6EsYDhZLiH7Mg-dbB0fWoYA@mail.gmail.com> (raw)
In-Reply-To: <jwv1sv525c3.fsf-monnier+gmane.emacs.help@gnu.org>

Stefan I noticed that your hack works even with M-x extended-buffer-menu,
while my advices don't.

I don't understand fully what that snippet does but that's some powerful
stuff, thank you!

On Fri, Feb 10, 2017 at 5:55 PM, Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> > How would you refactor that snippet to apply the dry principle?
>
> Here's how I'd refactor it:
>
>     (with-current-buffer (get-buffer "*scratch*")
>       (add-hook 'kill-buffer-hook
>                 (lambda () (error "DENIED! don't kill my precious
> *scratch*!!"))
>                 nil t))
>
> ;-)
>
>
>         Stefan
>
>
> PS: Along the same lines: kill-this-buffer calls kill-buffer, so you
> shouldn't need to advise kill-this-buffer.
>
>
>


  reply	other threads:[~2017-02-10 23:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-10 11:43 Seeking Advice about refactoring and advice snippet Filipe Silva
2017-02-10 13:08 ` Yuri Khan
2017-02-10 16:22   ` Filipe Silva
2017-02-10 13:44 ` Narendra Joshi
2017-02-10 14:17 ` Chunyang Xu
2017-02-10 16:24   ` Filipe Silva
2017-02-10 17:02 ` Filipe Silva
2017-02-10 19:55 ` Stefan Monnier
2017-02-10 23:12   ` Filipe Silva [this message]
2017-02-11  0:01     ` Stefan Monnier

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='CAEwkUWPMqEZfi08fQmLA=TKMfWA6EsYDhZLiH7Mg-dbB0fWoYA@mail.gmail.com' \
    --to=filipe.silva@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.