emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole a69d994d5a 31/47: ibut:operate - Add 2nd edit


From: ELPA Syncer
Subject: [elpa] externals/hyperbole a69d994d5a 31/47: ibut:operate - Add 2nd edit-flag parameter; non-nil means modifying
Date: Sun, 25 Jun 2023 15:58:37 -0400 (EDT)

branch: externals/hyperbole
commit a69d994d5aa0947cd9b8c67c573bfc08fb63d4e8
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>

    ibut:operate - Add 2nd edit-flag parameter; non-nil means modifying
    
    hactypes.el (rfc-toc): Fix wrong 'select-buffer' call by replacing with
    'switch-to-buffer' for permanent return to original buffer.
---
 ChangeLog   | 15 +++++++++++++++
 hactypes.el |  4 ++--
 hbut.el     | 20 ++++++++++----------
 hui.el      | 41 +++++++++++++++++++++--------------------
 4 files changed, 48 insertions(+), 32 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2b88492c52..cdef553643 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2023-06-25  Bob Weiner  <rsw@gnu.org>
+
+* hactypes.el (rfc-toc): Fix wrong 'select-buffer' call by replacing with
+    'switch-to-buffer' for permanent return to original buffer.
+
+2023-06-24  Bob Weiner  <rsw@gnu.org>
+
+* hui.el (hui:ibut-link-create): Fix name attribute not getting set when 
creating a
+    new ibutton.  Rename 'but-edit' to 'edit-flag' and always send name arg to
+    'ibut:operate' call so that button name attribute is always set when given.
+         (hui:ebut-link-directly, hui:ibut-link-directly): Change 'but-edit' to
+    'edit-flag'.
+  hbut.el (ibut:operate): Add 2nd edit-flag parameter; when non-nil, means 
modifying
+    an existing ibut at point.
+
 2023-06-22  Bob Weiner  <rsw@gnu.org>
 
 * man/hyperbole.texi (By Menu): Add section similar to that of Ibuts, 
documenting
diff --git a/hactypes.el b/hactypes.el
index 05f3d1e9c0..112d903731 100644
--- a/hactypes.el
+++ b/hactypes.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    23-Sep-91 at 20:34:36
-;; Last-Mod:     19-Jun-23 at 15:24:25 by Bob Weiner
+;; Last-Mod:     25-Jun-23 at 09:38:34 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -716,7 +716,7 @@ Optional SECTIONS-START limits toc entries to those after 
that point."
       (insert "Sections of " rfc-buf-name ":\n")
       (set-buffer-modified-p nil))
     (when opoint
-      (select-buffer buf-name)
+      (switch-to-buffer buf-name)
       (goto-char opoint))))
 
 (defact text-toc (section)
diff --git a/hbut.el b/hbut.el
index 9d4b50217c..9aa5f0c9ef 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:     21-Jun-23 at 21:42:00 by Bob Weiner
+;; Last-Mod:     24-Jun-23 at 13:09:26 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -2163,13 +2163,14 @@ move to the first occurrence of the button."
            (re-search-forward (ibut:label-regexp lbl-key t) nil t))
     (goto-char (+ (match-beginning 0) (length ibut:label-start)))))
 
-(defun    ibut:operate (&optional new-name)
+(defun    ibut:operate (&optional new-name edit-flag)
   "Insert/modify an ibutton based on `hbut:current' in current buffer.
-If optional NEW-NAME is non-nil, modify an existing ibutton with 'name'
-attribute in `hbut:current'.
+Optional non-nil NEW-NAME is name to give button.  With optional
+EDIT-FLAG non-nil, modify an existing in-buffer ibutton rather
+than creating a new one.
 
-If NAME is nil, use the active region text as the button name, if any;
-if no such region, then create an unnamed implicit button.
+If NEW-NAME is nil, use the active region text as the button name, if any;
+if no such region, then create/modify an unnamed implicit button.
 
 Return instance string appended to name to form a per-buffer unique
 name; nil if name is already unique or no name.  Signal an error when no
@@ -2192,7 +2193,6 @@ Summary of operations based on inputs:
   (let* ((actype (hattr:get 'hbut:current 'actype))
         (name (hattr:get 'hbut:current 'name))
         (name-regexp (ibut:label-regexp (ibut:label-to-key name)))
-        (modify new-name)
         (region-flag (hmouse-use-region-p))
         (instance-flag))
     (unless actype
@@ -2208,7 +2208,7 @@ Summary of operations based on inputs:
       (hattr:set 'hbut:current 'name new-name))
     (save-excursion
       (if (progn
-           (if modify
+           (if edit-flag
                (progn
                  (setq instance-flag
                        (hbdata:ibut-instance-last (ibut:label-to-key 
new-name)))
@@ -2222,10 +2222,10 @@ Summary of operations based on inputs:
          (when (hmail:editor-p)
            (hmail:msg-narrow))
        (hypb:error "(ibut:operate): Failed to %s button %s%s%s in buffer %s"
-                   (if modify "modify" "create")
+                   (if edit-flag "modify" "create")
                    ibut:label-start name ibut:label-end
                    (buffer-name))))
-    (cond (modify
+    (cond (edit-flag
           (if name
               ;; Rename all occurrences of button - those with same name
               (let* ((but-key-and-pos (ibut:label-p nil nil nil 'pos))
diff --git a/hui.el b/hui.el
index de47de608a..91a8e42bb1 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:     21-Jun-23 at 00:12:35 by Bob Weiner
+;; Last-Mod:     25-Jun-23 at 09:41:45 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1066,7 +1066,7 @@ from those instead.  See also documentation for
                 (assist-key-clear-variables)
                 (hmouse-choose-link-and-referent-windows)))
 
-  (let (but-name but-edit link-types num-types type-and-args lbl-key but-loc 
but-dir)
+  (let (but-name edit-flag link-types num-types type-and-args lbl-key but-loc 
but-dir)
     (multiple-value-bind (link-but-window referent-window)
        (if (and depress-window release-window)
            (list depress-window release-window)
@@ -1082,7 +1082,7 @@ from those instead.  See also documentation for
        (switch-to-buffer action-key-depress-buffer))
       (hui:buf-writable-err (current-buffer) "link-directly")
       (if (ebut:at-p)
-         (setq but-edit t
+         (setq edit-flag t
                but-loc (hattr:get 'hbut:current 'loc)
                but-dir (hattr:get 'hbut:current 'dir)
                lbl-key (hattr:get 'hbut:current 'lbl-key))
@@ -1106,7 +1106,7 @@ from those instead.  See also documentation for
             (error "(link-directly): No possible link type to create"))
            ((= num-types 1)
             (setq type-and-args (hui:list-remove-text-properties (car 
link-types)))
-            (hui:ebut-link-create but-edit link-but-window lbl-key but-loc 
but-dir type-and-args))
+            (hui:ebut-link-create edit-flag link-but-window lbl-key but-loc 
but-dir type-and-args))
            (t ;; more than 1
             (let ((item)
                   type)
@@ -1129,12 +1129,12 @@ from those instead.  See also documentation for
                             link-types)))
                     type-and-args (hui:list-remove-text-properties 
type-and-args))
               (hui:ebut-link-create
-               but-edit link-but-window
+               edit-flag link-but-window
                lbl-key but-loc but-dir type-and-args))))
       (with-selected-window referent-window
        (hmouse-pulse-line))
       (when (called-interactively-p 'interactive)
-       (hui:ebut-message but-edit)))))
+       (hui:ebut-message edit-flag)))))
 
 (defun hui:ibut-link-directly (&optional depress-window release-window 
name-arg-flag)
   "Create a link ibutton at Assist Key depress point, linked to release point.
@@ -1159,7 +1159,8 @@ drag from a window to another window's modeline."
                 (append (hmouse-choose-link-and-referent-windows)
                         current-prefix-arg)))
 
-  (let (but-name but-edit link-types num-types type-and-args name-key but-loc 
but-dir)
+  (let (but-name edit-flag link-types num-types type-and-args name-key but-loc 
but-dir)
+    ;; edit-flag when set non-nil means are editing an existing ibut at point
     (multiple-value-bind (link-but-window referent-window)
        (if (and depress-window release-window)
            (list depress-window release-window)
@@ -1175,7 +1176,7 @@ drag from a window to another window's modeline."
        (switch-to-buffer assist-key-depress-buffer))
       (hui:buf-writable-err (current-buffer) "link-directly")
       (if (ibut:at-p)
-         (setq but-edit t
+         (setq edit-flag t
                but-loc (hattr:get 'hbut:current 'loc)
                but-dir (hattr:get 'hbut:current 'dir)
                name-key (ibut:label-to-key (hattr:get 'hbut:current 'name)))
@@ -1204,7 +1205,7 @@ drag from a window to another window's modeline."
             (error "(link-directly): No possible link type to create"))
            ((= num-types 1)
             (setq type-and-args (hui:list-remove-text-properties (car 
link-types)))
-            (hui:ibut-link-create but-edit link-but-window name-key but-loc 
but-dir type-and-args))
+            (hui:ibut-link-create edit-flag link-but-window name-key but-loc 
but-dir type-and-args))
            (t ;; more than 1
             (let ((item)
                   type)
@@ -1227,12 +1228,11 @@ drag from a window to another window's modeline."
                             link-types)))
                     type-and-args (hui:list-remove-text-properties 
type-and-args))
               (hui:ibut-link-create
-               but-edit link-but-window
-               name-key but-loc but-dir type-and-args))))
+               edit-flag link-but-window name-key but-loc but-dir 
type-and-args))))
       (with-selected-window referent-window
        (hmouse-pulse-line))
       (when (called-interactively-p 'interactive)
-       (hui:ibut-message but-edit)))))
+       (hui:ibut-message edit-flag)))))
 
 
 ;;; ************************************************************************
@@ -1644,13 +1644,15 @@ arguments."
 
 (defun hui:ibut-link-create (edit-flag but-window name-key but-loc but-dir 
type-and-args)
   "Create or edit a new Hyperbole implicit link button.
-If EDIT-FLAG is non-nil, edit button at point in BUT-WINDOW,
-otherwise, prompt for button name and create a button.
-NAME-KEY is internal form of button name.  BUT-LOC is the file or buffer
-in which to create button.  BUT-DIR is the directory of BUT-LOC.
+With EDIT-FLAG non-nil, edit an existing ibutton at point in
+BUT-WINDOW; otherwise, create a new one.
+
+NAME-KEY is the internal form of the button name; when nil,
+prompt for new button name.  BUT-LOC is the file or buffer in
+which to create button.  BUT-DIR is the directory of BUT-LOC.
 TYPE-AND-ARGS is the action type for the button followed by any
-arguments it requires.  Any text properties are removed from string
-arguments."
+arguments it requires.  Any text properties are removed from
+string arguments."
   (hattr:set 'hbut:current 'categ 'implicit)
   (hattr:set 'hbut:current 'loc but-loc)
   (hattr:set 'hbut:current 'dir but-dir)
@@ -1662,8 +1664,7 @@ arguments."
   (unless (and but-loc (or (equal (buffer-name) but-loc)
                           (eq (current-buffer) but-loc)))
     (hbut:key-src-set-buffer but-loc))
-  (let ((name (hbut:key-to-label name-key)))
-    (ibut:operate (when edit-flag name))))
+  (ibut:operate (ibut:key-to-label name-key) edit-flag))
 
 (defun hui:link-possible-types ()
   "Return list of possible link action types during editing of a Hyperbole 
button.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]