[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole 5544a6c: Fix Org mode handling to encompass a
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole 5544a6c: Fix Org mode handling to encompass all Smart Key keyboard contexts |
Date: |
Sun, 2 May 2021 15:57:09 -0400 (EDT) |
branch: externals/hyperbole
commit 5544a6c22b0bcc1c77970273f51fe521d56c5ff6
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>
Fix Org mode handling to encompass all Smart Key keyboard contexts
---
ChangeLog | 36 ++++---
MANIFEST | 9 +-
Makefile | 4 +-
hib-org.el | 149 --------------------------
hibtypes.el | 132 +++++++++++------------
hsettings.el | 2 +-
hsys-org.el | 71 ++++++++++--
hui-mouse.el | 98 +++++++++++++++++
hui-treemacs.el | 2 +-
test/{hib-org-tests.el => smart-org-tests.el} | 32 +++---
10 files changed, 275 insertions(+), 260 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d064ea5..8d806a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2021-05-02 Bob Weiner <rsw@gnu.org>
+* hibtypes.el (pathname-line-and-column): Lower priority below grep
+ ibtypes so does not interfere.
+ (grep-msg): Stop from matching to any file names
+ that start with quote marks. Those are handled elsewhere.
+
+* hui-mouse.el (hkey-alist, smart-org): Add smart-org near the top to
+ handle M-RET dispatching in Org mode prior to most other contexts.
+ Also integrated assist key handling from hsys-org.el org-mode:help
+ into smart-org.
+ hibtypes.el (org-mode): Remove this ibtype; replace with smart-org
+ function; this also ensures that pathnames within org links are
+ handled by Org commands.
+ hib-org.el: Move remaining action types to hsys-org.el and delete
+ this file.
+ test/hib-org-tests.el: Rename to test/smart-org-tests.el.
+
* kotl/kotl-mode.el (kotl-mode:kill-whole-line): Add override
of kill-whole-line for Koutliner.
@@ -166,9 +182,9 @@
2021-04-26 Mats Lidell <matsl@gnu.org>
-* test/hib-org-tests.el
(hib-org:org-mode-with-smart-keys-on-file-is-hypb-button)
- (hib-org:org-mode-with-smart-keys-buttons-on-file-is-hypb-button)
- (hib-org:org-mode-with-no-smart-keys-on-file-is-hypb-button): Tests for
+* test/smart-org-tests.el
(smart-org-mode-with-smart-keys-on-file-is-hypb-button)
+ (smart-org-mode-with-smart-keys-buttons-on-file-is-hypb-button)
+ (smart-org-mode-with-no-smart-keys-on-file-is-hypb-button): Tests for
hsys-org-enable-smart-keys.
* test/hy-test-helpers.el
@@ -184,8 +200,8 @@
(hsys-org:org-radio-target-def-at-p, hsys-org:org-radio-target-at-p)
(hsys-org:org-internal-link-target-at-p, hsys-org:org-face-at-p): hsys-org
tests
-* test/hib-org-tests.el (hib-org:org-mode-on-header-cycles-visibility):
- hib-org test
+* test/smart-org-tests.el (smart-org-mode-on-header-cycles-visibility):
+ smart-org test
* hsys-org.el (hsys-org-link-at-p): Use org-target-link-regexp for radio links
(hsys-org-internal-link-target-at-p): Inverse boolean check
@@ -206,9 +222,6 @@
* hyperbole.el (hyperbole-mode): Finish documentation.
-* hib-org.el (org-mode): Add (not (hyperb:stack-frame '(hbut:at-p)))
- to prevent infinite loop.
-
* hpath.el (hpath:posix-mount-point-to-mswindows-alist): Made this an autoload
since referenced in hyperbole.
@@ -222,7 +235,7 @@
Smart Key support in Org mode.
(hsys-org-hbut-activate-p):
hibtypes.el (org-link-outside-org-mode):
- hib-org.el (org-mode): Updated to use hsys-org-enable-smart-keys.
+ hui-mouse.el (smart-org-mode): Updated to use hsys-org-enable-smart-keys.
(inhibit-hsys-org): Remove, replaced by
hsys-org-enable-smart-keys.
man/hyperbole.texi (Questions and Answers): Updated Org mode section with
this new variable.
@@ -568,8 +581,6 @@
2021-04-05 Bob Weiner <rsw@gnu.org>
-* Makefile (ELC_COMPILE): Fix hib-org.elc (was .el).
-
* hibtypes.el (hypb-ert): Load Hyperbole test runner ibtypes.
2021-04-04 Mats Lidell <matsl@gnu.org>
@@ -935,9 +946,6 @@ absolute paths.
hibtypes.el: Changed require to load for all hibtype files so are always
added when the ibtype priority list is reset.
-* hibtypes.el (hib-org): Moved Org links to lowest priority so
- all implicit button types can be used in Org mode.
-
2020-10-18 Bob Weiner <rsw@gnu.org>
* hypb.el (hypb:replace-match-string):
diff --git a/MANIFEST b/MANIFEST
index 3500d2e..72757e9 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -42,7 +42,7 @@ hui-menu.el - Menubar menu of GNU Hyperbole commands
hui-mini.el - Single line command menus for GNU Hyperbole
hui-mouse.el - Use key or mouse key for many functions, e.g. GNU
Hyperbole menus
hui-select.el - Select delimited or larger and larger syntax-driven
regions in a buffer
-hui-treemacs.el - Hyperbole Smart Key support for the Treemacs file
manager package
+hui-treemacs.el - GNU Hyperbole Smart Key support for the Treemacs file
manager package
hui-window.el - Smart Mouse Key window and modeline depress/release
actions
hui.el - GNU Hyperbole button and hyperlink user interface
@@ -82,19 +82,18 @@ 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
-hsettings.el - Hyperbole settings which may require customization
+hsettings.el - GNU Hyperbole settings which may require customization
hvar.el - Variable manipulation routines for GNU Hyperbole
hypb-maintenance.el - Support for updating Hyperbole web pages
hyperbole-banner.png - Graphic of GNU Hyperbole for display with About
Hyperbole
smart-clib-sym - Test whether symbol appears within a set of C libraries
topwin.py - Python script to find the topmost macOS app window at a
screen position
-.hypb & _hypb - Button data files used by the Hyperbole DEMO file
+.hypb & _hypb - Button data files used by the GNU Hyperbole DEMO file
--- EXTERNAL SYSTEM ENCAPSULATIONS ---
-hsys-org.el - GNU Hyperbole support functions for hib-org.el
+hsys-org.el - GNU Hyperbole support functions for Org mode
hsys-www.el - GNU Hyperbole support for Emacs W3 World-Wide Web (WWW)
browsing
diff --git a/Makefile b/Makefile
index 4c9f58e..61e4b02 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-org.el hib-social.el hibtypes.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 \
@@ -168,7 +168,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-org.elc hib-social.elc hact.elc \
+ 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-org.el b/hib-org.el
deleted file mode 100644
index 0e95b03..0000000
--- a/hib-org.el
+++ /dev/null
@@ -1,149 +0,0 @@
-;;; 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
-;;; ************************************************************************
-
-(eval-when-compile (require 'hmouse-drv))
-
-(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 `hsys-org-enable-smart-keys' to nil. 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'."
- (when (and (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))))
- (cond ((not hsys-org-enable-smart-keys)
- (hact 'org-meta-return))
- ((and (not (hyperb:stack-frame '(hbut:at-p))) (hbut:at-p))
- ;; Activate any Hyperbole button at point
- (hbut:act))
- ((eq hsys-org-enable-smart-keys t)
- (let (start-end)
- (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
- ;; no operation
- t))))
- ;; default fallback cmd when (eq hsys-org-enable-smart-keys 'button)
- (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 ee24bc0..2ff28cb 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -101,41 +101,12 @@ line and check for a source reference line again."
(load "hypb-ert")
;;; ========================================================================
-;;; Follows Org mode links and radio targets and cycles Org heading views
-;;; ========================================================================
-
-(load "hib-org")
-
-;; If you want to to disable ALL Hyperbole support within Org major
-;; and minor modes, set the custom option `hsys-org-enable-smart-keys' to nil.
-
-;;; ========================================================================
;;; Follows URLs by invoking a web browser.
;;; ========================================================================
(load "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."
- (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)))))
-
-;; Org links in Org mode are handled at a lower priority in "hib-org.el"
-
-;;; ========================================================================
;;; Composes mail, in another window, to the e-mail address at point.
;;; ========================================================================
@@ -289,6 +260,27 @@ display options."
))))))
;;; ========================================================================
+;;; Follows Org links that are in non-Org mode buffers
+;;; ========================================================================
+
+;; Org links in Org mode are handled at the highest priority; see the last
+;; section at the end of this file.
+
+(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."
+ (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)))))
+
+;;; ========================================================================
;;; Use the XEmacs func-menu library to jump to a function referred to
;;; in the same file in which it is defined. Function references
;;; across files are handled separately by clauses within the
@@ -801,6 +793,34 @@ e.g. <ilink: my series of keys: ${hyperb:dir}/HYPB>."
(hlink 'link-to-ibut "ilink_" ilink:start ilink:end))
;;; ========================================================================
+;;; Displays files at specific lines and optional column number
+;;; locations.
+;;; ========================================================================
+
+(defib pathname-line-and-column ()
+ "Make a valid pathname:line-num[:column-num] pattern display the path at
line-num and optional column-num.
+Also works for remote pathnames.
+May also contain hash-style link references with the following format:
+\"<path>[#<link-anchor>]:<line-num>[:<column-num>]}\".
+
+See `hpath:at-p' function documentation for possible delimiters.
+See `hpath:suffixes' variable documentation for suffixes that are added to or
+removed from pathname when searching for a valid match.
+See `hpath:find' function documentation for special file display options."
+ (let ((path-line-and-col (hpath:delimited-possible-path)))
+ (when (and (stringp path-line-and-col)
+ (string-match hpath:section-line-and-column-regexp
path-line-and-col))
+ (let ((file (save-match-data (hpath:expand (match-string-no-properties 1
path-line-and-col))))
+ (line-num (string-to-number (match-string-no-properties 3
path-line-and-col)))
+ (col-num (when (match-end 4)
+ (string-to-number (match-string-no-properties 5
path-line-and-col)))))
+ (when (save-match-data (setq file (hpath:is-p file)))
+ (ibut:label-set file (match-beginning 1) (match-end 1))
+ (if col-num
+ (hact 'link-to-file-line-and-column file line-num col-num)
+ (hact 'link-to-file-line file line-num)))))))
+
+;;; ========================================================================
;;; Jumps to source line associated with ipython, ripgrep, grep or
;;; compilation errors.
;;; ========================================================================
@@ -902,35 +922,35 @@ in grep and shell buffers."
(beginning-of-line)
(when (or
;; Grep matches, UNIX C compiler and Introl 68HC11 C compiler
errors
- (looking-at "\\([^ \t\n\r:]+\\): ?\\([1-9][0-9]*\\)[ :]")
+ (looking-at "\\([^ \t\n\r:\"'`]+\\): ?\\([1-9][0-9]*\\)[ :]")
;; Grep matches, UNIX C compiler and Introl 68HC11 C
;; compiler errors, allowing for file names with
;; spaces followed by a null character rather than a :
- (looking-at "\\([^\t\n\r]+\\) ?\\([1-9][0-9]*\\)[ :]")
+ (looking-at "\\([^\t\n\r\"'`]+\\) ?\\([1-9][0-9]*\\)[ :]")
;; HP C compiler errors
(looking-at "[a-zA-Z0-9]+: \"\\([^\t\n\r\",]+\\)\", line
\\([0-9]+\\):")
;; BSO/Tasking 68HC08 C compiler errors
(looking-at
"[a-zA-Z 0-9]+: \\([^ \t\n\r\",]+\\) line \\([0-9]+\\)[ \t]*:")
;; UNIX Shell errors
- (looking-at "\\([^:]+\\): line \\([0-9]+\\): ")
+ (looking-at "\\([^:\"'`]+\\): line \\([0-9]+\\): ")
;; UNIX Lint errors
- (looking-at "[^:]+: \\([^ \t\n\r:]+\\): line \\([0-9]+\\):")
+ (looking-at "[^:\"'`]+: \\([^ \t\n\r:]+\\): line \\([0-9]+\\):")
;; SparcWorks C compiler errors (ends with :)
;; IBM AIX xlc C compiler errors (ends with .)
- (looking-at "\"\\([^\"]+\\)\", line \\([0-9]+\\)[:.]")
+ (looking-at "\"\\([^\"'`]+\\)\", line \\([0-9]+\\)[:.]")
;; Introl as11 assembler errors
- (looking-at " \\*+ \\([^ \t\n\r]+\\) - \\([0-9]+\\) ")
+ (looking-at " \\*+ \\([^ \t\n\r\"'`]+\\) - \\([0-9]+\\) ")
;; perl5: ... at file.c line 10
- (looking-at ".+ at \\([^ \t\n\r]+\\) line +\\([0-9]+\\)")
+ (looking-at ".+ at \\([^ \t\n\r\"'`]+\\) line +\\([0-9]+\\)")
;; Weblint
- (looking-at "\\([^ \t\n\r:()]+\\)(\\([0-9]+\\)): ")
+ (looking-at "\\([^ \t\n\r:()\"'`]+\\)(\\([0-9]+\\)): ")
;; Microsoft JVC
;; file.java(6,1) : error J0020: Expected 'class' or 'interface'
(looking-at "^\\(\\([a-zA-Z]:\\)?[^:\( \t\n\r-]+\\)[:\(][
\t]*\\([0-9]+\\),")
;; Grep match context lines (-A<num> option)
(and (string-match "grep\\|shell" (buffer-name))
- (looking-at "\\([^ \t\n\r:]+\\)-\\([1-9][0-9]*\\)-")))
+ (looking-at "\\([^ \t\n\r:\"'`]+\\)-\\([1-9][0-9]*\\)-")))
(let* ((file (match-string-no-properties 1))
(line-num (match-string-no-properties 2))
(but-label (concat file ":" line-num))
@@ -1040,34 +1060,6 @@ This works with JavaScript and Python tracebacks, gdb,
dbx, and xdb. Such lines
(hact 'link-to-file-line file line-num))))))
;;; ========================================================================
-;;; Displays files at specific lines and optional column number
-;;; locations.
-;;; ========================================================================
-
-(defib pathname-line-and-column ()
- "Make a valid pathname:line-num[:column-num] pattern display the path at
line-num and optional column-num.
-Also works for remote pathnames.
-May also contain hash-style link references with the following format:
-\"<path>[#<link-anchor>]:<line-num>[:<column-num>]}\".
-
-See `hpath:at-p' function documentation for possible delimiters.
-See `hpath:suffixes' variable documentation for suffixes that are added to or
-removed from pathname when searching for a valid match.
-See `hpath:find' function documentation for special file display options."
- (let ((path-line-and-col (hpath:delimited-possible-path)))
- (when (and (stringp path-line-and-col)
- (string-match hpath:section-line-and-column-regexp
path-line-and-col))
- (let ((file (save-match-data (hpath:expand (match-string-no-properties 1
path-line-and-col))))
- (line-num (string-to-number (match-string-no-properties 3
path-line-and-col)))
- (col-num (when (match-end 4)
- (string-to-number (match-string-no-properties 5
path-line-and-col)))))
- (when (save-match-data (setq file (hpath:is-p file)))
- (ibut:label-set file (match-beginning 1) (match-end 1))
- (if col-num
- (hact 'link-to-file-line-and-column file line-num col-num)
- (hact 'link-to-file-line file line-num)))))))
-
-;;; ========================================================================
;;; Jumps to source of Emacs Lisp byte-compiler error messages.
;;; ========================================================================
@@ -1403,6 +1395,14 @@ arg1 ... argN '>'. For example, <mail nil
\"user@somewhere.org\">."
(ibut:label-set completion)
(hact 'completion))))
+;;; ========================================================================
+;;; Follows Org mode links and radio targets and cycles Org heading views
+;;; ========================================================================
+
+;; See `smart-org' in "hui-mouse.el"; this is higher priority than all ibytpes
+
+;; If you want to to disable ALL Hyperbole support within Org major
+;; and minor modes, set the custom option `hsys-org-enable-smart-keys' to nil.
(run-hooks 'hibtypes-end-load-hook)
(provide 'hibtypes)
diff --git a/hsettings.el b/hsettings.el
index 570497f..dd9fa01 100644
--- a/hsettings.el
+++ b/hsettings.el
@@ -1,4 +1,4 @@
-;;; hsettings.el --- Hyperbole settings which may require customization
+;;; hsettings.el --- GNU Hyperbole settings which may require customization
;;
;; Author: Bob Weiner
;;
diff --git a/hsys-org.el b/hsys-org.el
index 38cef0d..77a8a5a 100644
--- a/hsys-org.el
+++ b/hsys-org.el
@@ -1,4 +1,4 @@
-;;; hsys-org.el --- GNU Hyperbole support functions for Support for hib-org.el
+;;; hsys-org.el --- GNU Hyperbole support functions for Org mode
;;
;; Author: Bob Weiner
;;
@@ -11,13 +11,24 @@
;;; Commentary:
;;
-;; Support functions for hib-org.el
+;; Support functions for smart-org in "hui-mouse.el"
+;;
+;; smart-org is triggered when the major mode is org-mode or is derived
+;; from org-mode.
+;;
+;; See the doc for smart-org 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
;;; ************************************************************************
+(eval-when-compile (require 'hmouse-drv))
+
(require 'hbut)
(require 'org)
(require 'org-element)
@@ -42,9 +53,61 @@ with different settings of this option. For example, a nil
value makes
:initialize #'custom-initialize-default
:group 'hyperbole-buttons)
+;;; ************************************************************************
+;;; Public variables
+;;; ************************************************************************
+
(defvar hsys-org-mode-function #'hsys-org-mode-p
"*Boolean function of no arguments that determines whether point is in an
Org mode-related buffer or not.")
+;;; ************************************************************************
+;;; Public Action Types
+;;; ************************************************************************
+
+(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
+;;; ************************************************************************
+
(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)
@@ -64,10 +127,6 @@ with different settings of this option. For example, a nil
value makes
this-command 'org-cycle)
(org-global-cycle nil))
-;;; ************************************************************************
-;;; Public functions
-;;; ************************************************************************
-
(defun hsys-org-region-with-text-property-value (pos property)
"Return (start . end) buffer positions of the region around POS that shares
its non-nil text PROPERTY value, else nil."
(when (null pos) (setq pos (point)))
diff --git a/hui-mouse.el b/hui-mouse.el
index 3311fbd..b9a7188 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -42,6 +42,7 @@
(require 'hmouse-info))
(unless (fboundp 'smart-c-at-tag-p)
(require 'hmouse-tag))
+(require 'hsys-org)
;;; ************************************************************************
;;; Public variables
@@ -99,6 +100,11 @@ Its default value is #'smart-scroll-down."
((and (boundp 'company-active-map)
(memq company-active-map (current-minor-mode-maps))) .
((smart-company-to-definition) . (smart-company-help)))
+ ;; Handle any Org mode-specific contexts
+ ((and (not (hyperb:stack-frame '(smart-org)))
+ (smart-org current-prefix-arg)) .
+ ;; smart-org performs the actions and assist help
+ ((identity t) . (identity t)))
;; Ivy minibuffer completion mode
((and (boundp 'ivy-mode) ivy-mode (minibuffer-window-active-p
(selected-window))) .
((ivy-done) . (ivy-dispatching-done)))
@@ -1543,6 +1549,98 @@ If not on a file name, returns nil."
ref))))
;;; ************************************************************************
+;;; smart-org functions
+;;; ************************************************************************
+
+(defun smart-org (&optional assist-flag)
+ "If `hsys-org-enable-smart-keys' is non-nil, follow Org mode references,
cycles outline visibility and executes code blocks.
+
+When the Action Key is pressed:
+
+ 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).
+
+When the Assist Key is pressed:
+
+ First, on an Org mode heading, this cycles through views of the whole buffer
outline.
+
+ Second, on on an Org mode link or agenda item, this displays standard
Hyperbole help.
+
+To disable ALL Hyperbole support within Org major and minor modes, set the
+custom option `hsys-org-enable-smart-keys' to nil. 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'."
+ (when (funcall hsys-org-mode-function)
+ (cond ((not hsys-org-enable-smart-keys)
+ (hact 'org-meta-return current-prefix-arg)
+ ;; Ignore any further Smart Key non-Org contexts
+ t)
+ ((hbut:at-p)
+ ;; Activate/Assist with any Hyperbole button at point
+ (if (not assist-flag)
+ (hact 'hbut:act)
+ (hact 'hkey-help))
+ ;; Ignore any further Smart Key non-Org contexts
+ t)
+ ((eq hsys-org-enable-smart-keys t)
+ (let (start-end)
+ (cond ((hsys-org-agenda-item-at-p)
+ (if (not assist-flag)
+ (progn (hsys-org-set-ibut-label (cons
(line-beginning-position) (line-end-position)))
+ (hact 'org-agenda-show-and-scroll-up
current-prefix-arg))
+ (hact 'hkey-help))
+ ;; Ignore any further Smart Key non-Org contexts
+ t)
+ ((setq start-end (hsys-org-internal-link-target-at-p))
+ (hsys-org-set-ibut-label start-end)
+ (hact 'org-internal-link-target)
+ t)
+ ((hsys-org-radio-target-def-at-p)
+ (hact 'org-radio-target)
+ t)
+ ((setq start-end (hsys-org-link-at-p))
+ (if (not assist-flag)
+ (progn (hsys-org-set-ibut-label start-end)
+ (hact 'org-link))
+ (hact 'hkey-help))
+ t)
+ ((org-at-heading-p)
+ (if (not assist-flag)
+ (hact 'hsys-org-cycle)
+ (hact 'hsys-org-global-cycle))
+ t)
+ ((hsys-org-block-start-at-p)
+ (hact 'org-ctrl-c-ctrl-c)
+ t)
+ (t
+ ;; Continue with any further Smart Key non-Org contexts
+ nil))))
+ (t
+ ;; hsys-org-enable-smart-keys is set to 'buttons or some
+ ;; invalid value (treat it just like 'buttons) and
+ ;; ignore any further Smart Key non-Org contexts
+ t))))
+
+
+;;; ************************************************************************
;;; smart-outline functions
;;; ************************************************************************
diff --git a/hui-treemacs.el b/hui-treemacs.el
index 5b93917..6491629 100644
--- a/hui-treemacs.el
+++ b/hui-treemacs.el
@@ -1,4 +1,4 @@
-;;; hui-treemacs.el --- Hyperbole Smart Key support for the Treemacs file
manager package
+;;; hui-treemacs.el --- GNU Hyperbole Smart Key support for the Treemacs file
manager package
;;
;; Author: Bob Weiner
;;
diff --git a/test/hib-org-tests.el b/test/smart-org-tests.el
similarity index 62%
rename from test/hib-org-tests.el
rename to test/smart-org-tests.el
index 1ea3942..0d7435d 100644
--- a/test/hib-org-tests.el
+++ b/test/smart-org-tests.el
@@ -1,4 +1,4 @@
-;;; hib-org-tests.el --- hib-org-el tests -*- lexical-binding: t;
-*-
+;;; smart-org-tests.el --- smart-org-el tests -*- lexical-binding:
t; -*-
;; Copyright (C) 2021 Mats Lidell
@@ -13,18 +13,18 @@
;;; Commentary:
-;; Tests for "../hib-org.el"
+;; Tests for smart-org in "../hui-mouse.el"
;;; Code:
(require 'ert)
-(require 'hib-org)
+(require 'hui-mouse)
(require 'hact)
(declare-function hy-test-helpers:hypb-function-should-call-hpath:find
"hy-test-helpers")
-(ert-deftest hib-org:org-mode-on-header-cycles-visibility ()
- "With smart keys on an outline header `ibtypes::org-mode' cycles visibility."
+(ert-deftest smart-org-mode-on-header-cycles-visibility ()
+ "With smart keys on an outline header `smart-org' cycles visibility."
(with-temp-buffer
(let ((bn (buffer-name))
(hsys-org-enable-smart-keys t))
@@ -32,33 +32,33 @@
(insert "* 1\n** 2\n*** 3\n")
(goto-char 1)
(should (not (org-check-for-hidden 'headlines)))
- (ibtypes::org-mode)
+ (smart-org)
;; Setting the buffer should not be needed but for some reason
- ;; it looks like we get into ert buffer after ibtypes::org-mode
+ ;; it looks like we get into ert buffer after smart-org
(set-buffer bn)
(should (org-check-for-hidden 'headlines))
(next-line)
(should (equal (line-number-at-pos) 4)))))
-(ert-deftest hib-org:org-mode-with-smart-keys-on-file-is-hypb-button ()
+(ert-deftest smart-org-mode-with-smart-keys-on-file-is-hypb-button ()
"With smart keys on file name is hypb button."
(with-temp-buffer
(let ((hsys-org-enable-smart-keys t))
(org-mode)
(insert "/tmp")
(goto-char 1)
- (hy-test-helpers:hypb-function-should-call-hpath:find 'ibtypes::org-mode
"/tmp"))))
+ (hy-test-helpers:hypb-function-should-call-hpath:find 'smart-org
"/tmp"))))
-(ert-deftest hib-org:org-mode-with-smart-keys-buttons-on-file-is-hypb-button ()
+(ert-deftest smart-org-mode-with-smart-keys-buttons-on-file-is-hypb-button ()
"With smart keys on file name is hypb button."
(with-temp-buffer
(let ((hsys-org-enable-smart-keys 'buttons))
(org-mode)
(insert "/tmp")
(goto-char 1)
- (hy-test-helpers:hypb-function-should-call-hpath:find 'ibtypes::org-mode
"/tmp"))))
+ (hy-test-helpers:hypb-function-should-call-hpath:find 'smart-org
"/tmp"))))
-(ert-deftest hib-org:org-mode-with-no-smart-keys-on-file-is-hypb-button ()
+(ert-deftest smart-org-mode-with-no-smart-keys-on-file-is-hypb-button ()
"With no smart keys on file calls org mode M-RET."
(with-temp-buffer
(let ((bn (buffer-name))
@@ -66,11 +66,11 @@
(org-mode)
(insert "/tmp")
(goto-char 1)
- (ibtypes::org-mode)
+ (smart-org)
;; Setting the buffer should not be needed but for some reason
- ;; it looks like we get into ert buffer after ibtypes::org-mode
+ ;; it looks like we get into ert buffer after smart-org
(set-buffer bn)
(should (equal (buffer-string) "* /tmp")))))
-(provide 'hib-org-tests)
-;;; hib-org-tests.el ends here
+(provide 'smart-org-tests)
+;;; smart-org-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/hyperbole 5544a6c: Fix Org mode handling to encompass all Smart Key keyboard contexts,
ELPA Syncer <=