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

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

[elpa] externals/hyperbole 07c0664 21/51: Org-mode local binding of M-RE


From: Stefan Monnier
Subject: [elpa] externals/hyperbole 07c0664 21/51: Org-mode local binding of M-RET activates Hyperbole implicit buttons
Date: Sun, 12 Jul 2020 18:10:12 -0400 (EDT)

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

    Org-mode local binding of M-RET activates Hyperbole implicit buttons
---
 Changes       | 11 ++++++++---
 HY-NEWS       | 45 ++++++++++++++++++++++++++++-----------------
 hact.el       |  4 ++--
 hbut.el       |  9 +++++----
 hibtypes.el   |  2 +-
 hload-path.el |  3 ++-
 hsys-org.el   | 28 ++++++++++++++++++++++------
 7 files changed, 68 insertions(+), 34 deletions(-)

diff --git a/Changes b/Changes
index 99aba85..e9f06ed 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,13 @@
+2020-02-12  Bob Weiner  <rsw@gnu.org>
+
+* hsys-org.el (hsys-org-hbut-activate-p): Defined and added to 
org-metareturn-hook so local binding
+    of M-RET in org-mode activates Hyperbole buttons (doesn't run full set of 
Action Key actions).
+    (org-link): Updated to utilize newer org-link-open-from-string function 
when available.
+    (hsys-org-link-at-p): Updated to utilize newer org-link-any-re variable 
when available.
+
 2020-02-09  Bob Weiner  <rsw@gnu.org>
 
-* DEMO (Windows Grid): Use {Q} to ensure quit from HyControl and not from the 
DEMO (which is in Help mode).
+* DEMO (Windows Grid): Used {Q} to ensure quit from HyControl and not from the 
DEMO (which is in Help mode).
 
 * hypb.el (hypb:mark-object, hypb:object-p): Added these to give strings and 
symbols a hyperbole property.
   hpath.el (hpath:relative-to, hpath:absolute-to): Ignore any string with a 
hyperbole property.
@@ -341,8 +348,6 @@ V7.0.7 test release changes ^^^^:
     ibtypes::<implicit-button-type> jump to the associated defact and
     defib definitions.
 
-    actypes::link-to-file
-
 * hmouse-tag.el (smart-lisp-at-definition-p): Don't match to 'def' alone.
 
 2019-09-10  Bob Weiner  <rsw@gnu.org>
diff --git a/HY-NEWS b/HY-NEWS
index e3de692..1825c3e 100644
--- a/HY-NEWS
+++ b/HY-NEWS
@@ -10,13 +10,14 @@
     - After installing the ace-window package and loading Hyperbole, execute
       (hkey-ace-window-setup "\M-o") to enable the following capabilities:
 
-    - The hkey-throw command bound to {M-o t} now throws the active 
(highlighted)
-      region, if any, into the target window's buffer, rather than replacing 
its
-      buffer with the source window buffer.  If you don't use region 
highlighting,
-      i.e. transient-mark-mode, then use {C-u M-o t} for the same effect.  The
-      buffer in the target window must differ from the one in the source 
window.
-      With no region active, this command stillthrows the source buffer to the
-      target window.
+    - Region Throws: The hkey-throw command bound to {M-o t} now throws the
+      active (highlighted) region, if any, into the target window's buffer,
+      rather than replacing its buffer with the source window buffer.  If
+      you don't use region highlighting, i.e. transient-mark-mode, then use
+      {C-u M-o t} for the same effect.  The buffer in the target window
+      must differ from the one in the source window.  With no region
+      active, this command stillthrows the source buffer to the target
+      window.
 
   DEMO
 
@@ -24,24 +25,34 @@
 
   GLOSSARY
 
-    - Added Action Button, Elink, Ilink, Glink definitions.
+    - Hlink Definitions: Added Action Button, Elink, Ilink, Glink definitions.
 
   HYROLO
 
-    - Fixed new entry addition to add in sorted order and logic operators to
-      perform properly, after a bug in level calculation had been introduced.
+    - Hyrolo Add: Fixed new entry addition to add in sorted order and logic
+      operators to perform properly, after a bug in level calculation had been
+      introduced.
 
   IMPLICIT BUTTONS
 
-    - Key series delimited by {} may not also be in double quotes, e.g. "{C-x 
o}".
+    - Double Quoting Key Series: Key series delimited by {} may now be in 
double
+      quotes, e.g. "{C-x o}".
+
+  ORG MODE
+
+    - Implicit Button Support: Org-mode's local binding of {M-RET} by default
+      now activates Hyperbole implicit buttons when within them.
+In org-mode buffers when not on a Hyperbole
+      button, org link or heading, and the {M-RET} Action Key is pressed,
+      Hyperbole defers to Org's org-meta-return command.
 
   PROGRAMMING
 
-    - If using Emacs imenu package, the Action Key will look up in-buffer
-      identifier references with imenu.  If imenu's index is rendered invalid
-      due to large changes in a buffer, Hyperbole will now automatically 
rebuild
-      the index to have correct pointers.  (Does not require use of the
-      imenu-auto-rescan setting.
+    - Auto Imenu Reindexing: If using Emacs imenu package, the Action Key
+      will look up in-buffer identifier references with imenu.  If imenu's
+      index is rendered invalid due to large changes in a buffer, Hyperbole
+      will now automatically rebuild the index to have correct pointers.
+      (Does not require use of the imenu-auto-rescan setting.
 
 ===========================================================================
 *                                   V7.0.8
@@ -265,7 +276,7 @@
 
     - Org Mode: When in an *Org Help* buffer, the Smart Keys now defer to
       org-mode to handle jumps to its own locations for compatibility.
-      Similarly, in org-mode buffers when not on an org link or heading,
+      Similarly, in org-mode buffers when not on an Org link or heading,
       and the {M-RET} Action Key is pressed, Hyperbole defers to Org's
       org-meta-return command.
 
diff --git a/hact.el b/hact.el
index e1abfd7..dff926d 100644
--- a/hact.el
+++ b/hact.el
@@ -394,10 +394,10 @@ Other paths are simply expanded.  Non-path arguments are 
returned unchanged."
 
 (defmacro hact (&rest args)
   "Perform action formed from rest of ARGS and return the result.
+The value of `hrule:action' determines what effect this has.
 Alternatively act as a no-op when testing implicit button type contexts.
 First arg may be a symbol or symbol name for either an action type or a
-function.  Runs `action-act-hook' before performing action.
-The value of `hrule:action' determines what effect this has."
+function.  Runs `action-act-hook' before performing action."
   (eval `(cons 'funcall (cons 'hrule:action ',args))))
 
 (defun    actype:act (actype &rest args)
diff --git a/hbut.el b/hbut.el
index 0a01a9f..0a6f208 100644
--- a/hbut.el
+++ b/hbut.el
@@ -737,9 +737,10 @@ others who use a different value!")
 
 (defun    hbut:act (hbut)
   "Perform action for explicit or implicit Hyperbole button symbol HBUT."
-  (if hbut (apply hrule:action
-                 (hattr:get hbut 'actype)
-                 (hattr:get hbut 'args))))
+  (when hbut
+    (apply hrule:action
+          (hattr:get hbut 'actype)
+          (hattr:get hbut 'args))))
 
 (defun    hbut:action (hbut)
   "Return appropriate action for Hyperbole button symbol HBUT."
@@ -751,7 +752,7 @@ others who use a different value!")
                   atype
                 (or action (actype:action atype))))
       ;; Must be an implicit button.
-      (if (fboundp atype) atype))))
+      (when (fboundp atype) atype))))
 
 (defun    hbut:at-p ()
   "Return symbol for explicit or implicit Hyperbole button at point or nil."
diff --git a/hibtypes.el b/hibtypes.el
index bb9790a..b5fac86 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -1261,7 +1261,7 @@ arg1 ... argN '>'.  For example, <mail nil 
\"user@somewhere.org\">."
                             actype 'display-variable)))
            ;; Necessary so can return a null value, which actype:act cannot.
            (let ((hrule:action
-               (if (eq hrule:action #'actype:identity)
+                          (if (eq hrule:action #'actype:identity)
                    #'actype:identity
                  #'actype:eval)))
           (if (eq hrule:action #'actype:identity)
diff --git a/hload-path.el b/hload-path.el
index 6e7ab26..5e85b62 100644
--- a/hload-path.el
+++ b/hload-path.el
@@ -29,7 +29,8 @@ It must end with a directory separator character.")
 ;; Ensure final name (after resolving all links) of hyperb:dir is
 ;; used; otherwise, Hyperbole may fail to substitute this as a
 ;; variable into link path buttons.
-(if (stringp hyperb:dir) (setq hyperb:dir (file-truename hyperb:dir)))
+(when (stringp hyperb:dir)
+  (setq hyperb:dir (file-truename hyperb:dir)))
 
 ;; Add hyperb:dir to load-path so other Hyperbole libraries can be
 ;; found unless it is already there since the Emacs Package Manager
diff --git a/hsys-org.el b/hsys-org.el
index f5be91b..9ddbb9e 100644
--- a/hsys-org.el
+++ b/hsys-org.el
@@ -32,13 +32,15 @@
 (defvar hsys-org-mode-function #'hsys-org-mode-p
   "*Boolean function of no arguments that determines whether hsys-org actions 
are triggered or not.")
 
+;; Make Org-mode's M-RET binding activate implicit buttons
+(add-hook 'org-metareturn-hook #'hsys-org-hbut-activate-p)
+
 (defun hsys-org-mode-p ()
-  "Return non-nil if an Org-related major or minor mode is active in the 
current buffer."
+  "Return non-nil if point is not on a Hyperbole button but is within an Org 
major or minor-mode buffer."
   (or (derived-mode-p 'org-mode)
       (and (boundp 'outshine-mode) outshine-mode)
       (and (boundp 'poporg-mode) poporg-mode)))
 
-
 (defun hsys-org-cycle ()
   "Call `org-cycle' and force it to be set as `this-command' to cycle through 
all states."
   (setq last-command 'org-cycle
@@ -51,6 +53,12 @@
        this-command 'org-cycle)
   (org-global-cycle nil))
 
+(defun hsys-org-hbut-activate-p ()
+  "Activate any Hyperbole button at point and return t, else return nil."
+  (when (and (funcall hsys-org-mode-function) (hbut:at-p))
+    (hbut:act 'hbut:current)
+    t))
+
 ;;; ************************************************************************
 ;;; Public Button Types
 ;;; ************************************************************************
@@ -72,11 +80,14 @@ cycles the view of the subtree at point.
 
 Fifth, with point on the first line of a code block definition, this
 executes the code block via the Org mode standard binding of {C-c C-c},
-(org-ctrl-c-ctrl-c).
+\(org-ctrl-c-ctrl-c).
 
 In any other context besides the end of a line, the Action Key invokes the
 Org mode standard binding of {M-RET}, (org-meta-return)."
-  (when (funcall hsys-org-mode-function)
+  (when (and (funcall hsys-org-mode-function)
+            ;; Prevent infinite recursion when called via org-metareturn-hook
+            ;; from org-meta-return invocation.
+            (not (hyperb:stack-frame '(org-meta-return))))
     (let (start-end)
       (cond ((setq start-end (hsys-org-internal-link-target-at-p))
             (hsys-org-set-ibut-label start-end)
@@ -108,7 +119,10 @@ If on an Org mode link, displays standard Hyperbole help."
   "Follows an optional Org mode LINK to its target.
 If LINK is nil, follows any link at point.  Otherwise, triggers an error."
   (if (stringp link)
-      (org-open-link-from-string link) ;; autoloaded
+      (cond ((fboundp #'org-link-open-from-string)
+            (org-link-open-from-string link))
+            ((fboundp #'org-open-link-from-string)
+            (org-open-link-from-string link))) ;; autoloaded
     (org-open-at-point))) ;; autoloaded
 
 (defact org-internal-link-target (&optional link-target)
@@ -169,7 +183,9 @@ uses that one.  Otherwise, triggers an error."
 (defun hsys-org-link-at-p ()
   "Return non-nil iff point is on an Org mode link.
 Assumes caller has already checked that the current buffer is in `org-mode'."
-  (or (org-in-regexp org-any-link-re)
+  (or (if (boundp 'org-link-any-re)
+         (org-in-regexp org-link-any-re)
+       (org-in-regexp org-any-link-re))
       (hsys-org-face-at-p 'org-link)))
 
 ;; Assumes caller has already checked that the current buffer is in org-mode.



reply via email to

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