From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Puneeth Chaganti <punchagan@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>, Rasmus <rasmus@gmx.us>
Subject: Re: [PATCH] org-id-goto doesn't work if buffer is narrowed.
Date: Sun, 25 Oct 2015 10:42:37 +0100 [thread overview]
Message-ID: <877fmbb7xu.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CALnw1fR6G=cHgT+Rk52XRHU-T=oZm+vyihyjLZU_bp0sqh5zeA@mail.gmail.com> (Puneeth Chaganti's message of "Sun, 25 Oct 2015 14:40:23 +0530")
Puneeth Chaganti <punchagan@gmail.com> writes:
> Thanks for your careful review and detailed comments. I've attached
> an updated patch.
Thank you. I have another suggestion about it.
> +(defun org-id-show (id cmd)
> + "Show an entry with id ID by buffer-switching using CMD.
> +CMD is a function that takes a buffer or a string (buffer name)
> +as an argument, which will be used to switch to the buffer
> +containing the entry with id ID."
> + (let ((m (org-id-find id 'marker)))
> + (unless m
> + (error "Cannot find entry with ID \"%s\"" id))
> + (unless (equal (current-buffer) (marker-buffer m))
> + (funcall cmd (marker-buffer m)))
Nitpick: (eq (current-buffer) (marker-buffer m))
> + (when (let ((pos (marker-position m)))
> + (or (< pos (point-min))
> + (> pos (point-max))))
> + (widen))
> + (goto-char m)
> + (move-marker m nil)
> + (org-show-context 'link-search)))
If CMD raises an error, you have a dangling marker in the buffer, which
is not a great idea. I suggest to wrap everything into
a `unwind-protect' and add (set-marker m nil) as an unwindform, i.e.,
(let ((m (org-id-find id 'marker)))
(unless m (error "Cannot find entry with ID \"%s\"" id))
(unwind-protect
(progn
(unless (eq (current-buffer) (marker-buffer m))
(funcall cmd (marker-buffer m)))
(when (let ((pos (marker-position m)))
(or (< pos (point-min))
(> pos (point-max))))
(widen))
(goto-char m)
(org-show-context 'link-search))
(set-marker m nil)))
Regards,
next prev parent reply other threads:[~2015-10-25 9:40 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-23 15:11 [PATCH] org-id-goto doesn't work if buffer is narrowed Puneeth Chaganti
2015-10-23 15:27 ` Rasmus
2015-10-23 18:05 ` Puneeth Chaganti
2015-10-23 18:48 ` John Kitchin
2015-10-23 20:22 ` Rasmus
2015-10-24 5:29 ` Puneeth Chaganti
2015-10-24 11:33 ` John Kitchin
2015-10-24 11:49 ` Puneeth Chaganti
2015-10-24 11:57 ` Nicolas Goaziou
2015-10-24 12:47 ` Rasmus
2015-10-24 17:48 ` John Kitchin
2015-10-24 18:03 ` Rasmus
2015-10-25 11:11 ` John Kitchin
2015-10-24 12:27 ` Rasmus
2015-10-25 2:24 ` Puneeth Chaganti
2015-10-25 3:12 ` Puneeth Chaganti
2015-10-25 8:38 ` Nicolas Goaziou
2015-10-25 9:10 ` Puneeth Chaganti
2015-10-25 9:42 ` Nicolas Goaziou [this message]
2015-10-25 9:57 ` Puneeth Chaganti
2015-10-25 11:19 ` Rasmus
2015-10-26 14:14 ` Puneeth Chaganti
2015-10-23 19:59 ` Matt Lundin
2015-10-23 20:18 ` Rasmus
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=877fmbb7xu.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=punchagan@gmail.com \
--cc=rasmus@gmx.us \
/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.