all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Karl Fogel'" <kfogel@red-bean.com>,
	"'Sun Yijiang'" <sunyijiang@gmail.com>
Cc: emacs-devel@gnu.org
Subject: RE: bookmark.el bug report
Date: Fri, 1 Jan 2010 23:51:07 -0800	[thread overview]
Message-ID: <F0FDFD6B81AC499A8EC8F1635ABF5D82@us.oracle.com> (raw)
In-Reply-To: <87r5q99jv9.fsf@red-bean.com>

> Note to Drew Adams: I took your suggestions about new constants.
> However, I did not wrap the new `save-excursion' in `ignore-errors'
> or `condition-case', because we should never be at eob right 
> after calling `bookmark-bmenu-ensure-position' (and if we are,
> I want to know).

Hi Karl,

Do as you like, but part of my message was that there is no need to call
`bookmark-bmenu-check-position' here (which you renamed `...ensure...').

Since the "check" part of that function doesn't really do anything, all it
really does is move point to the nearest bookmark line. If point is already on a
bookmark line, then it is a no-op.

And the way to tell if point is on a bookmark line is (now) to call
`bookmark-bmenu-bookmark'. So I use this simplified code (FWIW):

(defun bookmark-bmenu-check-position ()
  "Move to the beginning of the nearest bookmark line."
  (beginning-of-line)
  (unless (bookmark-bmenu-bookmark)
    (if (and (bolp) (eobp))
        (beginning-of-line 0)
      (goto-char (point-min))
      (forward-line bookmarkp-bmenu-header-lines)))
  t) ; Vanilla bookmark code depends on non-nil value.

(defun bookmark-bmenu-bookmark ()
  "Return the name of the bookmark on this line."
  (condition-case nil
      (save-excursion
       (forward-line 0)
       (forward-char (1+ bookmarkp-bmenu-marks-width))
       (get-text-property (point) 'bookmarkp-bookmark-name))
    (error nil)))

Instead of calling `*-bmenu-bookmark' at the beginning of `ensure' to check for
a no-op, the original code has it backward: it calls `ensure' at the start of
each call to `*-bmenu-bookmark', to ensure that point is on a bookmark line. But
for many calls to `*-bmenu-bookmark', we already know that point is on a
bookmark line.

If it is not called also within `*-bmenu-bookmark', then `ensure' is called much
less often than `*-bmenu-bookmark'. And the original code has extra calls to
`ensure', besides the one in `*-bmenu-mark'. In fact, it often calls it both at
the beginning and at the end of a function (e.g. `*-bmenu-delete').

`ensure' only needs to be called before some (not all) of the calls to
`*-bmenu-bookmark' - it has no use otherwise.

That's why I said you can get rid of some of the calls to `ensure'. But if
`ensure' is not called from within `*-bmenu-bookmark' then you need to protect
the eob case (just to inhibit a msg) - hence the `condition-case'.

HTH.

--

I don't know what changes you actually made, since I cannot see them here:
http://cvs.savannah.gnu.org/viewvc/emacs/emacs/lisp/
The last revision of bookmark.el shown there dates from Nov 24.

Has the URL for the Emacs development source code changed, now that the
repository is on BZR? If so, what is it - how does one get to the source code
via HTTP? And if that URL is no longer valid, then its Web page should redirect
to the proper URL, no?

Personally, I do not intend to access the repository using BZR (just as I did
not use CVS to access it before). I'm looking for a way to download a revision
by just clicking an ordinary web-page link in my browser, as before.





  parent reply	other threads:[~2010-01-02  7:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-28  6:19 bookmark.el bug report Sun Yijiang
2009-12-28  6:48 ` Karl Fogel
2009-12-28  7:41   ` Thierry Volpiatto
2009-12-28 15:58     ` Drew Adams
2009-12-28 21:12       ` Karl Fogel
2009-12-29 18:22         ` Stefan Monnier
2009-12-30 13:37           ` Thierry Volpiatto
2009-12-30 15:28             ` Stefan Monnier
2009-12-30 15:57               ` Drew Adams
2009-12-30 16:26                 ` Drew Adams
2009-12-30 17:43               ` Thierry Volpiatto
2009-12-30 18:32                 ` Stefan Monnier
2010-01-02  5:05 ` Karl Fogel
2010-01-02  5:15   ` Karl Fogel
2010-01-02  7:03     ` Thierry Volpiatto
2010-01-02  7:26       ` Karl Fogel
2010-01-02  8:15         ` Thierry Volpiatto
2010-01-02 19:17           ` Karl Fogel
2010-01-02  7:51   ` Drew Adams [this message]
2010-01-02  8:16     ` Karl Fogel
2010-01-02  8:42       ` Drew Adams

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=F0FDFD6B81AC499A8EC8F1635ABF5D82@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=kfogel@red-bean.com \
    --cc=sunyijiang@gmail.com \
    /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.