[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole 531cf87 02/50: Handle Org links in non-Org mo
From: |
Stefan Monnier |
Subject: |
[elpa] externals/hyperbole 531cf87 02/50: Handle Org links in non-Org mode buffers with a low priority ibtype |
Date: |
Wed, 17 Mar 2021 18:44:12 -0400 (EDT) |
branch: externals/hyperbole
commit 531cf877fac91bfffa656fd6e47963029aa6cd3e
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>
Handle Org links in non-Org mode buffers with a low priority ibtype
---
Changes | 24 +++++++++++
DEMO | 2 +-
HY-TALK/HYPB | 19 +++++++-
MANIFEST | 3 +-
Makefile | 4 +-
hib-kbd.el | 2 +-
hib-org.el | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
hibtypes.el | 47 +++++++++++++-------
hsys-org.el | 123 ++--------------------------------------------------
9 files changed, 221 insertions(+), 142 deletions(-)
diff --git a/Changes b/Changes
index 1e2b9b7..f97cd67 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,27 @@
+2020-10-04 Bob Weiner <rsw@gnu.org>
+
+* kotl/kexport.el (kexport:html-replacement-alist): Correct \\0 with \0 so html
+ export works properly.
+
+* hibtypes.el (hsys-www): Move to lower priority than pathname implicit buttons
+ so they can handle file:// links, especially with :line-number suffixes.
+ Fixes bug#43794.
+
+* hsys-org.el (hsys-org-mode-p): Added org-agenda-mode check.
+ hib-org.el (org-mode): Changed to apply inhibit-hsys-org to org-agenda-mode
as well.
+
+* hibtypes.el (hib-debbugs): Raise priority above social and markdown links.
+ (org-link-outside-org-mode): Added to lower priority below
+ other Hyperbole link types and removed from hsys-org.el.
+
+* hib-org.el: Moved Org mode implicit button and action types to this new
+ file to allow for separate handling of Org links outside of Org mode.
+ Makefile (EL_COMPILE, ELC_COMPILE): Added hib-org.el{c}.
+
+==============================================================================
+V7.1.4 changes ^^^^:
+==============================================================================
+
2020-09-21 Bob Weiner <rsw@gnu.org>
* hversion.el: Released 7.1.3.
diff --git a/DEMO b/DEMO
index 60e9c6c..4b8823c 100644
--- a/DEMO
+++ b/DEMO
@@ -683,7 +683,7 @@ Once you have Tramp configured for loading and are on the
Internet, you can
press on any of the following to jump to the ftp site of Hyperbole tarball
distributions:
- /ftp:anonymous@ftp.gnu.org:/pub/gnu/hyperbole/
+ /ftp:anonymous@ftp.gnu.org:/pub/gnu/hyperbole/
For Tramp pathnames, Hyperbole recognizes them with or without double quote
delimiters.
diff --git a/HY-TALK/HYPB b/HY-TALK/HYPB
index bf93c76..1a4866c 100644
--- a/HY-TALK/HYPB
+++ b/HY-TALK/HYPB
@@ -1,3 +1,13 @@
+* How to setup button2 and button3 as Action and Assist Mouse Keys
+
+Add to your Emacs init file:
+
+ (eval-after-load "hyperbole" '(hmouse-add-unshifted-smart-keys))
+
+or interactively after loading Hyperbole:
+
+ <hmouse-add-unshifted-smart-keys>
+
* Keystroke Display
** Keypression - overlaying parts of buffer (shows trail of keys)
@@ -16,12 +26,15 @@
* Pathname Prefixes
- "!${PATH)/date" - execute 'date' shell command
+ "!${PATH}/date" - execute 'date' shell command
"&Preview.app ${hyperb:dir}/man/hyperbole.pdf"
"-subr.elc" - load an Elisp library
+* Programming Buttons
+
+Emacs Yank Bug: bug#5320
* Global Buttons
@@ -41,4 +54,6 @@
"${hyperb:dir}/README.md#Programmer Quick Reference"
"${hyperb:dir}/README.md#programmer-quick-reference:4:2"
-<hpath:find "${hyperb:dir}">
\ No newline at end of file
+<hpath:find "${hyperb:dir}">
+
+<[PDF Viewer]> == "${hyperb:dir}/man/hyperbole.pdf"
\ No newline at end of file
diff --git a/MANIFEST b/MANIFEST
index cbc450a..d64d576 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -82,6 +82,7 @@ hibtypes.el - GNU Hyperbole default implicit button
types
hib-debbugs.el - Implicit button type for browsing GNU debbugs issues
hib-doc-id.el - Implicit button type for document id index entries
hib-kbd.el - Implicit button type for key sequences delimited with {}
+hib-org.el - Implicit button type for Org mode
hib-social.el - Implicit button type for social media/git hashtag and
username references
hinit.el - Standard initializations for GNU Hyperbole
hload-path.el - GNU Hyperbole load-path setup
@@ -93,6 +94,6 @@ topwin.py - Python script to find the topmost
macOS app window at a s
.hypb & _hypb - Button data files used by the Hyperbole DEMO file
--- EXTERNAL SYSTEM ENCAPSULATIONS ---
-hsys-org.el - GNU Hyperbole support for Emacs Org mode links
+hsys-org.el - GNU Hyperbole support functions for Support for
hib-org.el
hsys-www.el - GNU Hyperbole support for Emacs W3 World-Wide Web (WWW)
browsing
diff --git a/Makefile b/Makefile
index 8be3052..5d5d102 100644
--- a/Makefile
+++ b/Makefile
@@ -153,7 +153,7 @@ EL_SRC = hui-em-but.el
EL_COMPILE = hact.el hactypes.el hargs.el hbdata.el hbmap.el hbut.el \
hgnus.el hhist.el hib-debbugs.el hib-doc-id.el hib-kbd.el \
- hib-social.el hibtypes.el \
+ hib-org.el hib-social.el hibtypes.el \
hinit.el hload-path.el hmail.el hmh.el hmoccur.el hmouse-info.el \
hmouse-drv.el hmouse-key.el hmouse-mod.el hmouse-sh.el
hmouse-tag.el \
hpath.el hrmail.el hsettings.el hsmail.el hsys-org.el hsys-www.el
htz.el \
@@ -167,7 +167,7 @@ EL_KOTL = kotl/kexport.el kotl/kfile.el kotl/kfill.el
kotl/kimport.el kotl/klabe
kotl/kview.el kotl/kvspec.el
ELC_COMPILE = hactypes.elc hibtypes.elc hib-debbugs.elc hib-doc-id.elc
hib-kbd.elc \
- hib-social.elc hact.elc \
+ hib-org.el hib-social.elc hact.elc \
hargs.elc hbdata.elc hbmap.elc hbut.elc hgnus.elc hhist.elc \
hinit.elc hload-path.elc hmail.elc hmh.elc hmoccur.elc
hmouse-info.elc \
hmouse-drv.elc hmouse-key.elc hmouse-mod.elc hmouse-sh.elc
hmouse-tag.elc \
diff --git a/hib-kbd.el b/hib-kbd.el
index 1016a48..8b2c516 100644
--- a/hib-kbd.el
+++ b/hib-kbd.el
@@ -143,7 +143,7 @@ Returns t if KEY-SERIES has a binding, else nil."
;; Disable helm while processing M-x commands; helm
;; gobbles final RET key. Counsel works without modification.
(let ((orig-binding (global-key-binding [?\M-x]))
- (helm-flag (and (boundp 'helm-mode) helm-mode))
+ (helm-flag (when (boundp 'helm-mode) helm-mode))
(minibuffer-completion-confirm))
(unwind-protect
(progn
diff --git a/hib-org.el b/hib-org.el
new file mode 100644
index 0000000..b2bd79b
--- /dev/null
+++ b/hib-org.el
@@ -0,0 +1,139 @@
+;;; hib-org.el --- Implicit button type for Org mode
+;;
+;; Author: Bob Weiner
+;;
+;; Orig-Date: 2-Jul-16 at 14:54:14
+;;
+;; Copyright (C) 2016-2020 Free Software Foundation, Inc.
+;; See the "HY-COPY" file for license information.
+;;
+;; This file is part of GNU Hyperbole.
+
+;;; Commentary:
+;;
+;; This defines a context-sensitive implicit button type, org-mode,
+;; triggered when the major mode is org-mode or is derived from
+;; org-mode and point is anywhere other than at the end of a line.
+;;
+;; See the doc for ibtypes::org-mode for details of what it does and
+;; its compatibility with org-mode.
+;;
+;; For a good tutorial on basic use of Org-mode, see:
+;; https://orgmode.org/worg/org-tutorials/orgtutorial_dto.html
+
+;;; Code:
+;;; ************************************************************************
+;;; Other required Elisp libraries
+;;; ************************************************************************
+
+(require 'hsys-org)
+
+;;; ************************************************************************
+;;; Public Button Types
+;;; ************************************************************************
+
+(defib org-mode ()
+ "Follow Org mode references, cycles outline visibility and executes code
blocks.
+
+First, this follows internal links in Org mode files. When pressed on a
+link referent/target, the link definition is displayed, allowing two-way
+navigation between definitions and targets.
+
+Second, this follows Org mode external links.
+
+Third, within a radio target definition, this jumps to the first
+occurrence of an associated radio target.
+
+Fourth, when point is on an outline heading in Org mode, this
+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).
+
+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).
+
+To disable ALL Hyperbole support within Org major and minor modes, set the
+custom option `inhibit-hsys-org' to t. Then in Org modes, this will
+simply 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'."
+ (let (start-end)
+ (cond ((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))))
+ (if inhibit-hsys-org
+ (hact 'org-meta-return)
+ (cond ((hsys-org-agenda-item-at-p)
+ (hsys-org-set-ibut-label (cons (line-beginning-position)
(line-end-position)))
+ (hact 'org-agenda-show-and-scroll-up current-prefix-arg))
+ ((setq start-end (hsys-org-internal-link-target-at-p))
+ (hsys-org-set-ibut-label start-end)
+ (hact 'org-internal-link-target))
+ ((hsys-org-radio-target-def-at-p)
+ (hact 'org-radio-target))
+ ((setq start-end (hsys-org-link-at-p))
+ (hsys-org-set-ibut-label start-end)
+ (hact 'org-link))
+ ((org-at-heading-p)
+ (hact 'hsys-org-cycle))
+ ((hsys-org-block-start-at-p)
+ (org-ctrl-c-ctrl-c))
+ (t
+ (hact 'org-meta-return))))))))
+
+(defun org-mode:help (&optional _but)
+ "If on an Org mode heading, cycles through views of the whole buffer outline.
+If on an Org mode link, displays standard Hyperbole help."
+ (cond ((or (hsys-org-link-at-p) (hsys-org-agenda-item-at-p))
+ (hkey-help current-prefix-arg)
+ t)
+ ((and (funcall hsys-org-mode-function)
+ (org-at-heading-p))
+ (hact 'hsys-org-global-cycle)
+ t)))
+
+(defact org-link (&optional link)
+ "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)
+ (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)
+ "Follows an optional Org mode LINK-TARGET back to its link definition.
+If LINK-TARGET is nil, follows any link target at point. Otherwise, triggers
an error."
+ (let (start-end)
+ (cond ((stringp link-target)
+ (setq start-end t)
+ (hsys-org-search-internal-link-p link-target))
+ ((null link-target)
+ (when (setq start-end (hsys-org-internal-link-target-at-p))
+ (hsys-org-search-internal-link-p (buffer-substring-no-properties
+ (car start-end) (cdr
start-end))))))
+ (unless start-end
+ (error "(org-internal-link-target): Point must be on a link target (not
the link itself)"))))
+
+
+(defact org-radio-target (&optional target)
+ "Jump to the next occurrence of an optional Org mode radio TARGET link.
+If TARGET is nil and point is on a radio target definition or link, it
+uses that one. Otherwise, triggers an error."
+ (let (start-end)
+ (cond ((stringp target)
+ (setq start-end t)
+ (hsys-org-to-next-radio-target-link target))
+ ((null target)
+ (when (setq start-end (hsys-org-radio-target-at-p))
+ (hsys-org-to-next-radio-target-link (buffer-substring-no-properties
+ (car start-end) (cdr
start-end))))))
+ (unless start-end
+ (error "(org-radio-target): Point must be on a radio target definition
or link"))))
+
+(provide 'hib-org)
diff --git a/hibtypes.el b/hibtypes.el
index 7c5bd0c..949bb6a 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -65,6 +65,28 @@
(run-hooks 'hibtypes-begin-load-hook)
;;; ========================================================================
+;;; Follows URLs by invoking a web browser.
+;;; ========================================================================
+
+(require 'hsys-www)
+
+;;; ========================================================================
+;;; Follows Org links that are in non-Org mode buffers
+;;; ========================================================================
+
+(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."
+ (unless inhibit-hsys-org
+ (require 'hsys-org)
+ (let ((start-end (hsys-org-link-at-p)))
+ (hsys-org-set-ibut-label start-end)
+ (hact 'org-open-at-point-global))))
+
+;; Org links in Org mode are handled at a higher priority in "hib-org.el"
+
+;;; ========================================================================
;;; Composes mail, in another window, to the e-mail address at point.
;;; ========================================================================
@@ -242,12 +264,6 @@ must have an attached file."
(hact 'annot-bib ref))))))
;;; ========================================================================
-;;; Handles Gnu debbugs issue ids, e.g. bug#45678 or just 45678.
-;;; ========================================================================
-
-(require 'hib-debbugs)
-
-;;; ========================================================================
;;; Handles social media hashtag and username references, e.g.
twitter#myhashtag
;;; ========================================================================
@@ -539,6 +555,12 @@ spaces and then another non-space, non-parenthesis,
non-brace character."
(hact 'link-to-file entry))))))))
;;; ========================================================================
+;;; Handles Gnu debbugs issue ids, e.g. bug#45678 or just 45678.
+;;; ========================================================================
+
+(require 'hib-debbugs)
+
+;;; ========================================================================
;;; Executes or documents command bindings of brace delimited key sequences.
;;; ========================================================================
@@ -1124,12 +1146,6 @@ GNUS is a news and mail reader."
(hact 'gnus-article-press-button)))
;;; ========================================================================
-;;; Follows URLs by invoking a web browser.
-;;; ========================================================================
-
-(require 'hsys-www)
-
-;;; ========================================================================
;;; Displays Info nodes when double quoted "(file)node" button is activated.
;;; ========================================================================
@@ -1280,9 +1296,10 @@ arg1 ... argN '>'. For example, <mail nil
\"user@somewhere.org\">."
;;; Follows Org mode links and radio targets and cycles Org heading views
;;; ========================================================================
-;; Set the custom option `inhibit-hsys-org' non-nil to disable ALL Hyperbole
-;; support within Org major and minor modes.
-(require 'hsys-org)
+(require 'hib-org)
+
+;; If you want to to disable ALL Hyperbole support within Org major
+;; and minor modes, set the custom option `inhibit-hsys-org' non-nil.
;;; ========================================================================
;;; Inserts completion into minibuffer or other window.
diff --git a/hsys-org.el b/hsys-org.el
index 89ae575..73ee9c0 100644
--- a/hsys-org.el
+++ b/hsys-org.el
@@ -1,4 +1,4 @@
-;;; hsys-org.el --- GNU Hyperbole support for Emacs Org mode links
+;;; hsys-org.el --- GNU Hyperbole support functions for Support for hib-org.el
;;
;; Author: Bob Weiner
;;
@@ -11,15 +11,7 @@
;;; Commentary:
;;
-;; This defines a context-sensitive implicit button type, org-mode,
-;; triggered when the major mode is org-mode or is derived from
-;; org-mode and point is anywhere other than at the end of a line.
-;;
-;; See the doc for ibtypes::org-mode for details of what it does and
-;; its compatibility with org-mode.
-;;
-;; For a good tutorial on basic use of Org-mode, see:
-;; https://orgmode.org/worg/org-tutorials/orgtutorial_dto.html
+;; Support functions for hib-org.el
;;; Code:
;;; ************************************************************************
@@ -44,6 +36,7 @@
(defun hsys-org-mode-p ()
"Return non-nil if point is within an Org major or minor-mode buffer."
(or (derived-mode-p 'org-mode)
+ (derived-mode-p 'org-agenda-mode)
(and (boundp 'outshine-mode) outshine-mode)
(and (boundp 'poporg-mode) poporg-mode)))
@@ -66,116 +59,6 @@
t))
;;; ************************************************************************
-;;; Public Button Types
-;;; ************************************************************************
-
-(defib org-mode ()
- "Follow Org mode references, cycles outline visibility and executes code
blocks.
-
-First, this follows internal links in Org mode files. When pressed on a
-link referent/target, the link definition is displayed, allowing two-way
-navigation between definitions and targets.
-
-Second, this follows Org mode external links.
-
-Third, within a radio target definition, this jumps to the first
-occurrence of an associated radio target.
-
-Fourth, when point is on an outline heading in Org mode, this
-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).
-
-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).
-
-To disable ALL Hyperbole support within Org major and minor modes, set the
-custom option `inhibit-hsys-org' to t. Then in Org modes, this will
-simply invoke `org-meta-return'. Org links in non-"
- (let (start-end)
- (cond ((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))))
- (if inhibit-hsys-org
- (hact 'org-meta-return)
- (cond ((setq start-end (hsys-org-internal-link-target-at-p))
- (hsys-org-set-ibut-label start-end)
- (hact 'org-internal-link-target))
- ((hsys-org-radio-target-def-at-p)
- (hact 'org-radio-target))
- ((setq start-end (hsys-org-link-at-p))
- (hsys-org-set-ibut-label start-end)
- (hact 'org-link))
- ((org-at-heading-p)
- (hact 'hsys-org-cycle))
- ((hsys-org-block-start-at-p)
- (org-ctrl-c-ctrl-c))
- (t
- (hact 'org-meta-return)))))
- ;; Org links may be used outside of Org mode
- ((unless inhibit-hsys-org
- (setq start-end (hsys-org-link-at-p)))
- (hsys-org-set-ibut-label start-end)
- (hact 'org-open-at-point-global))
- ((hsys-org-agenda-item-at-p)
- (hsys-org-set-ibut-label (cons (line-beginning-position)
(line-end-position)))
- (hact 'org-agenda-show-and-scroll-up current-prefix-arg)))))
-
-(defun org-mode:help (&optional _but)
- "If on an Org mode heading, cycles through views of the whole buffer outline.
-If on an Org mode link, displays standard Hyperbole help."
- (cond ((or (hsys-org-link-at-p) (hsys-org-agenda-item-at-p))
- (hkey-help current-prefix-arg)
- t)
- ((and (funcall hsys-org-mode-function)
- (org-at-heading-p))
- (hact 'hsys-org-global-cycle)
- t)))
-
-(defact org-link (&optional link)
- "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)
- (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)
- "Follows an optional Org mode LINK-TARGET back to its link definition.
-If LINK-TARGET is nil, follows any link target at point. Otherwise, triggers
an error."
- (let (start-end)
- (cond ((stringp link-target)
- (setq start-end t)
- (hsys-org-search-internal-link-p link-target))
- ((null link-target)
- (when (setq start-end (hsys-org-internal-link-target-at-p))
- (hsys-org-search-internal-link-p (buffer-substring-no-properties
- (car start-end) (cdr
start-end))))))
- (unless start-end
- (error "(org-internal-link-target): Point must be on a link target (not
the link itself)"))))
-
-
-(defact org-radio-target (&optional target)
- "Jump to the next occurrence of an optional Org mode radio TARGET link.
-If TARGET is nil and point is on a radio target definition or link, it
-uses that one. Otherwise, triggers an error."
- (let (start-end)
- (cond ((stringp target)
- (setq start-end t)
- (hsys-org-to-next-radio-target-link target))
- ((null target)
- (when (setq start-end (hsys-org-radio-target-at-p))
- (hsys-org-to-next-radio-target-link (buffer-substring-no-properties
- (car start-end) (cdr
start-end))))))
- (unless start-end
- (error "(org-radio-target): Point must be on a radio target definition
or link"))))
-
-;;; ************************************************************************
;;; Public functions
;;; ************************************************************************
- [elpa] externals/hyperbole updated (d65920b -> 4eef4e9), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole c0e48fb 01/50: Use \0 for matched Nth substitution (#37), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 531cf87 02/50: Handle Org links in non-Org mode buffers with a low priority ibtype,
Stefan Monnier <=
- [elpa] externals/hyperbole afbae3a 04/50: Do not save temp buffer, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole c1ac392 05/50: Use emacs lisp for updating the web repo, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 357a098 06/50: Initial org-tbl support, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 0e8d33e 03/50: Add Makefile.maintenance, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole de9e60f 09/50: Fix bug#43692, failed to do substitute fixed case for path variables, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 66b35cc 07/50: Add kotl/kotl-orgtbl.el, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 8d77205 08/50: 7.1.3a - Add key bindings and finish Kotl Org table mode support, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 4ddeaf6 10/50: Remove Makefile.maintenance, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 28a1e0c 18/50: Use xdg-open to dispatch to user preferences for display alist (#40), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 7b92152 11/50: Merge pull request #39 from rswgnu/add-maintenance-makefile-with-web-site-support, Stefan Monnier, 2021/03/17