From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Filipe Silva Newsgroups: gmane.emacs.help Subject: Re: Seeking Advice about refactoring and advice snippet Date: Fri, 10 Feb 2017 21:12:34 -0200 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1486768380 17896 195.159.176.226 (10 Feb 2017 23:13:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 10 Feb 2017 23:13:00 +0000 (UTC) Cc: Help Gnu Emacs mailing list To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 11 00:12:56 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ccKN6-0004Tz-H1 for geh-help-gnu-emacs@m.gmane.org; Sat, 11 Feb 2017 00:12:56 +0100 Original-Received: from localhost ([::1]:46383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccKNC-00071O-4T for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Feb 2017 18:13:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccKMm-0006zw-Ja for help-gnu-emacs@gnu.org; Fri, 10 Feb 2017 18:12:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ccKMl-0000wt-Kr for help-gnu-emacs@gnu.org; Fri, 10 Feb 2017 18:12:36 -0500 Original-Received: from mail-ot0-x229.google.com ([2607:f8b0:4003:c0f::229]:33869) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ccKMl-0000wm-F6 for help-gnu-emacs@gnu.org; Fri, 10 Feb 2017 18:12:35 -0500 Original-Received: by mail-ot0-x229.google.com with SMTP id f9so39867597otd.1 for ; Fri, 10 Feb 2017 15:12:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=DZY6PjC+92ZFH2IDzW1PpQTikgtCKC3JRYuVfL4VrJE=; b=aQSImNLKxh/lciO1/HxA1eGWeBZpMPjv6mmmHxPJPpH7ZOfDg+NRVPGWSl1OcBhUcJ QWFwYrOpU7T00eJNkYy8u5a1BN6ICZjHYkosImQAdXJUIwxhG7XdrR212HK9jup+Erw8 6taXw/jVstUoRfU4xauEWESPa83ycuRVuTIxYyICNkarV4wwwiwvm4bFTpYGoudcgca1 4dL2U8uwtJgVW89PnEKXii1YZLWoHrNERYVw6ui7/CS3qlP+yVlzx8TcgfVLZrnkk/pw EuHDiU6PYIG/8L+vRAHda5FQ3sz+ai/k5gLZCM+6nPmSvrH6yQ4f3OyFRVJUlz40aNYO XpfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=DZY6PjC+92ZFH2IDzW1PpQTikgtCKC3JRYuVfL4VrJE=; b=Srlxo3xmFPkjuA4TCmbFh9G6g+xfLdDL4mQ5UD/TZt5bjSYYwhNt94KNhXdnXFrF2/ rwOmGzH44ONwIrlwUlpqPjMP1dchzajUOkWOGCq5lJ1WC0eZzLr9/DHY/6gQ60lNmi/k RtPkjp6ZAPLMepCa6Vlid540+OLeWr96+nMdQhyoog54L87sJTqaF5OHfnt/G+80GMfg ITh4P0kECC3fkRp223bh+DueTPGmbAKjDFSc5xh2y/MwGuG3nwXKxkv4qyClf7s1NNur e4GJsUbFM34uf1CUXihGSVivTAj8VQolkobWUGRHEwRqP8RX9Pi00JMPaZyO4hxZP2LX tb1A== X-Gm-Message-State: AMke39l5ubDpdMPSAybLGAZ3T/S+uJd9E9qzAxznG2jCKODjLAxk1fh1S/2bLusljzzAOT7asRTg3NC4zuf3SQ== X-Received: by 10.157.6.164 with SMTP id 33mr5703008otx.43.1486768354922; Fri, 10 Feb 2017 15:12:34 -0800 (PST) Original-Received: by 10.157.56.242 with HTTP; Fri, 10 Feb 2017 15:12:34 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c0f::229 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112299 Archived-At: 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 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. > > >