From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Jamie Beardslee Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Add user option to disable location in bookmarks Date: Sun, 21 Jun 2020 12:22:07 +1200 Message-ID: <87r1u9mfo0.fsf@gmail.com> References: <87sgep35cb.fsf@gmail.com> <87blld2x5h.fsf@gmail.com> <062414c6-41f4-4803-9a62-28274825b8e0@default> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="120897"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: emacs-devel@gnu.org Cancel-Lock: sha1:TRurf9GchTR/HcYmvCWUOcYzvTI= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jun 21 02:22:56 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jmnlA-000VQv-GM for ged-emacs-devel@m.gmane-mx.org; Sun, 21 Jun 2020 02:22:56 +0200 Original-Received: from localhost ([::1]:44408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmnl9-0002ir-JE for ged-emacs-devel@m.gmane-mx.org; Sat, 20 Jun 2020 20:22:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmnkb-0001xh-6L for emacs-devel@gnu.org; Sat, 20 Jun 2020 20:22:22 -0400 Original-Received: from ciao.gmane.io ([159.69.161.202]:60942) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmnkZ-0004gu-Jx for emacs-devel@gnu.org; Sat, 20 Jun 2020 20:22:20 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jmnkW-000UgZ-3I for emacs-devel@gnu.org; Sun, 21 Jun 2020 02:22:16 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=159.69.161.202; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/20 18:24:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 20 X-Spam_score: 2.0 X-Spam_bar: ++ X-Spam_report: (2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:252476 Archived-At: --=-=-= Content-Type: text/plain >> 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Allow-save-place-to-override-the-position-when-using.patch >From c4378882ef88fafcd04017d1942f673658b04dd1 Mon Sep 17 00:00:00 2001 From: Jamie Beardslee 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 --=-=-=--