From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.devel Subject: Re: New version of todo-mode.el (announcement + user guide) Date: Sat, 15 Jun 2013 14:52:16 +0200 Message-ID: <87y5abbkov.fsf@rosalinde.fritz.box> References: <87k3m2275u.fsf@rosalinde.fritz.box> <8761xmxfnx.fsf@bzg.ath.cx> <87txl6ghjq.fsf@rosalinde.fritz.box> <87a9myggr7.fsf@wanadoo.es> <87sj0p8z99.fsf@rosalinde.fritz.box> <87mwqwpk98.fsf@rosalinde.fritz.box> <6emwqvxmpo.fsf@fencepost.gnu.org> <8761xjdn7t.fsf@rosalinde.fritz.box> <87txl1bula.fsf@rosalinde.fritz.box> <87obb874ru.fsf@rosalinde.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1371300750 11442 80.91.229.3 (15 Jun 2013 12:52:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Jun 2013 12:52:30 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jun 15 14:52:30 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Unpy1-0006q7-GW for ged-emacs-devel@m.gmane.org; Sat, 15 Jun 2013 14:52:29 +0200 Original-Received: from localhost ([::1]:52265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Unpy1-0006jn-42 for ged-emacs-devel@m.gmane.org; Sat, 15 Jun 2013 08:52:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Unpxw-0006ja-FY for emacs-devel@gnu.org; Sat, 15 Jun 2013 08:52:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Unpxs-0001CC-BU for emacs-devel@gnu.org; Sat, 15 Jun 2013 08:52:24 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:55107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Unpxs-0001C2-27 for emacs-devel@gnu.org; Sat, 15 Jun 2013 08:52:20 -0400 Original-Received: from mailout-de.gmx.net ([10.1.76.10]) by mrigmx.server.lan (mrigmx001) with ESMTP (Nemesis) id 0LbOHk-1U4IcC46FG-00ktgq for ; Sat, 15 Jun 2013 14:52:18 +0200 Original-Received: (qmail invoked by alias); 15 Jun 2013 12:52:18 -0000 Original-Received: from i59F54841.versanet.de (EHLO rosalinde.fritz.box) [89.245.72.65] by mail.gmx.net (mp010) with SMTP; 15 Jun 2013 14:52:18 +0200 X-Authenticated: #20778731 X-Provags-ID: V01U2FsdGVkX1/DBElByfrDYCfQli7mgYtz4e1HwlGO34YUYBbkSW kA+efnoeL4O9YR In-Reply-To: (Stefan Monnier's message of "Fri, 14 Jun 2013 21:49:35 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.15.15 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:160448 Archived-At: On Fri, 14 Jun 2013 21:49:35 -0400 Stefan Monnier wrote: >> But it works when it's added at top-level. Moreover, it turns out that >> using :around isn't right, at least not without making it much more >> complicated AFAICT. It's much more straightforward to use :override. > > I don't see why, but it doesn't matter. I'll try explaining anyway, since if you see a way to do it that I'm overlooking, I'd like to know. There are two situations that diary-goto-entry handles (which entails two calls of the modified function): where a valid marker points to the diary entry location, and where there is no such marker. When the entry comes from a todo file in a live buffer, narrowing is in effect, so before finding the location, the buffer has to be widened, and then afterwards narrowed again, to restore the proper display. But what happens between widening and re-narrowing is different in the two situations (indicated below by the arrows pointing to the code executed by the :around advice) and I see no straightforward way to cover them both with a single :around advice. (Note that widening just before the third goto-char, which would allow the simple :around advice you suggested, is too late.) (defun diary-goto-entry (button) "Jump to the diary entry for the BUTTON at point." (let* ((locator (button-get button 'locator)) (marker (car locator)) markbuf file opoint) ;; If marker pointing to diary location is valid, use that. (if (and marker (setq markbuf (marker-buffer marker))) (progn (pop-to-buffer markbuf) 1a=> (when (eq major-mode 'todos-mode) (widen)) (goto-char (marker-position marker)) 1b=> (todos-diary-goto-entry)) ;; Marker is invalid (eg buffer has been killed). (or (and (setq file (cadr locator)) (file-exists-p file) (find-file-other-window file) (progn (when (eq major-mode (default-value 'major-mode)) (diary-mode)) 2a=> (when (eq major-mode 'todos-mode) (widen)) (goto-char (point-min)) (when (re-search-forward (format "%s.*\\(%s\\)" (regexp-quote (nth 2 locator)) (regexp-quote (nth 3 locator))) nil t) (goto-char (match-beginning 1)) 2b=> (todos-diary-goto-entry)))) (message "Unable to locate this diary entry"))))) Actually, I don't see why the first situation, using a valid marker, is needed. I suppose executing that code is quicker than doing a regexp search, but I doubt it's noticeable, perhaps unless the file is really huge. If diary-goto-entry were changed to always search for the entry, then the simple :around advice would be fine. If it isn't changed, I think using :override advice is the simplest alternative. Steve Berman