[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/hyperbole 0bf8fd8eee 03/16: Try and avoid using `hyperb:s
From: |
Stefan Monnier |
Subject: |
[elpa] scratch/hyperbole 0bf8fd8eee 03/16: Try and avoid using `hyperb:stack-frame` |
Date: |
Mon, 19 Jun 2023 22:36:44 -0400 (EDT) |
branch: scratch/hyperbole
commit 0bf8fd8eeea16012fcbee35a344203b4957f3c07
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Try and avoid using `hyperb:stack-frame`
Scanning the stack frame can be useful in some unusual cases, but
should be avoided when a straightforward let-binding does the trick.
* hmouse-drv.el (hkey--within-help): New var.
(hkey-help): Bind it.
* hibtypes.el (pathname): Consult it.
(hibtypes--within-org-link-outside-org-mode): New var.
(org-link-outside-org-mode): Use it to detect recursion.
* hui-mouse.el (hyp--within-smart-org): New var.
(smart-org): Bind it.
(hkey-alist): Consult it.
(-flatten): Move declaration to where we know the function is
actually available.
---
hibtypes.el | 25 ++++++++++++++-----------
hmouse-drv.el | 7 +++++--
hui-mouse.el | 25 ++++++++++++++++++-------
3 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/hibtypes.el b/hibtypes.el
index dbbe4a437f..ecb7dd5605 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -186,6 +186,7 @@ If the referenced location is found, return non-nil."
;;; ========================================================================
(defib pathname ()
+ ;; FIXME: GNU convention calls these *file* names.
"Make a valid pathname at point display the path entry.
If instead is a PATH-style variable name, .e.g. MANPATH, will prompt
@@ -255,7 +256,8 @@ display options."
(cond ((and (string-match hpath:path-variable-regexp path)
(setq path (match-string 1 path))
(hpath:is-path-variable-p path))
- (setq path (if (or assist-flag (hyperb:stack-frame
'(hkey-help)))
+ (setq path (if (or assist-flag
+ (bound-and-true-p hkey--within-help))
path
(hpath:choose-from-path-variable path "Display")))
(unless (or (null path) (string-blank-p path)
@@ -359,21 +361,22 @@ in all buffers."
;; Org links in Org mode are handled at the highest priority; see the last
;; section at the end of this file.
+(defvar hibtypes--within-org-link-outside-org-mode nil)
(defib org-link-outside-org-mode ()
"Follow an Org link in a non-Org mode buffer.
This should be a very low priority so other Hyperbole types
handle any links they recognize first."
- (with-no-warnings
- (when (and (eq hsys-org-enable-smart-keys t)
- (not (funcall hsys-org-mode-function))
- ;; Prevent infinite recursion if ever called via
org-metareturn-hook
- ;; from org-meta-return invocation.
- (not (hyperb:stack-frame '(ibtypes::debugger-source
org-meta-return))))
- (let ((start-end (hsys-org-link-at-p)))
- (when start-end
- (hsys-org-set-ibut-label start-end)
- (hact 'org-open-at-point-global))))))
+ (when (and (eq hsys-org-enable-smart-keys t)
+ (not (funcall hsys-org-mode-function))
+ ;; Prevent infinite recursion, e.g. if called via
+ ;; `org-metareturn-hook' from `org-meta-return' invocation.
+ (not hibtypes--within-org-link-outside-org-mode))
+ (let* ((hibtypes--within-org-link-outside-org-mode t)
+ (start-end (hsys-org-link-at-p)))
+ (when start-end
+ (hsys-org-set-ibut-label start-end)
+ (hact 'org-open-at-point-global)))))
;;; ========================================================================
;;; Handles internal references within an annotated bibliography, delimiters=[]
diff --git a/hmouse-drv.el b/hmouse-drv.el
index 52736b45e5..ee0a219eb8 100644
--- a/hmouse-drv.el
+++ b/hmouse-drv.el
@@ -110,7 +110,7 @@ Note that this may be a buffer different than where the
release occurs.")
(defvar assist-key-help-flag nil
"When non-nil, forces display of help for next Assist Key release.")
-(defvar assist-flag nil
+(defvar assist-flag nil ;FIXME: Don't eat up others's namespace!
"Non-nil when Hyperbole's Assist Key is in use rather than the Action Key.
Never set directly. Bound as a parameter when `hkey-execute' is called
and then used as a free variable.")
@@ -1014,13 +1014,16 @@ predicate is found."
(setq hkey-forms (cdr hkey-forms))))
pred-value))
+(defvar hkey--within-help nil)
+
(defun hkey-help (&optional assisting)
"Display help for the Action Key command in current context.
With optional ASSISTING prefix arg non-nil, display help for the
Assist Key command. Return non-nil iff associated help
documentation is found."
(interactive "P")
- (let* ((mouse-flag (when (mouse-event-p last-command-event)
+ (let* ((hkey--within-help t)
+ (mouse-flag (when (mouse-event-p last-command-event)
(or action-key-depress-position
assist-key-depress-position)))
(mouse-drag-flag (hmouse-drag-p))
(hkey-forms (if mouse-flag hmouse-alist hkey-alist))
diff --git a/hui-mouse.el b/hui-mouse.el
index 29e3a1d6b8..b01c8a576b 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -128,6 +128,9 @@ Its default value is `smart-scroll-down'. To disable it,
set it to
;;; Public declarations
;;; ************************************************************************
+;; FIXME: What makes us think these functions will be available when we
+;; call them?
+
(declare-function todotxt-archive "ext:todotxt")
(declare-function todotxt-bury "ext:todotxt")
(declare-function todotxt-complete-toggle "ext:todotxt")
@@ -144,8 +147,6 @@ Its default value is `smart-scroll-down'. To disable it,
set it to
(defvar magit-root-section)
(defvar magit-display-buffer-function)
-(declare-function -flatten "ext:dash")
-
(declare-function imenu--make-index-alist "imenu")
(declare-function image-dired-thumbnail-display-external "image-dired")
@@ -161,7 +162,7 @@ Its default value is `smart-scroll-down'. To disable it,
set it to
(declare-function helm-pos-header-line-p "ext:helm")
(declare-function helm-resume "ext:helm")
(declare-function helm-window "ext:helm-lib")
-(declare-function with-helm-buffer "ext:helm-lib")
+;;(declare-function with-helm-buffer "ext:helm-lib")
(defvar helm-action-buffer)
(defvar helm-alive-p)
(defvar helm-buffer)
@@ -187,6 +188,12 @@ Its default value is `smart-scroll-down'. To disable it,
set it to
(declare-function unix-apropos-get-man "ext:man-apropos")
+;;; ************************************************************************
+;;; Private variables
+;;; ************************************************************************
+
+(defvar hyp--within-smart-org nil)
+
;;; ************************************************************************
;;; Hyperbole context-sensitive keys dispatch table
;;; ************************************************************************
@@ -203,7 +210,7 @@ Its default value is `smart-scroll-down'. To disable it,
set it to
;;
;; Handle any Org mode-specific contexts but give priority to Hyperbole
;; buttons prior to cycling Org headlines
- ((and (not (hyperb:stack-frame '(smart-org)))
+ ((and (not hyp--within-smart-org)
(let ((hrule:action #'actype:identity))
(smart-org)))
. ((smart-org) . (smart-org)))
@@ -1433,7 +1440,10 @@ NO-RECURSE-FLAG non-nil prevents infinite recursions."
;; Does nothing unless the dash Emacs Lisp
;; library is available for the -flatten
function.
(and (require 'dash nil t)
- (assoc index-key (-flatten alist)))))))
+ ;; FIXME: Use Emacs-27's `flatten-tree'?
+ (progn
+ (declare-function -flatten "ext:dash")
+ (assoc index-key (-flatten alist))))))))
(when index-item
(setq index-position (when (markerp (cdr index-item))
(marker-position (cdr index-item))))
@@ -1749,8 +1759,9 @@ will invoke `org-meta-return'.
Org links may be used outside of Org mode buffers. Such links are
handled by the separate implicit button type, `org-link-outside-org-mode'."
- (when (funcall hsys-org-mode-function)
- (let (start-end)
+ (let ((hyp--within-smart-org t)
+ start-end)
+ (when (funcall hsys-org-mode-function)
(cond ((not hsys-org-enable-smart-keys)
(when (hsys-org-meta-return-shared-p)
(hact 'hsys-org-meta-return))
- [elpa] branch scratch/hyperbole created (now a269d1536e), Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 5206d3b3d4 01/16: * hload-path.el (hyperb:dir): Use `macroexp-file-name`, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 0bf8fd8eee 03/16: Try and avoid using `hyperb:stack-frame`,
Stefan Monnier <=
- [elpa] scratch/hyperbole b5780234d9 02/16: * hversion.el (hyperb:path-being-loaded): Delete function, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 60cf4b3ab0 07/16: * hact.el: Fix broken lexical-binding cookie, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 57d02f8456 09/16: hyperbole-autoloads.el: Remove needless definitions, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 5aa8d7a577 10/16: * hycontrol.el (hycontrol-windows-mode-map): Don't autoload, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole fd3f79a9ee 15/16: * hargs.el (hargs:set-string-to-complete): Don't mess with windows, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole ab0338d714 05/16: Fix compilation of test file, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 63e463172e 06/16: (kview:char-visible-p): Delete function, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole fbcfcc04a3 08/16: * hyperbole.el: Preload `kotl-autoloads`, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole fc7e33b5e5 11/16: * hui-select.el: Fix a few warnings and improve some docstrings, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 12fa8e328d 12/16: (man-show): Fix miscompilation, Stefan Monnier, 2023/06/19