aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2010-02-10 15:02:54 -0500
committerStefan Monnier2010-02-10 15:02:54 -0500
commitdbf8402bc76a775284905f09399b4d88ee0c03e5 (patch)
tree6615b2923ef8679dce88434e6c216e18f1ca45f0
parent2b23acdef6b4b0521e549b7ffe2d7e1b0f7910c3 (diff)
downloademacs-dbf8402bc76a775284905f09399b4d88ee0c03e5.tar.gz
emacs-dbf8402bc76a775284905f09399b4d88ee0c03e5.zip
(bookmark-handle-bookmark): Catch the right error.
(bookmark-default-handler): Accept new bookmark field `buffer'.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/bookmark.el36
2 files changed, 25 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 19d3bce3fc0..2a157d9f7fb 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12010-02-10 Thierry Volpiatto <thierry.volpiatto@gmail.com>
2
3 * bookmark.el (bookmark-handle-bookmark): Catch the right error.
4 (bookmark-default-handler): Accept new bookmark field `buffer'.
5
12010-02-10 Chong Yidong <cyd@stupidchicken.com> 62010-02-10 Chong Yidong <cyd@stupidchicken.com>
2 7
3 * iswitchb.el (iswitchb-completions): Revert last change. 8 * iswitchb.el (iswitchb-completions): Revert last change.
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 5af6ab91cc3..49abea5d3e3 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1068,7 +1068,7 @@ that file no longer exists, then offer interactively to relocate BOOKMARK."
1068 (funcall (or (bookmark-get-handler bookmark) 1068 (funcall (or (bookmark-get-handler bookmark)
1069 'bookmark-default-handler) 1069 'bookmark-default-handler)
1070 (bookmark-get-bookmark bookmark)) 1070 (bookmark-get-bookmark bookmark))
1071 (file-error 1071 (bookmark-error-no-filename ;file-error
1072 ;; We were unable to find the marked file, so ask if user wants to 1072 ;; We were unable to find the marked file, so ask if user wants to
1073 ;; relocate the bookmark, else remind them to consider deletion. 1073 ;; relocate the bookmark, else remind them to consider deletion.
1074 (when (stringp bookmark) 1074 (when (stringp bookmark)
@@ -1116,24 +1116,28 @@ that file no longer exists, then offer interactively to relocate BOOKMARK."
1116BMK-RECORD is a bookmark record, not a bookmark name (i.e., not a string). 1116BMK-RECORD is a bookmark record, not a bookmark name (i.e., not a string).
1117Changes current buffer and point and returns nil, or signals a `file-error'." 1117Changes current buffer and point and returns nil, or signals a `file-error'."
1118 (let ((file (bookmark-get-filename bmk-record)) 1118 (let ((file (bookmark-get-filename bmk-record))
1119 (buf (bookmark-prop-get bmk-record 'buffer))
1119 (forward-str (bookmark-get-front-context-string bmk-record)) 1120 (forward-str (bookmark-get-front-context-string bmk-record))
1120 (behind-str (bookmark-get-rear-context-string bmk-record)) 1121 (behind-str (bookmark-get-rear-context-string bmk-record))
1121 (place (bookmark-get-position bmk-record))) 1122 (place (bookmark-get-position bmk-record)))
1122 (if (not file) 1123 (set-buffer
1123 (signal 'bookmark-error-no-filename (list 'stringp file)) 1124 (cond
1124 (set-buffer (find-file-noselect file)) 1125 ((and file (file-readable-p file) (not (buffer-live-p buf)))
1125 (if place (goto-char place)) 1126 (find-file-noselect file))
1126 ;; Go searching forward first. Then, if forward-str exists and 1127 ;; No file found. See if buffer BUF have been created.
1127 ;; was found in the file, we can search backward for behind-str. 1128 ((and buf (get-buffer buf)))
1128 ;; Rationale is that if text was inserted between the two in the 1129 (t ;; If not, raise error.
1129 ;; file, it's better to be put before it so you can read it, 1130 (signal 'bookmark-error-no-filename (list 'stringp file)))))
1130 ;; rather than after and remain perhaps unaware of the changes. 1131 (if place (goto-char place))
1131 (if forward-str 1132 ;; Go searching forward first. Then, if forward-str exists and
1132 (if (search-forward forward-str (point-max) t) 1133 ;; was found in the file, we can search backward for behind-str.
1133 (goto-char (match-beginning 0)))) 1134 ;; Rationale is that if text was inserted between the two in the
1134 (if behind-str 1135 ;; file, it's better to be put before it so you can read it,
1135 (if (search-backward behind-str (point-min) t) 1136 ;; rather than after and remain perhaps unaware of the changes.
1136 (goto-char (match-end 0))))) 1137 (when (and forward-str (search-forward forward-str (point-max) t))
1138 (goto-char (match-beginning 0)))
1139 (when (and behind-str (search-backward behind-str (point-min) t))
1140 (goto-char (match-end 0)))
1137 nil)) 1141 nil))
1138 1142
1139;;;###autoload 1143;;;###autoload