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

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

[elpa] externals/hyperbole 1320c37e8b 05/16: hynote.el - Add initial HyN


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 1320c37e8b 05/16: hynote.el - Add initial HyNote link support for Org and Org Roam
Date: Sun, 30 Jun 2024 03:58:23 -0400 (EDT)

branch: externals/hyperbole
commit 1320c37e8b2374c8e837e3a72db5a581d78fe377
Author: bw <rsw@gnu.org>
Commit: bw <rsw@gnu.org>

    hynote.el - Add initial HyNote link support for Org and Org Roam
---
 ChangeLog     |  34 +++++++++++----
 MANIFEST      |   5 ++-
 Makefile      |   4 +-
 hbut.el       |  11 ++++-
 hibtypes.el   |   8 +++-
 hmouse-drv.el |  10 ++---
 hynote.el     | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hypb.el       |   6 +++
 hywiki.el     |  53 +++--------------------
 9 files changed, 199 insertions(+), 69 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c8f6c08d40..27012fa5a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,29 @@
+2024-06-25  Bob Weiner  <rsw@gnu.org>
+
+* hibtypes.el (hynote): Add for Org and Org Roam links by name.
+  MANIFEST (hynote.el): Add.
+  Makefile (EL_COMPILE): Add hynote.el.
+
+* hynote.el (hynote-directory-list, hynote-find-file-stem): Add.
+
+* hbut.el (ibut:create): Add debugging to show the type name if an ibtype
+    evaluation fails.
+  hmouse-drv.el (hkey-execute, hkey-help): Change 'eval' to 'hypb:eval-debug'
+    to show a backtrace whenever an error occurs.
+
 2024-06-23  Bob Weiner  <rsw@gnu.org>
 
-* Makefile: (dockerized-run): Add to intweractively run dockerized versions
-    of Emacs with Hyperbole.  Update Commentary to summarize dockerized
+* hynote.el (hynote-get-files, hynote-get-file-stem-list, hynote-find-file,
+             hynote-file-stem-start-end-at):
+    Add these functions to find non-HyWikiWord files in `hywiki-directory' when
+    referenced by stem name, e.g. Action key on Non-Wiki-Word displays
+    Non-Wiki-Word.org.
+            (hynote-file): Add ibtype to display non-HyWikiWord files in
+    hywiki-directory'.
+
+
+* Makefile: (docker-run): Add to intweractively run docker versions
+    of Emacs with Hyperbole.  Update Commentary to summarize docker
     targets that build, byte-compile and run Hyperbole.
 
 2024-06-22  Mats Lidell  <matsl@gnu.org>
@@ -12,7 +34,7 @@
 
 * Makefile (dockerized-update): Target to update (pull) the Emacs docker
     image.
-    (dockerized): Copy source to docker so not local workspace is affected
+    (dockererized): Copy source to docker so not local workspace is affected
     when running targets in the docker environment.
 
 2024-06-22  Bob Weiner  <rsw@gnu.org>
@@ -31,12 +53,6 @@
 * hywiki.el (hywiki-word-at): Fix to use 
'hywiki-word-with-optional-section-regexp'
     instead of 'hywiki-word-regexp' so handles sections properly.
             (hywiki-word-highlight-flag): Improve documentation.
-            (hywiki-get-files, hywiki-get-file-stem-list, hywiki-find-file):
-    Add these functions to find non-HyWikiWord files in `hywiki-directory' when
-    referenced by stem name, e.g. Action key on Non-Wiki-Word displays
-    Non-Wiki-Word.org.
-            (hywiki-file): Add ibtype to display non-HyWikiWord files in
-    hywiki-directory'.
            (hywiki-get-page-file): Allow name to include 'hywiki-file-suffix'
     for non-HyWikiWord files.  Also, rename to 'hywiki-get-file'.
 
diff --git a/MANIFEST b/MANIFEST
index f2ded012f9..3c1f8cbfee 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -78,9 +78,10 @@ hyrolo.el            - Hierarchical, multi-file, easy-to-use 
record management s
 hyrolo.py            - Output file header and matching entries from HyRolo 
files via the command-line
 hyrolo-logic.el      - Logic functions for GNU Hyperbole Rolo files
 
-* --- HYPERBOLE WIKI ---
-hywiki.el            - Hyperbole's auto-wikiword note-taking system
+* --- HYPERBOLE NOTES AND WIKI ---
 hasht.el             - Create hash tables from lists and operate on them.
+hynote.el            - Link to Org and Org Roam notes by name
+hywiki.el            - Hyperbole's auto-wikiword note-taking system
 
 * --- USENET NEWS SUPPORT ---
 hgnus.el             - GNU Hyperbole buttons in news reader/poster: GNUS
diff --git a/Makefile b/Makefile
index 7cc0b848a1..bcb5e0b7c1 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 # Author:       Bob Weiner
 #
 # Orig-Date:    15-Jun-94 at 03:42:38
-# Last-Mod:     23-Jun-24 at 00:16:22 by Bob Weiner
+# Last-Mod:     25-Jun-24 at 02:32:30 by Bob Weiner
 #
 # Copyright (C) 1994-2023  Free Software Foundation, Inc.
 # See the file HY-COPY for license information.
@@ -198,7 +198,7 @@ EL_COMPILE = hact.el hactypes.el hargs.el hbdata.el 
hbmap.el hbut.el \
             hpath.el hrmail.el hsettings.el hsmail.el hsys-flymake.el 
hsys-org.el \
              hsys-org-roam.el hsys-www.el hsys-xref.el hsys-youtube.el htz.el \
             hycontrol.el hui-jmenu.el hui-menu.el hui-mini.el hui-mouse.el 
hui-select.el \
-            hui-treemacs.el hui-window.el hui.el hvar.el hversion.el hypb.el 
hyperbole.el \
+            hui-treemacs.el hui-window.el hui.el hvar.el hversion.el hynote.el 
hypb.el hyperbole.el \
             hyrolo-demo.el hyrolo-logic.el hyrolo-menu.el hyrolo.el 
hywconfig.el hywiki.el \
              hasht.el set.el hypb-ert.el hui-dired-sidebar.el 
hypb-maintenance.el hui-em-but.el \
              hui-register.el
diff --git a/hbut.el b/hbut.el
index 501d92a11d..958db847ee 100644
--- a/hbut.el
+++ b/hbut.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    18-Sep-91 at 02:57:09
-;; Last-Mod:     23-Jun-24 at 00:11:37 by Mats Lidell
+;; Last-Mod:     25-Jun-24 at 01:03:43 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1957,7 +1957,14 @@ If a new button is created, store its attributes in the 
symbol,
                         (setq ibtype-point (point))
                         (while (and (not is-type) types)
                           (setq itype (car types))
-                          (when (and itype (setq args (funcall itype)))
+                          (when (condition-case ()
+                                    (and itype (setq args (funcall itype)))
+                                  ;; Purposely trigger another error
+                                  ;; here by sending a symbol
+                                  ;; argument to the message call
+                                  ;; below so can see the value of
+                                  ;; itype whose funcall failed above.
+                                  (error (message itype)))
                             (setq is-type itype)
                             ;; Any implicit button type check should leave 
point
                             ;; unchanged.  Trigger an error if not.
diff --git a/hibtypes.el b/hibtypes.el
index ed2156f614..c4b11e4467 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -91,7 +91,13 @@
 ;; ibtype priorities.
 
 ;;; ========================================================================
-;;; Creates and display personal wiki pages with auto-wikiword links
+;;; Displays Org and Org Roam files and sections by name link
+;;; ========================================================================
+
+(load "hynote")
+
+;;; ========================================================================
+;;; Creates and displays personal wiki pages and sections with auto-wikiword 
links
 ;;; ========================================================================
 
 (load "hywiki")
diff --git a/hmouse-drv.el b/hmouse-drv.el
index 59b2b43f4a..c748fced8b 100644
--- a/hmouse-drv.el
+++ b/hmouse-drv.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    04-Feb-90
-;; Last-Mod:      8-Mar-24 at 11:06:21 by Mats Lidell
+;; Last-Mod:     25-Jun-24 at 02:13:58 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1029,7 +1029,7 @@ predicate is found."
     (while (and (null pred-value) (setq hkey-form (car hkey-forms)))
       (if (setq hkey-action (if assisting (cddr hkey-form) (cadr hkey-form))
                pred (car hkey-form)
-               pred-value (eval pred))
+               pred-value (hypb:eval-debug pred))
          (progn
            ;; Any Smart Key predicate should leave point unchanged.
            ;; Trigger an error if not.
@@ -1041,9 +1041,7 @@ predicate is found."
            (when hkey-debug
              (hkey-debug pred pred-value hkey-action))
            (if hkey-debug
-               (let ((debug-on-error t)
-                     (debug-on-quit t))
-                 (eval hkey-action))
+               (hypb:eval-debug hkey-action)
              (eval hkey-action)))
        (setq hkey-forms (cdr hkey-forms))))
     pred-value))
@@ -1062,7 +1060,7 @@ documentation is found."
         (assist-flag assisting)
         hkey-form pred-value call calls cmd-sym doc)
     (while (and (null pred-value) (setq hkey-form (car hkey-forms)))
-      (or (setq pred-value (eval (car hkey-form)))
+      (or (setq pred-value (hypb:eval-debug (car hkey-form)))
          (setq hkey-forms (cdr hkey-forms))))
     (if pred-value
        (setq call (if assisting (cdr (cdr hkey-form))
diff --git a/hynote.el b/hynote.el
new file mode 100644
index 0000000000..8f16206fd5
--- /dev/null
+++ b/hynote.el
@@ -0,0 +1,137 @@
+;;; hynote.el --- Link to Org and Org Roam notes by name   -*- 
lexical-binding: t; -*-
+;;
+;; Author:       Bob Weiner
+;;
+;; Orig-Date:    23-Jun-24 at 12:50:37
+;; Last-Mod:     25-Jun-24 at 02:39:05 by Bob Weiner
+;;
+;; SPDX-License-Identifier: GPL-3.0-or-later
+;;
+;; Copyright (C) 2024  Free Software Foundation, Inc.
+;; See the "HY-COPY" file for license information.
+;;
+;; This file is part of GNU Hyperbole.
+
+;;; Commentary:
+;;
+;;  This is Hyperbole's note taking system, HyNote.  It utilizes the
+;;  Org mode or the Koutliner file format plus UUIds and HyRolo for note 
lookups.
+;;
+;;  See all the autoloaded functions herein for interactive commands.
+;;  See the Info manual entry "(hyperbole)HyNote" for usage information.
+
+;;; Code:
+;;; ************************************************************************
+;;; Other required Elisp libraries
+;;; ************************************************************************
+
+(require 'hyrolo)
+(require 'hywiki)
+
+;;; ************************************************************************
+;;; Public Implicit Button and Action Types
+;;; ************************************************************************
+
+(defun hynote-file-stem-start-end-at ()
+  "Return (file-stem start end) if on a `hynote-directory-list' file stem.
+Otherwise, return (nil nil nil)."
+  (or (hpath:delimited-possible-path nil t)
+      (list nil nil nil)))
+
+(defib hynote-file ()
+  "When on a HyNote file name stem, display the file and its optional section.
+This type is active only in buffers where `hywiki-active-in-current-buffer-p'
+is true.  This may require that (hywiki-mode) has been enabled."
+  (when (hywiki-active-in-current-buffer-p)
+    (cl-destructuring-bind (file-stem-name start end)
+       (hynote-file-stem-start-end-at)
+      (when file-stem-name
+       (let ((file (hynote-get-file file-stem-name))
+             section)
+         (when (and file (file-readable-p file))
+           (setq section (when (string-match "#" file-stem-name)
+                           (substring file-stem-name (match-beginning 0))))
+           (ibut:label-set file-stem-name start end)
+           (hact 'hynote-find-file file section)))))))
+
+(defun hynote-find-file (file &optional section)
+  "Display an existing FILE starting at SECTION.
+SECTION must be the name of a heading from the FILE and should begin
+with \"#\", though this function will add \"#\" if missing.
+
+Return the absolute path to any file successfully found, else nil.
+After successfully finding a file and reading it into a buffer, run
+`hynote-find-file-hook'."
+  (interactive (list (completing-read "Find HyNote file: "
+                                     (hynote-get-files))))
+  (when (and (stringp file) (file-readable-p file))
+    (when (and (stringp section) (not (string-prefix-p "#" section)))
+      (setq section (concat "#" section)))
+    (hpath:find (concat file section))
+    (hywiki-maybe-highlight-page-names)
+    (run-hooks 'hynote-find-file-hook)
+    file))
+
+(defun hynote-find-file-stem (file-stem-name)
+  "Display an existing FILE-STEM-NAME from `hynote-directory-list'.
+Return the absolute path to any file successfully found, else nil.
+
+After successfully finding a file and reading it into a buffer, run
+`hynote-find-file-hook'."
+  (interactive (list (completing-read "Find HyNote file: "
+                                     (hynote-get-file-stems))))
+  (when (stringp file-stem-name)
+    (let ((file (hynote-get-file file-stem-name))
+         section)
+      (when (file-readable-p file)
+       (setq section (when (string-match "#" file-stem-name)
+                       (substring file-stem-name (match-beginning 0))))
+       (when file
+         (hpath:find (concat file section))
+         (hywiki-maybe-highlight-page-names)
+         (run-hooks 'hynote-find-file-hook)
+         file)))))
+
+;;; ************************************************************************
+;;; Public variables
+;;; ************************************************************************
+
+(defvar hynote-directory-list '("~/org/" "~/org-roam/")
+  "Directories in which to find HyNote Org files.")
+
+;;; ************************************************************************
+;;; Public functions
+;;; ************************************************************************
+
+(defun hynote-get-file (file-stem-name)
+  "Return existing file path in `hynote-directory-list' from FILE-STEM-NAME.
+File name must end with `hyrolo-file-suffix-regexp'.  No
+validation of FILE-STEM-NAME is done."
+  ;; Remove any #section from `file-stem-name'
+  (setq file-stem-name (if (string-match "#" file-stem-name)
+                          (substring file-stem-name 0 (match-beginning 0))
+                        file-stem-name))
+  (locate-file file-stem-name hynote-directory-list 
+              '(".org" ".md" ".kotl" ".kot")))
+
+(defun hynote-get-files ()
+  "Return `hynote-directory-list' files ending with 
`hyrolo-file-suffix-regexp'.
+File names returned are relative to `hynote-directory-list'."
+  (mapcan
+   (lambda (dir)
+    (make-directory dir t)
+    (when (file-readable-p dir)
+      (directory-files dir nil (concat "^[^#]+" hyrolo-file-suffix-regexp))))
+   hynote-directory-list))
+
+(defun hynote-get-file-stems ()
+  "Return the list of existing HyWiki files sans their `hynote-file-suffixes'.
+This includes both Hynote page files and others.  Stems returned are
+relative to `hynote-directory-list'."
+  (mapcar #'file-name-sans-extension (hynote-get-files)))
+
+;;; ************************************************************************
+;;; Private functions
+;;; ************************************************************************
+
+(provide 'hynote)
diff --git a/hypb.el b/hypb.el
index 34a67d26a9..d804b5e064 100644
--- a/hypb.el
+++ b/hypb.el
@@ -476,6 +476,12 @@ the `format' function."
     (put 'error 'error-message msg)
     (error msg)))
 
+(defun hypb:eval-debug (sexp)
+  "Eval SEXP and on error show a debug backtrace of the problem."
+  (let ((debug-on-error t)
+       (debug-on-quit t))
+    (eval sexp)))
+
 (defun hypb:fgrep-git-log (string)
   "List git log entries whose changesets include STRING for selection and 
display.
 Listing is asynchronous.  A press of RET, the Action Key or the
diff --git a/hywiki.el b/hywiki.el
index 89ca51790c..66c2da05f2 100644
--- a/hywiki.el
+++ b/hywiki.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    21-Apr-24 at 22:41:13
-;; Last-Mod:     23-Jun-24 at 00:12:37 by Mats Lidell
+;; Last-Mod:     24-Jun-24 at 23:33:45 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -381,21 +381,6 @@ See the Info documentation at \"(hyperbole)HyWiki\".
 ;;; Public Implicit Button and Action Types
 ;;; ************************************************************************
 
-(defun hywiki-file-stem-start-end-at ()
-  "Return (file-stem start-pos end-pos) if on a `hywiki-directory' file stem.
-Otherwise, return (nil nil nil)."
-  (or (hpath:delimited-possible-path nil t)
-      (list nil nil nil)))
-
-(defib hywiki-file ()
-  "When on a HyWiki file name stem, display the file and its optional section."
-  (cl-destructuring-bind (file-stem-name start end)
-      (hywiki-file-stem-start-end-at)
-    (when (and file-stem-name
-              (file-readable-p (hywiki-get-file file-stem-name)))
-      (ibut:label-set file-stem-name start end)
-      (hact 'hywiki-find-file file-stem-name))))
-
 (defib hywiki-word ()
   "When on a HyWiki word, display its page and optional section."
   (let ((page-name (hywiki-word-at)))
@@ -403,26 +388,6 @@ Otherwise, return (nil nil nil)."
       (ibut:label-set page-name (match-beginning 0) (match-end 0))
       (hact 'hywiki-find-page page-name))))
 
-(defun hywiki-find-file (file-stem-name)
-  "Display an existing non-HyWikiWord FILE-STEM-NAME from `hywiki-directory'.
-Return the absolute path to any file successfully found, else nil.
-
-After successfully finding a file and reading it into a buffer, run
-`hywiki-find-file-hook'."
-  (interactive (list (completing-read "Find HyWiki file: "
-                                     (hywiki-get-file-stem-list))))
-  (when (stringp file-stem-name)
-    (let ((file (hywiki-get-file file-stem-name))
-         section)
-      (when (file-readable-p file)
-       (setq section (when (string-match "#" file-stem-name)
-                       (substring file-stem-name (match-beginning 0))))
-       (when file
-         (hpath:find (concat file section))
-         (hywiki-maybe-highlight-page-names)
-         (run-hooks 'hywiki-find-file-hook)
-         file)))))
-
 (defun hywiki-find-page (&optional page-name prompt-flag)
   "Display HyWiki PAGE-NAME or a regular file with PAGE-NAME nil.
 Return the absolute path to any page successfully found; nil if
@@ -440,7 +405,7 @@ successfully finding a page and reading it into a buffer, 
run
     (if (or (stringp page-name) in-hywiki-directory-flag)
        (progn
          (when in-page-flag
-           ;; Current buffer must be the desired page (called from 
'find-file-hook')
+           ;; Current buffer must be the desired page
            (unless in-hywiki-directory-flag
              (error "(hywiki-find-page): No `page-name' given; buffer file 
must be in `hywiki-directory', not %s"
                     default-directory))
@@ -467,10 +432,10 @@ successfully finding a page and reading it into a buffer, 
run
              (hywiki-maybe-highlight-page-names)
              (run-hooks 'hywiki-find-page-hook)
              page-file)))
-      ;; When called from `find-file-hook' without a page-name and outside
-      ;; hywiki-directory, just find as a regular file and use next line
-      ;; to highlight HyWikiWords only if buffer was not previously
-      ;; highlighted.
+      ;; When called from without a page-name and outside
+      ;; hywiki-directory, just find as a regular file and use next
+      ;; line to highlight HyWikiWords only if buffer was not
+      ;; previously highlighted.
       (hywiki-maybe-highlight-page-names))))
 
 ;;; ************************************************************************
@@ -896,12 +861,6 @@ relative to `hywiki-directory'."
        hywiki-directory nil
        (concat "^[^#]+" (regexp-quote hywiki-file-suffix) "$")))))
 
-(defun hywiki-get-file-stem-list ()
-  "Return the list of existing HyWiki files sans their `hywiki-file-suffix'.
-This includes both HyWiki page files and others.  Stems returned are
-relative to `hywiki-directory'."
-  (mapcar #'file-name-sans-extension (hywiki-get-files)))
-
 (defun hywiki-get-page (page-name)
   "Return the absolute path of HyWiki PAGE-NAME or nil if it does not exist."
   (if (and (stringp page-name) (not (string-empty-p page-name))



reply via email to

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