[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole 0f2fa04 1/2: hargs.el - Eliminate use of dyna
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole 0f2fa04 1/2: hargs.el - Eliminate use of dynamic variable, hargs:defaults |
Date: |
Mon, 6 Dec 2021 01:57:25 -0500 (EST) |
branch: externals/hyperbole
commit 0f2fa04b654334bdadbc824c57da9ef67a83d999
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>
hargs.el - Eliminate use of dynamic variable, hargs:defaults
---
ChangeLog | 8 ++++++++
hargs.el | 30 +++++++++++----------------
hui.el | 4 ++--
kotl/kotl-mode.el | 61 +++++++++++++++++++++++++++----------------------------
4 files changed, 52 insertions(+), 51 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 95b4bff..0209c07 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2021-12-05 Bob Weiner <rsw@gnu.org>
+* hargs.el (hargs:actype-get): Change to set 'modifying' to t if non-nil
+ for lower-level function call conformance.
+ (hargs:iform-read): Change 'modifying' param to 'defaults'.
+ If it is t, then get current Hyperbole button is being modified,
+ get defaults from it, otherwise, use the value as the defaults
+ when prompting for arguments. Eliminate use of hargs:defaults
+ dynamic variable.
+
* kotl/kotl-mode.el: Require 'org so can override org-force-self-insert.
(kotl-mode-map): Add kotl-mode overrides for these orgtbl editing
commands: org-force-self-insert, orgtbl-ctrl-c-ctrl-c,
diff --git a/hargs.el b/hargs.el
index fe7e43b..3080eb3 100644
--- a/hargs.el
+++ b/hargs.el
@@ -79,7 +79,7 @@
(defun hargs:action-get (action modifying)
"Interactively get list of arguments for ACTION's parameters.
-Current button is being modified when MODIFYING is non-nil.
+Current button is being modified when MODIFYING is t.
Return nil if ACTION is not a list or `byte-code' object, has no
interactive form or takes no arguments."
(and (or (hypb:emacs-byte-code-p action) (listp action))
@@ -281,8 +281,10 @@ that point is within is returned or nil if none."
;;; ************************************************************************
(defun hargs:actype-get (actype &optional modifying)
- "Interactively gets and return list of arguments for ACTYPE's parameters.
+ "Interactively get and return list of arguments for ACTYPE's parameters.
Current button is being modified when MODIFYING is non-nil."
+ (when modifying
+ (setq modifying t))
(hargs:action-get (actype:action-body actype) modifying))
(defun hargs:at-p (&optional no-default)
@@ -479,11 +481,11 @@ Insert in minibuffer if active or in other window if
minibuffer is inactive."
(delete-window))
entry)))))
-(defun hargs:iform-read (iform &optional modifying)
+(defun hargs:iform-read (iform &optional defaults)
"Read action arguments according to IFORM, a list with car = 'interactive.
-Optional MODIFYING non-nil indicates current button is being modified, so
-button's current values should be presented as defaults. Otherwise, uses
-hargs:defaults as list of defaults, if any.
+With optional DEFAULTS equal to t, the current button is being modified, so
+its attribute values should be presented as defaults. Otherwise, use
+DEFAULTS as a list of defaults to present when reading arguments.
See also documentation for `interactive'."
;; This is mostly a translation of `call-interactively' to Lisp.
;;
@@ -496,21 +498,13 @@ See also documentation for `interactive'."
(let ((prev-reading-p hargs:reading-p))
(unwind-protect
(progn
+ (when (eq defaults t)
+ (setq defaults (hattr:get 'hbut:current 'args)))
(setq hargs:reading-p t)
(if (not (stringp iform))
- (let ((defaults (if modifying
- (hattr:get 'hbut:current 'args)
- (and (boundp 'hargs:defaults)
- (listp hargs:defaults)
- hargs:defaults))))
- (eval iform))
+ (eval iform)
(let ((i 0) (start 0) (end (length iform))
- (ientry) (results) (val) (default)
- (defaults (if modifying
- (hattr:get 'hbut:current 'args)
- (and (boundp 'hargs:defaults)
- (listp hargs:defaults)
- hargs:defaults))))
+ (ientry) (results) (val) (default))
;;
;; Handle special initial interactive string chars.
;;
diff --git a/hui.el b/hui.el
index 7eef1d9..44231de 100644
--- a/hui.el
+++ b/hui.el
@@ -225,7 +225,7 @@ Signal an error when no such button is found in the current
buffer."
(setq actype (hui:actype (hattr:get but 'actype)))
(hattr:set 'hbut:current 'actype actype)
- (hattr:set 'hbut:current 'args (hargs:actype-get actype 'modifying))
+ (hattr:set 'hbut:current 'args (hargs:actype-get actype t))
(hattr:set 'hbut:current 'action
(and hui:ebut-prompt-for-action (hui:action actype))))
(ebut:operate lbl new-lbl)
@@ -422,7 +422,7 @@ modification Signal an error when no such button is
found."
(hattr:set 'hbut:current 'dir src-dir)
(setq actype (hui:actype (hattr:get but 'actype)))
(hattr:set 'hbut:current 'actype actype)
- (hattr:set 'hbut:current 'args (hargs:actype-get actype 'modifying))
+ (hattr:set 'hbut:current 'args (hargs:actype-get actype t))
(hattr:set 'hbut:current 'action
(and hui:ebut-prompt-for-action (hui:action actype)))
(set-buffer but-buf)
diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el
index 721db72..43aca49 100644
--- a/kotl/kotl-mode.el
+++ b/kotl/kotl-mode.el
@@ -971,11 +971,11 @@ Goes backward if ARG is negative; error if CHAR not
found."
APPEND-TO-CELL is refilled if neither cell has a no-fill property and
kotl-mode:refill-flag is enabled."
(interactive
- (let* ((label (kcell-view:label))
- (hargs:defaults (list label label)))
+ (let* ((label (kcell-view:label)))
(hargs:iform-read
'(interactive
- "*+KAppend contents of cell: \n+KAppend contents of cell <%s> to cell:
"))))
+ "*+KAppend contents of cell: \n+KAppend contents of cell <%s> to cell:
")
+ (list label label))))
(save-excursion
(kotl-mode:goto-cell contents-cell)
(let ((contents (kcell-view:contents))
@@ -1004,14 +1004,14 @@ TO-CELL-REF, otherwise make it the sibling following
TO-CELL-REF.
Leave point at the start of the root cell of the new tree."
(interactive
- (let* ((label (kcell-view:label))
- (hargs:defaults (list label label)))
+ (let* ((label (kcell-view:label)))
(append
(hargs:iform-read
(list
'interactive
(format "*+KCopy tree: \n+KCopy tree <%%s> to follow as %s of cell: "
- (if current-prefix-arg "child" "sibling"))))
+ (if current-prefix-arg "child" "sibling")))
+ (list label label))
(list current-prefix-arg))))
;;
;; Copy tree in current view and leave point at the start of the copy.
@@ -1030,14 +1030,14 @@ TO-CELL-REF's parent, otherwise make it the preceding
sibling of TO-CELL-REF.
Leave point at the start of the root cell of the new tree."
(interactive
- (let* ((label (kcell-view:label))
- (hargs:defaults (list label label)))
+ (let* ((label (kcell-view:label)))
(append
(hargs:iform-read
(list 'interactive
(format "*+KCopy tree: \n+KCopy tree <%%s> to be %s of cell: "
(if current-prefix-arg "first child of parent"
- "preceding sibling"))))
+ "preceding sibling")))
+ (list label label))
(list current-prefix-arg))))
;;
;; Copy tree in current view and leave point at the start of the copy.
@@ -1089,14 +1089,14 @@ With optional COPY-P, copies tree rather than moving it.
Leave point at original location but return the tree's new start point."
(interactive
- (let* ((label (kcell-view:label))
- (hargs:defaults (list label label)))
+ (let* ((label (kcell-view:label)))
(append
(hargs:iform-read
(list
'interactive
(format "*+KMove tree: \n+KMove tree <%%s> to follow as %s of cell: "
- (if current-prefix-arg "child" "sibling"))))
+ (if current-prefix-arg "child" "sibling")))
+ (list label label))
(list current-prefix-arg))))
(if (and (not copy-p) (equal from-cell-ref to-cell-ref))
(error "(kotl-mode:move-after): Can't move tree after itself"))
@@ -1186,14 +1186,14 @@ With optional COPY-P, copies tree rather than moving it.
Leave point at original location but return the tree's new start point."
(interactive
- (let* ((label (kcell-view:label))
- (hargs:defaults (list label label)))
+ (let* ((label (kcell-view:label)))
(append
(hargs:iform-read
(list 'interactive
(format "*+KMove tree: \n+KMove tree <%%s> to be %s of cell: "
(if current-prefix-arg "first child of parent"
- "preceding sibling"))))
+ "preceding sibling")))
+ (list label label))
(list current-prefix-arg))))
(when (and (not copy-p) (equal from-cell-ref to-cell-ref))
(error "(kotl-mode:move-before): Can't move tree before itself"))
@@ -2301,18 +2301,17 @@ to one level and kotl-mode:refill-flag is treated as
true."
(defun kotl-mode:exchange-cells (cell-ref-1 cell-ref-2)
"Exchange CELL-REF-1 with CELL-REF-2 in current view. Don't move point."
(interactive
- (let ((hargs:defaults
- (save-excursion
- (list (kcell-view:label)
- (cond
- ((kcell-view:previous t)
- (kcell-view:label))
- ((kcell-view:next t)
- (kcell-view:label))
- (t (error
- "(kotl-mode:exchange-cells): No two visible cells
available")))))))
- (hargs:iform-read
- '(interactive "*+KExchange cell: \n+KExchange cell <%s> with cell: "))))
+ (hargs:iform-read
+ '(interactive "*+KExchange cell: \n+KExchange cell <%s> with cell: ")
+ (save-excursion
+ (list (kcell-view:label)
+ (cond
+ ((kcell-view:previous t)
+ (kcell-view:label))
+ ((kcell-view:next t)
+ (kcell-view:label))
+ (t (error
+ "(kotl-mode:exchange-cells): No two visible cells
available")))))))
(save-excursion
(let (kcell-1 contents-1
kcell-2 contents-2)
@@ -2783,8 +2782,7 @@ Optional prefix arg CELLS-FLAG selects the cells to print:
See also the documentation for `kotl-mode:cell-attributes'."
(interactive
- (let* ((label (kcell-view:label))
- (hargs:defaults (list label label)))
+ (let* ((label (kcell-view:label)))
(append
(let ((arg (prefix-numeric-value current-prefix-arg)))
(if (< arg 1)
@@ -2792,7 +2790,8 @@ See also the documentation for
`kotl-mode:cell-attributes'."
(hargs:iform-read
(list 'interactive
(format "+KDisplay properties of koutline %s: "
- (if (= arg 1) "cell" "tree"))))))
+ (if (= arg 1) "cell" "tree")))
+ (list label label))))
(list current-prefix-arg))))
(unless (integerp cells-flag)
(setq cells-flag (prefix-numeric-value cells-flag)))
@@ -3053,7 +3052,7 @@ this function to `pre-command-hook'."
(when (not (kview:valid-position-p))
(kotl-mode:to-valid-position))))
-(defun kotl-mode:print-attributes (kview)
+(defun kotl-mode:print-attributes (_kview)
"Print to the `standard-output' stream the attributes of the current visible
kcell.
Takes argument KVIEW (so it can be used with `kview:map-tree' and so that
KVIEW is bound correctly) but always operates upon the current view."