all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Add user option to disable location in bookmarks
@ 2020-06-20 19:27 Jamie Beardslee
  2020-06-20 21:35 ` Drew Adams
  0 siblings, 1 reply; 11+ messages in thread
From: Jamie Beardslee @ 2020-06-20 19:27 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 238 bytes --]

Hi,

I've just started using save-place-mode, and found that bookmarks really
get in the way.  I figure there are probably a lot of people that use
bookmarks just to save some common files, rather than locations within a
file.

--
Jamie


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Add-user-option-to-disable-location-in-bookmarks.patch --]
[-- Type: text/x-patch, Size: 2584 bytes --]

From 17db59cbb7e060bed4c181f459b80cb67c1163b5 Mon Sep 17 00:00:00 2001
From: Jamie Beardslee <beardsleejamie@gmail.com>
Date: Sun, 21 Jun 2020 06:59:12 +1200
Subject: [PATCH] Add user option to disable location in bookmarks

When `bookmark-use-location' set to nil, bookmark-default-handler
won't try to jump to the right location in the file.

This way bookmarks can be used to just save regularly used files, and
save-place (or similar) can be relied on to, well, save the place.
---
 lisp/bookmark.el | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 5bb1698171..3687a0b20f 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -170,6 +170,10 @@ bookmark-menu-heading
   "Face used to highlight the heading in bookmark menu buffers."
   :version "22.1")
 
+(defcustom bookmark-use-location t
+  "Whether to open the specific location of bookmarked files.
+See also `save-place-mode'."
+  :type 'boolean)
 
 ;;; No user-serviceable parts beyond this point.
 
@@ -1224,16 +1228,17 @@ bookmark-default-handler
       ((and buf (get-buffer buf)))
       (t ;; If not, raise error.
        (signal 'bookmark-error-no-filename (list 'stringp file)))))
-    (if place (goto-char place))
-    ;; Go searching forward first.  Then, if forward-str exists and
-    ;; was found in the file, we can search backward for behind-str.
-    ;; Rationale is that if text was inserted between the two in the
-    ;; file, it's better to be put before it so you can read it,
-    ;; rather than after and remain perhaps unaware of the changes.
-    (when (and forward-str (search-forward forward-str (point-max) t))
-      (goto-char (match-beginning 0)))
-    (when (and behind-str (search-backward behind-str (point-min) t))
-      (goto-char (match-end 0)))
+    (when bookmark-use-location
+      (if place (goto-char place))
+      ;; Go searching forward first.  Then, if forward-str exists and
+      ;; was found in the file, we can search backward for behind-str.
+      ;; Rationale is that if text was inserted between the two in the
+      ;; file, it's better to be put before it so you can read it,
+      ;; rather than after and remain perhaps unaware of the changes.
+      (when (and forward-str (search-forward forward-str (point-max) t))
+        (goto-char (match-beginning 0)))
+      (when (and behind-str (search-backward behind-str (point-min) t))
+        (goto-char (match-end 0))))
     nil))
 
 ;;;###autoload
-- 
2.27.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 519 bytes --]

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-06-21 18:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-20 19:27 [PATCH] Add user option to disable location in bookmarks Jamie Beardslee
2020-06-20 21:35 ` Drew Adams
2020-06-20 22:24   ` Jamie Beardslee
2020-06-20 22:50     ` Stefan Monnier
2020-06-20 23:37       ` Drew Adams
2020-06-20 23:34     ` Drew Adams
2020-06-21  0:22       ` Jamie Beardslee
2020-06-21  5:19         ` Drew Adams
2020-06-21  9:56         ` Basil L. Contovounesios
2020-06-21  9:13       ` Yuri Khan
2020-06-21 18:44         ` Drew Adams

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.