From: Jamie Beardslee <beardsleejamie@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: [PATCH] Add user option to disable location in bookmarks
Date: Sun, 21 Jun 2020 12:22:07 +1200 [thread overview]
Message-ID: <87r1u9mfo0.fsf@gmail.com> (raw)
In-Reply-To: 062414c6-41f4-4803-9a62-28274825b8e0@default
[-- Attachment #1: Type: text/plain, Size: 1106 bytes --]
>> My patch allows the user to choose whether or not the bookmark record
>> should be in control of the position.
>
> The bookmark record has already chosen that. Just use a different
> kind of record. Why have an option that acts in a blanket manner on
> all bookmarks, to ignore their position?
I don't see the problem here, surely some users would want to ignore
bookmarks' positions. There isn't a similar built-in library that
doesn't save position so I feel it should be an option provided by
bookmark.el without the user needing to define their own handler.
> If this is about save-place then save-place should do the right thing.
> See above. If there's an option to be added in that regard, it's a
> save-place option: `save-place-ignore-bookmark-position'. The hook
> function (see above) can move to the save-place place if the option is
> non-nil, and just do nothing if it's nil.
Okay, well I've attached that patch here. I understand this is skipping
over one of the best features of bookmarks, but I still think it's a
valuable option even without the use of save-place.
--
Jamie
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-save-place-to-override-the-position-when-using.patch --]
[-- Type: text/x-patch, Size: 1797 bytes --]
From c4378882ef88fafcd04017d1942f673658b04dd1 Mon Sep 17 00:00:00 2001
From: Jamie Beardslee <beardsleejamie@gmail.com>
Date: Sun, 21 Jun 2020 11:59:44 +1200
Subject: [PATCH] Allow save-place to override the position when using
bookmarks.
When the user option `save-place-override-bookmark' is non-nil,
save-place will go to the last position rather than the position
specified in the bookmark record.
---
lisp/saveplace.el | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lisp/saveplace.el b/lisp/saveplace.el
index 46738ab03d..f32c1ad753 100644
--- a/lisp/saveplace.el
+++ b/lisp/saveplace.el
@@ -118,12 +118,22 @@ save-place-ignore-files-regexp
:version "24.1"
:type 'regexp)
+(defcustom save-place-override-bookmark nil
+ "Whether `save-place' should override bookmarks.
+
+Normally, a bookmark is used to save a specific point in a buffer
+or file. If this is non-nil, `save-place' will provide the
+position instead."
+ :type 'boolean)
+
(declare-function dired-current-directory "dired" (&optional localp))
(defun save-place--setup-hooks (add)
(cond
(add
(add-hook 'find-file-hook #'save-place-find-file-hook t)
+ (eval-after-load "bookmark"
+ '(add-hook 'bookmark-after-jump-hook #'save-place-bookmark-hook t))
(add-hook 'dired-initial-position-hook #'save-place-dired-hook)
(unless noninteractive
(add-hook 'kill-emacs-hook #'save-place-kill-emacs-hook))
@@ -334,6 +344,10 @@ save-place-find-file-hook
;; and make sure it will be saved again for later
(setq save-place-mode t)))))
+(defun save-place-bookmark-hook ()
+ (when save-place-override-bookmark
+ (save-place-find-file-hook)))
+
(declare-function dired-goto-file "dired" (file))
(defun save-place-dired-hook ()
--
2.27.0
next prev parent reply other threads:[~2020-06-21 0:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=87r1u9mfo0.fsf@gmail.com \
--to=beardsleejamie@gmail.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).