unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Karl Fogel <kfogel@red-bean.com>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] Changes to emacs/lisp/bookmark.el,v
Date: Wed, 19 Nov 2008 02:50:44 -0500	[thread overview]
Message-ID: <87y6zggnmz.fsf@red-bean.com> (raw)
In-Reply-To: <E1KvFgL-00034A-Gp@cvs.savannah.gnu.org> (Chong Yidong's message of "Wed, 29 Oct 2008 18:22:13 +0000")

Regarding this change:

Chong Yidong <cyd@stupidchicken.com> writes:
> [[[
> (bookmark-get-bookmark-record): Signal error for invalid bookmark.
> ]]]
>
> Index: bookmark.el
> ===================================================================
> RCS file: /sources/emacs/emacs/lisp/bookmark.el,v
> retrieving revision 1.117
> retrieving revision 1.118
> diff -u -b -r1.117 -r1.118
> --- bookmark.el	29 Oct 2008 17:42:49 -0000	1.117
> +++ bookmark.el	29 Oct 2008 18:22:12 -0000	1.118
> @@ -330,7 +330,8 @@
>  (defun bookmark-get-bookmark-record (bookmark)
>    "Return the guts of the entry for BOOKMARK in `bookmark-alist'.
>  That is, all information but the name."
> -  (let ((alist (cdr (bookmark-get-bookmark bookmark))))
> +  (let ((alist (cdr (or (bookmark-get-bookmark bookmark)
> +			(error "Invalid bookmark %s" bookmark)))))
>      ;; The bookmark objects can either look like (NAME ALIST) or
>      ;; (NAME . ALIST), so we have to distinguish the two here.
>      (if (and (null (cdr alist)) (consp (caar alist)))

Seeing this change made me ask: "Why doesn't `bookmark-get-bookmark'
just return error itself, if no such bookmark?"

Answer: "Because some callers might expect it to return nil in that
case, rather than error."  (Even though it is not documented to do
either -- its doc string is silent on this question!)  I think there are
only two callers who would care, though.  In `bookmark-store', we have
this:

    (if (and (bookmark-get-bookmark stripped-name) (not no-overwrite))
        ;; already existing bookmark under that name and
        ;; no prefix arg means just overwrite old bookmark
        ;; Use the new (NAME . ALIST) format.
        (setcdr (bookmark-get-bookmark stripped-name) alist)
      ;; otherwise just cons it onto the front (either the bookmark
      ;; doesn't exist already, or there is no prefix arg.  In either
      ;; case, we want the new bookmark consed onto the alist...)
      (push (cons stripped-name alist) bookmark-alist))

And `bookmark-delete', this:

    (or (bookmark-get-bookmark bookmark-current-bookmark)
        (setq bookmark-current-bookmark nil)))

I'm tempted to add an optional NOERROR parameter to
`bookmark-get-bookmark'.  That way we'd many more error checks for free,
and could remove the special-case error check added in Chong Yidong's
change above.

Any objections to that?

As an aside: it's very difficult to review & respond to commits to
Emacs, because the ChangeLog entry arrives in a separate email from the
diff.  If the change package were kept intact (i.e., arrived as one
email, the way every other project in the universe does it), we'd
probably get more review here.

-Karl




       reply	other threads:[~2008-11-19  7:50 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1KvFgL-00034A-Gp@cvs.savannah.gnu.org>
2008-11-19  7:50 ` Karl Fogel [this message]
2008-11-19 19:17   ` Reviewing changes (was: [Emacs-diffs] Changes to emacs/lisp/bookmark.el, v) Eli Zaretskii
2008-11-19 22:06     ` Reviewing changes Karl Fogel
2008-11-19 22:12       ` Eli Zaretskii
2008-11-19 22:26         ` Thomas Lord
2008-11-20  5:21         ` Karl Fogel
2008-11-20  0:43       ` Stephen J. Turnbull
2008-11-20  6:37         ` Karl Fogel
2008-11-20  8:31           ` Stephen J. Turnbull
2008-11-20  2:13       ` Stefan Monnier
2008-11-20  4:17         ` Eli Zaretskii
2008-11-20  6:22           ` Karl Fogel
2008-11-20 14:30           ` Stefan Monnier
2008-11-20 20:19             ` Eli Zaretskii
2008-11-21  4:01               ` Stefan Monnier
2008-11-21  4:08                 ` mail
2008-11-21 11:28                 ` Eli Zaretskii
2008-11-21 14:32                   ` Stefan Monnier
2008-11-21 15:14                     ` Eli Zaretskii
2008-11-21 19:14                       ` Stefan Monnier
2008-11-20 10:25       ` Yavor Doganov
2008-11-21  4:05         ` Stefan Monnier
2008-11-20  5:39   ` [Emacs-diffs] Changes to emacs/lisp/bookmark.el,v Miles Bader
2008-11-20  9:37     ` Andreas Schwab
2008-11-20 10:09       ` Miles Bader
2008-11-20 20:22         ` Eli Zaretskii
2008-11-20 20:32           ` Juanma Barranquero
2008-11-20 20:44             ` Eli Zaretskii
2008-11-21  5:38           ` Karl Fogel
2008-11-21 11:43             ` Eli Zaretskii
2008-11-23 19:11               ` martin rudalics
2008-11-24 20:20                 ` Eli Zaretskii
2008-11-25 15:23                   ` Karl Fogel
2008-11-25 16:25                     ` martin rudalics
2008-11-25 16:25                   ` martin rudalics
2008-11-25 21:07                     ` Eli Zaretskii
2008-11-26  2:17                       ` Stephen J. Turnbull
2008-11-27 13:41                       ` martin rudalics
2008-11-27 16:35                         ` Stefan Monnier
2008-11-25 21:44                     ` Stefan Monnier
2008-11-21 19:29   ` Stefan Monnier
     [not found] <E1L2i1k-0000XC-CX@cvs.savannah.gnu.org>
     [not found] ` <f7ccd24b0811191458o3e2ad7d3v2370385de7dbb748@mail.gmail.com>
     [not found]   ` <87bpwbdkza.fsf@red-bean.com>
     [not found]     ` <f7ccd24b0811200035p91e01d3ideef573f393eb71c@mail.gmail.com>
2008-11-21  5:30       ` Karl Fogel

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y6zggnmz.fsf@red-bean.com \
    --to=kfogel@red-bean.com \
    --cc=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).