branch: externals/hyperbole commit 2166ac89530ca854a5debe1c96330a9eb289a0b5 Author: Robert Weiner <r...@gnu.org> Commit: GitHub <nore...@github.com>
hui:link-possible-types - fix to not default when on dirs or files (#397) * hui:link-possible-types - fix to not default when on dirs or files * Autosave global button file after any edits. --- ChangeLog | 9 +++++++++ HY-NEWS | 7 +++++-- hbut.el | 7 ++++++- hui.el | 30 ++++++++++++++++-------------- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8eccd33e3..d6dffb6269 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2023-10-22 Bob Weiner <r...@gnu.org> + +* hbut.el (gbut:save-buffer): Add function to use after global button file is + edited. +* hui.el (hui:gbut-delete, hui:gbut-rename, hui:gbut-link-directly): Save + global button file after create/edit. + (hui:link-possible-types): Fix missing `no-default' arg when testing + if on a directory or file name. + 2023-10-21 Bob Weiner <r...@gnu.org> * hibtypes.el (markdown-follow-inline-link-p): Fix to process anchored diff --git a/HY-NEWS b/HY-NEWS index 3d18ed39a7..5b32778999 100644 --- a/HY-NEWS +++ b/HY-NEWS @@ -85,15 +85,16 @@ ** EXPLICIT BUTTONS (See "(hyperbole)Explicit Buttons"). - *** Ebut/Link Menu Item - Inserts a named ebutton that links to point in + *** Ebut/Link Menu Item: Inserts a named ebutton that links to point in another window. See "(hyperbole)menu item, Ebut/Link". ** GLOBAL BUTTONS (See "(hyperbole)Global Buttons"). - *** Gbut/Link Menu Item - A single name creates a new global link button + *** Gbut/Link Menu Item: A single name creates a new global link button to point. See "(hyperbole)menu item, Gbut/Link". + *** Auto Save: Automatically save the global button file after any edit. ** HYCONTROL (See "(hyperbole)HyControl"). @@ -461,6 +462,8 @@ on such a string, use the 'default-directory' or 'buffer-file-name'. Previously just returned nil in such circumstances. + *** (gbut:save-buffer): Added to save global button file after edits. + ** ORG MODE INTEGRATION (See "(hyperbole)Smart Key - Org Mode"). diff --git a/hbut.el b/hbut.el index 21da7be4b7..68ede303c4 100644 --- a/hbut.el +++ b/hbut.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 18-Sep-91 at 02:57:09 -;; Last-Mod: 4-Oct-23 at 20:00:02 by Mats Lidell +;; Last-Mod: 22-Oct-23 at 08:42:11 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -807,6 +807,11 @@ to two lines." (when (equal buffer-file-name (gbut:file)) (hbut:label-p as-label start-delim end-delim pos-flag two-lines-flag))) +(defun gbut:save-buffer () + "Save global button file after an edit." + (with-current-buffer (find-file-noselect (gbut:file)) + (save-buffer))) + (defun gbut:to (lbl-key) "Find the global button with LBL-KEY (a label or label key). Find it within the visible portion of the global button file. diff --git a/hui.el b/hui.el index 92a5b59d7a..6219628ea5 100644 --- a/hui.el +++ b/hui.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 19-Sep-91 at 21:42:03 -;; Last-Mod: 4-Oct-23 at 20:07:50 by Mats Lidell +;; Last-Mod: 22-Oct-23 at 08:46:02 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -574,10 +574,10 @@ details." (defun hui:gbut-delete (but-key) "Delete global Hyperbole button given by BUT-KEY. - Return t if button is deleted, nil if user chooses not to delete or signal - an error otherwise. If called interactively, prompt user whether to delete - and derive BUT-KEY from the button that point is within. - Signal an error if point is not within a button." +Return t if button is deleted, nil if user chooses not to delete or signal +an error otherwise. If called interactively, prompt user whether to delete +and derive BUT-KEY from the button that point is within. +Signal an error if point is not within a button." (interactive (list (save-excursion (hui:buf-writable-err (find-file-noselect (gbut:file)) "gbut-delete") @@ -585,13 +585,14 @@ details." (hargs:read-match "Global button to delete: " (mapcar #'list (gbut:label-list)) nil t nil 'gbut))))) - (hui:hbut-delete but-key (gbut:file))) + (prog1 (hui:hbut-delete but-key (gbut:file)) + (gbut:save-buffer))) (defun hui:gbut-edit (lbl-key) "Edit a global Hyperbole button given by LBL-KEY. - The button may be explicit or a labeled implicit button. - When called interactively, save the global button buffer after the - modification Signal an error when no such button is found." +The button may be explicit or a labeled implicit button. +When called interactively, save the global button buffer after the +modification. Signal an error when no such button is found." (interactive (list (save-excursion (hui:buf-writable-err (find-file-noselect (gbut:file)) "gbut-edit") @@ -604,7 +605,6 @@ details." (error "(hui:gbut-edit): No global button to edit") (error "(hui:gbut-edit): 'lbl-key' argument must be a string, not '%s'" lbl-key))) - (hypb:assert-same-start-and-end-buffer (let ((lbl (hbut:key-to-label lbl-key)) (interactive-flag (called-interactively-p 'interactive)) @@ -707,12 +707,13 @@ implicit button. See also documentation for (when (called-interactively-p 'interactive) (hui:ibut-message edit-flag))) (setq edit-flag (hui:ebut-link-directly link-but-window referent-window)) + (gbut:save-buffer) (when (called-interactively-p 'interactive) (hui:ebut-message edit-flag))))))) (defun hui:gbut-rename (label) "Interactively rename a Hyperbole global button with LABEL. - When in the global button buffer, the default is the button at point." +When in the global button buffer, the default is the button at point." (interactive (list (save-excursion (hui:buf-writable-err (find-file-noselect (gbut:file)) "gbut-rename") @@ -720,7 +721,8 @@ implicit button. See also documentation for (hargs:read-match "Global button to rename: " (mapcar #'list (gbut:label-list)) nil t nil 'gbut))))) - (hbut:rename (gbut:to label))) + (prog1 (hbut:rename (gbut:to label)) + (gbut:save-buffer))) (defun hui:gibut-create (name text) "Create a Hyperbole global implicit button with NAME and button TEXT at point. @@ -1884,10 +1886,10 @@ Buffer without File link-to-buffer-tmp" (list (rmail:msg-id-get) buffer-file-name)))))) (t (cond ((let ((hargs:reading-type 'directory)) - (setq val (hargs:at-p))) + (setq val (hargs:at-p t))) (list 'link-to-directory val)) ((let ((hargs:reading-type 'file)) - (setq val (hargs:at-p))) + (setq val (hargs:at-p t))) (list 'link-to-file val (point))) ((derived-mode-p #'kotl-mode) (list 'link-to-kcell buffer-file-name (kcell-view:idstamp)))