From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Porter Subject: Re: org-pop-mode Date: Wed, 18 Mar 2020 15:24:21 -0500 Message-ID: <87sgi5za16.fsf@alphapapa.net> References: <7d38c66d-6ea5-ff8f-ee39-142c8dbdcd18@kli.org> <87wo7hzd7g.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:57026) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEfEs-0006nF-JW for emacs-orgmode@gnu.org; Wed, 18 Mar 2020 16:24:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEfEr-0002Fx-Bj for emacs-orgmode@gnu.org; Wed, 18 Mar 2020 16:24:30 -0400 Received: from ciao.gmane.io ([159.69.161.202]:34910) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEfEr-0002Fe-5r for emacs-orgmode@gnu.org; Wed, 18 Mar 2020 16:24:29 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jEfEo-000WJm-0K for emacs-orgmode@gnu.org; Wed, 18 Mar 2020 21:24:26 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org "Mark E. Shoulson" writes: > Heh; fair enough.  The filename originally was "org-level-end.el", I > think; I started using the catchier "org-pop" because... well, it was > catchier.  It made sense in my mind, in the "push"/"pop" sense used > with stacks in programming, that you "push" to a deeper level and this > library would allow you to "pop" back up to a higher one.  I'll see if > I can think of something better, thanks. Well, org-heading-push-pop wouldn't be a /great/ name, but the push/pop paradigm is understandable, so you might consider that. :) > >> 2. In the code, I saw you comment about cl-flet, and I see you using >> fset and unwind-protect in the org-pop-with-continuations macro. >> Instead, use cl-letf with symbol-function, like: >> >> (cl-letf* (((symbol-function 'foo) >> #'my-foo) >> ((symbol-function 'bar) >> (lambda () >> ...))) >> BODY) >> >> See also Nic Ferrier's package, noflet. > > I'll take a look, thanks.  It's questionable whether I really should > even be messing about with that macro anyway.  I musnt have removed the > comments, but I had a whole thing there about how I had been trying > with cl-letf and/or cl-flet and it didn't work. Thing is, cl-flet, > according to the docs, (info:cl#Function Bindings) is strictly > *lexical* binding, which is not going to cut it.  cl-letf might be > different; the docs are different about it, but I am pretty sure I > tried it and it didn't work, or didn't work "enough of the time."  But > maybe I had it wrong, and maybe noflet will succeed. The issue is what the macros expand to. cl-letf rebinds the function symbols, just like fset, so it affects all code that runs in Emacs until the function symbols are set again. cl-flet expands into lambdas bound to variables and replaces calls to them with funcall, so it only affects calls in the macro's body. Use pp-macroexpand-last-sexp to see the expansions. BTW, in the body of your email, the text you write has these two characters between sentences: "  ". The second is a plain space, but the first is a Unicode non-breaking space, or "C-x 8 RET a0". I noticed because it's displayed in Emacs as an underline character next to the plain space.