From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] org-id-goto doesn't work if buffer is narrowed. Date: Sun, 25 Oct 2015 09:38:52 +0100 Message-ID: <87k2qbbaw3.fsf@nicolasgoaziou.fr> References: <874mhh1u7s.fsf@gmx.us> <87oafpz65e.fsf@gmx.us> <87pp04zc1r.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqGnh-0008Fc-Ag for emacs-orgmode@gnu.org; Sun, 25 Oct 2015 04:37:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqGng-0005aG-A7 for emacs-orgmode@gnu.org; Sun, 25 Oct 2015 04:37:13 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:53390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqGng-0005a8-31 for emacs-orgmode@gnu.org; Sun, 25 Oct 2015 04:37:12 -0400 In-Reply-To: (Puneeth Chaganti's message of "Sun, 25 Oct 2015 08:42:33 +0530") 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.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Puneeth Chaganti Cc: emacs-orgmode , Rasmus Hello, Puneeth Chaganti writes: > Here is a patch that works for the case you describe. Thank you. Some comments follow. > + (org-id-show id 'org-pop-to-buffer-same-window)) (org-id-show id #'org-pop-to-buffer-same-window) > +(defun org-id-show (id cmd) > + "Show an entry with id ID by buffer-switching using CMD." You should explain what is CMD. If it is a function, you should spell out its signature. > + (let ((m (org-id-find id 'marker))) > + (unless m > + (error "Cannot find entry with ID \"%s\"" id)) > + (if (not (equal (current-buffer) (marker-buffer m))) > + (funcall cmd (marker-buffer m))) (unless (eq (current-buffer) (marker-buffer m)) ...) > + (when (and (org-buffer-narrowed-p) > + (let ((pos (marker-position m))) > + (or (< pos (point-min)) > + (> pos (point-max))))) > + (widen)) `org-buffer-narrowed-p' is not useful here since you check boundaries right after its call. (when (let ((pos (marker-position m))) (or (< pos (point-min)) (> pos (point-max)))) (widen)) > + (goto-char m) > + (move-marker m nil) > + (org-show-context))) I think this should be (org-show-context 'link-search) according to `org-show-context-detail'. > ;; id link type > > ;; Calling the following function is hard-coded into `org-store-link', > @@ -659,25 +669,15 @@ optional argument MARKERP, return the position as a new marker." > (defun org-id-open (id) > "Go to the entry with id ID." > (org-mark-ring-push) > - (let ((m (org-id-find id 'marker)) > - cmd) > - (unless m > - (error "Cannot find entry with ID \"%s\"" id)) > - ;; Use a buffer-switching command in analogy to finding files > - (setq cmd > - (or > - (cdr > - (assq > - (cdr (assq 'file org-link-frame-setup)) > - '((find-file . switch-to-buffer) > - (find-file-other-window . switch-to-buffer-other-window) > - (find-file-other-frame . switch-to-buffer-other-frame)))) > - 'switch-to-buffer-other-window)) > - (if (not (equal (current-buffer) (marker-buffer m))) > - (funcall cmd (marker-buffer m))) > - (goto-char m) > - (move-marker m nil) > - (org-show-context))) > + (let ((cmd (or > + (cdr > + (assq > + (cdr (assq 'file org-link-frame-setup)) > + '((find-file . switch-to-buffer) > + (find-file-other-window . switch-to-buffer-other-window) > + (find-file-other-frame . switch-to-buffer-other-frame)))) > + 'switch-to-buffer-other-window))) #'switch-to-buffer-other-window Regards, -- Nicolas Goaziou