Skip to content

Commit

Permalink
Merge pull request #615 from rswgnu/rsw
Browse files Browse the repository at this point in the history
hywiki.el - Add global HyWiki page override & custom referent types
  • Loading branch information
rswgnu authored Dec 16, 2024
2 parents e2749c6 + 93874b2 commit c4c5daa
Show file tree
Hide file tree
Showing 20 changed files with 1,386 additions and 610 deletions.
203 changes: 201 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,23 +1,224 @@
2024-12-16 Bob Weiner <[email protected]>

* test/hbut-tests.el: Change most "/tmp" to "/tmp/" for ease of comparison
with 'default-directory'.

2024-12-15 Bob Weiner <[email protected]>

* test/hywiki-tests.el (hywiki-tests--action-key-on-wikiword-displays-page):
Change mocklet call from 'hywiki-add-page' to newer
'hywiki-display-referent' to fix the test.

* test/hywiki-tests.el (hywiki-tests--active-in-current-buffer-p): Force
'hywiki-mode' nil when testing that hywiki is not active.

* hpath.el (hpath:shorten): Fix to normalize directory paths to end with
a dir separator char so compare properly to `default-directory'.

* hbut.el (ebut:get): Remove unneeded local 'actype'.

* test/hywiki-tests.el (hywiki-tests--assist-key-on-wikiword-displays-help):
Update to not use mocklet and to check WikiWord returned.

* hywiki.el (hywiki-word, hywiki-word-at): Rewrite to get the proper
start and end buffer positions of any wikiword string, accounting for
Org link complexities much better than before.

* hbut.el (hbut:source): Update doc to reflect that the caller must have
successfully searched for 'hbut:source-prefix' prior to calling this.
(ibut:set-name-and-label-key-p): Add set of ibut 'loc attribute
needed by a number of tests.

* hmouse-tag.el (smart-tags-file-list, smart-ancestor-tag-files): Fix to
handle a list of directories as the first argument in which to look
for TAGS files, as used by 'smart-man-c-routine-ref' in "hui-mouse.el".
hui-mouse.el (smart-man-c-routine-ref): Update to support use of newer
'Man-header-file-path' variable.

2024-12-02 Bob Weiner <[email protected]>

* hywiki.el (hywiki-clear-pages-hasht): Add and use in defcustom :set
method of `hywiki-directory' to ensure hash table is emptied including
all non-page referents when 'hywiki-directory' is changed.

2024-12-01 Bob Weiner <[email protected]>

* hmouse-drv.el (action-key-depress, assist-key-depress, hkey-help): Add
calls to (hattr:clear 'hbut:current) to clear 'hbut:current' button
attributes before depress,

* hbut.el (ibut:create): Move setting of 'hbut:current HyWiki 'referent
attribute from 'hkey-help' to this function, so works with all
ibutton reports. Also, remove 'name-and-lbl-key-flag' from check
of whether to set attributes to the current button values. Also,
move call of 'hbut:report' when called interactively to here from
'ibut:set-name-and-label-key-p' so works with all ibutton reports.
(ibut:set-name-and-label-key-p): Fix to return non-nil only when
'lbl-key' or 'name' are set.
(ebut:get): Remove Hyperbole V1 setting of 'referent' attribute
from (hbdata:referent) so as not to confuse new use of same attribute
for HyWiki referents.
hibtypes.el (action): Add :name arg to 'ibut:create' call.

* hywiki.el (hywiki-display-page): Set 'referent' attribute for
current button.

* hsys-org.el (hsys-org-link-at-p): Change to ignore [[hy:MyWikiWord]]
links.
hywiki.el (hywiki-word-at): Change to handle [[hy:MyWikiWord]] links.
(hywiki-strip-org-link): Also strip hy: prefix from a link.

* hywiki.el (hywiki-get-plural-wikiword): Return non-nil iff
'hywiki-allow-plurals-flag' is set.
(hywiki-get-page-hasht): Remove any nil return values from
calling 'hywiki-allow-plurals-flag'.
(hywiki-allow-plurals-flag): Reset 'hywiki--any-page-regexp-list'
whenever this variable is set.

* test/hywiki-tests.el (hywiki-tests--action-key-on-wikiword-displays-page,
hywiki-tests--assist-key-on-wikiword-displays-help):
Update to test Action and Assist Key behavior.

* hywiki.el: Add additional require, defvar and declare-function to
remove byte-compiler warnings.

2024-11-25 Bob Weiner <[email protected]>

* hywiki.el (hywiki-referent-menu): Make all menu calls interactive
and update all hywiki-add-* interactive specs to take any wikiword
at point and if not, then prompt with completion for one.

* hui-mini.el (hui:menu-hywiki): HyWiki menu replace FindPage with
FindReferent.
(hui:menu-act): Fix improper closing parens before end
of setq causing a bug where always returned nil.

2024-11-25 Mats Lidell <[email protected]>

* kotl/kmenu.el (kotl-menu-common-body): Use kotl-kview.

* .github/workflows/static.yaml: Static workflow for publishing the manual
to a static site using GitHub Pages.

2024-11-24 Bob Weiner <[email protected]>

* hywiki.el (hywiki-add-page-and-display): Add optional prefix arg
PROMPT-FLAG for use in 'hywiki-find-referent' call. Rewrite.
Update doc. This allows setting custom referent types when passing
a prefix arg to the the HyWiki/Create menu item.
(hywiki-display-page, hywiki-get-referent): Call 'hywiki-get-file'
to expand page file path, rather than doing it manually. Return referent.

* hmouse-drv.el (hkey-help): If a HyWikiWord ibut, save its referent as an
attribute.

* hui-menu.el (hui-menu-hywiki): Rename 'Add-HyWiki-Link' to 'Insert-HyWiki-Link'.
hywiki.el (hywiki-add-link): Rename to 'hywiki-insert-link'.

* hywiki.el (hywiki-read-new-page-name, hywiki-read-page-name):
Rename to 'hywiki-word-read-new' and 'hywiki-word-read'.
Change prompt from "HyWiki Page Name" to "HyWikiWord" since
not all referents are pages any more.
(hywiki-word-grep): Add to compute and perform HyWikiWord grep.
(hywiki-get-page): Rename to 'hywiki-get-referent'.
(hywiki-get-singular-page-name): Rename to
'hywiki-get-singular-wikiword'.
(hywiki-get-plural-page-name): Rename to
'hywiki-get-plural-wikiword'.
(hywiki-page-exists-p): Rename to 'hywiki-referent-exists-p'
and improve doc string.
(hywiki-display-referent): Fix to use existing referent if any
before calling 'hywiki-add-page'.
(hywiki-referent-menu): Change 'Path' to 'Link' and add 'Page'
to reset to a standard HyWiki Page link.
(hywiki-add-path): Rename to 'hywiki-add-link'.
(hywiki-add-page): Remove unused 'prompt-flag' arg and replace
with optional 'force-flag' to force overwriting an existing HyWikiWord
referent.
(hywiki-add-to-page): Rename to 'hywiki-add-to-referent' and
rewrite to handle referents. Change arg 'start-flag' to 'position'
of insert.

* hactypes.el (link-to-buffer-tmp, link-to-file): Fix 'point' arg to
accept markers.

* hywiki.el (hywiki-make-pages-hasht): Fix to maintain non-page referent
elements when rebuild the hash table.

* hibtypes.el (hywiki-word:help): Add so Assist Key on a HyWikiWord
customizes its referent type and link.

2024-11-24 Mats Lidell <[email protected]>

* Makefile (website-local-devel): Update the website files locally for
development version.
(website-devel): Push local updates to go live at
https:/www.gnu.org/software/hyperbole/devel.

2024-11-23 Bob Weiner <[email protected]>

* hui.el (hui:link-possible-types): Allow for :CUSTOM_ID: in
addition to :ID: matches for Org IDs.

* hib-kbd.el (kbd-key:normalize): Fix interactive expr to read
a string rather than a single key sequence.

* hywiki.el (hywiki-get-wikiwords-obarray): Add.
(hywiki-read-new-page-name, hywiki-read-page-name):
Replace 'hywiki-get-page-list' completion table with
'hywiki-get-wikiwords-obarray' which is more efficient.
(hywiki-find-page): Rename to 'hywiki-find-referent'.
Rename 'hywiki-find-page-hook' to 'hywiki-find-referent-hook'.
(hywiki-word-activate): Change so automatically creates
pages that do not exist, except for the first HyWiki page, in
which case, prompts before creation.
(hywiki-display-page-function): Add this customization
function that displays HyWiki pages.
(hywiki-display-page): Add to use above variable to
display HyWiki pages.
(hywiki-word): Update doc with first page prompting.
(hywiki-maybe-highlight-page-names): Return nil so
'hywiki-display-referent' returns nil when this is called.
(hywiki-get-file, hywiki-display-referent): Improve
#section matching to ignore #autosave# file names.
(hywiki-allow-plurals-flag): Add new customization,
defaults to t to treat plural HyWikiWords the same as singular
ones.
(hywiki-get-page): Handle HyWikiWord plurals based on
the above flag.

* hactypes.el: Document potential second arg of referent (point)
when referent is already read into a buffer and user wants
to link to the current point.

* hywiki.el (hywiki-add-*): Add to allow each HyWikiWord to have
a custom referent when created with a prefix argument. Referent
type is prompted for, similar to when creating other Hyperbole
buttons.
(hywiki-add-prompted-referent): Add to prompt for and
link a HyWikiWord to a custom referent or action type.
(hywiki-referent-menu): New minibuffer menu used by the
above function.
(hywiki-get-page): Expand to return all new possible
referent types.
(hywiki-display-referent): Add to display all of the
new referent types.
(hywiki-read-new-page-name): Use any potential WikiWord at
point as the default.

2024-11-23 Mats Lidell <[email protected]>

* Makefile (BATCHFLAGS): Use debug-on-error's default value nil. Emacs 31
introduces calling man using with-demoted-errors which
causes an error when requiring man when debug-on-error is set to t.

2024-11-22 Bob Weiner <[email protected]>

* hywiki.el (hywiki-find-page): Add missing second interactive
arg value, current-prefix-arg. Rewrite to allow for
different actions per HyWikiWord or a single overriding
function.

2024-11-19 Bob Weiner <[email protected]>

* hywiki.el (hywiki-maybe-highlight-page-name): Fix that adding
Expand All @@ -30,8 +231,6 @@
man-show where needed. This may allow CI/CD build of docker Emacs
master branch that lacks 'man' package.

2024-11-18 bw <bw@norlinux>

* hui-tests.el (hui--ibut-link-directly-to-org-header-first-column):
Remove dir from fileb when comparing to in-buffer filename and
do the same for other tests in this file.
Expand Down
15 changes: 9 additions & 6 deletions hactypes.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 23-Sep-91 at 20:34:36
;; Last-Mod: 18-Nov-24 at 23:27:33 by Bob Weiner
;; Last-Mod: 24-Nov-24 at 12:09:18 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -280,15 +280,15 @@ if any."

(defact link-to-buffer-tmp (buffer &optional point)
"Display a BUFFER scrolled to optional POINT.
If POINT is given, the buffer is displayed with POINT at the top of
the window.
If POINT is given (an integer or marker), the buffer is displayed with
POINT at the top of the window.
This type of link is for use within a single editor session. Use
`link-to-file' instead for a permanent link."
(interactive "bBuffer to link to: ")
(if (or (stringp buffer) (bufferp buffer))
(and (hpath:display-buffer buffer)
(integerp point)
(integer-or-marker-p point)
(progn (goto-char (min (point-max) point))
(recenter 0)))
(hypb:error "(link-to-buffer-tmp): Not a current buffer: %s" buffer)))
Expand Down Expand Up @@ -347,7 +347,10 @@ Interactively, KEY-FILE defaults to the current buffer's file name."
(describe-symbol symbol)))))

(defun hactypes:link-to-file-interactively ()
"Get a path to link to and return it as a one item list."
"Get a path to link to and return it as a one item list.
If the path is already read into a buffer, prompt the user whether to
also include its current (point) and if so, include that as the second
list item returned."
(let ((prev-reading-p hargs:reading-type)
(existing-buf t)
path-buf)
Expand Down Expand Up @@ -423,7 +426,7 @@ the window or as close as possible."
;; the path that use within a key series may have introduced.
(setq path (hpath:trim path))
(and (hpath:find path)
(integerp point)
(integer-or-marker-p point)
(progn (goto-char (min (point-max) point))
(recenter 0))))
(hypb:error "(link-to-file): Invalid file name: \"%s\"" path)))
Expand Down
29 changes: 16 additions & 13 deletions hasht.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
;; AUTHOR: Bob Weiner
;;
;; ORIG-DATE: 16-Mar-90 at 03:38:48
;; LAST-MOD: 6-Oct-24 at 13:26:58 by Bob Weiner
;; LAST-MOD: 24-Nov-24 at 15:20:44 by Bob Weiner
;;
;; Copyright (C) 1990-1995, 1997, 2016 Free Software Foundation, Inc.
;; See the file BR-COPY for license information.
Expand Down Expand Up @@ -65,11 +65,12 @@ It is sent the two values as arguments.")

(defun hash-add (value key hash-table)
"Add VALUE, any lisp object, referenced by KEY, a string, to HASH-TABLE.
Replaces any VALUE previously referenced by KEY."
(if (hashp hash-table)
(let* ((obarray (hash-obarray hash-table))
(sym (intern key obarray)))
(if sym (set sym value)))))
Replace any VALUE previously referenced by KEY."
(when (hashp hash-table)
(let* ((obarray (hash-obarray hash-table))
(sym (intern key obarray)))
(when sym
(set sym value)))))

(defun hash-copy (hash-table)
"Return a copy of HASH-TABLE.
Expand Down Expand Up @@ -111,7 +112,7 @@ Return nil if KEY is not in HASH-TABLE or non-nil otherwise."
(let ((htable-copy (hash-make (length (hash-obarray obj)))))
(mapc
(lambda (elt) (hash-add (car elt) (cdr elt) htable-copy))
(hash-map 'hash-deep-copy obj))
(hash-map #'hash-deep-copy obj))
htable-copy))
((vectorp obj)
;; convert to list for mapping
Expand Down Expand Up @@ -141,10 +142,11 @@ Return nil if KEY is not in HASH-TABLE or non-nil otherwise."
"Lookup KEY in HASH-TABLE and return associated value.
If value is nil, this function does not tell you whether or not KEY is in the
hash table. Use `hash-key-p' instead for that function."
(if (hashp hash-table)
(let* ((obarray (hash-obarray hash-table))
(sym (intern-soft key obarray)))
(if (boundp sym) (symbol-value sym)))))
(when (hashp hash-table)
(let* ((obarray (hash-obarray hash-table))
(sym (intern-soft key obarray)))
(when (boundp sym)
(symbol-value sym)))))

(defun hash-make (initializer &optional reverse)
"Create a hash table from INITIALIZER.
Expand Down Expand Up @@ -201,7 +203,7 @@ in reverse order of occurrence (they are prepended to the list)."
(cons 'hasht obarray)))

(defun hash-map (func hash-table)
"Return result of applying FUNC over each (<value> . <key>) in HASH-TABLE.
"Return list result of calling FUNC over each (<value> . <key>) in HASH-TABLE.
<key> is a symbol.
If FUNC is in '(cdr key second symbol-name), then return all <key>s as strings.
Expand All @@ -215,7 +217,8 @@ If FUNC is in '(car value first symbol-value), then return all <value>s."
(t `(lambda (sym) (funcall ,func
(cons (symbol-value sym)
(symbol-name sym)))))))
(let ((result))
(let ((obarray (hash-obarray hash-table))
result)
(mapatoms (lambda (sym)
(and (boundp sym)
sym
Expand Down
3 changes: 1 addition & 2 deletions hbdata.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 2-Apr-91
;; Last-Mod: 18-Feb-24 at 11:32:03 by Mats Lidell
;; Last-Mod: 2-Dec-24 at 01:48:15 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -253,7 +253,6 @@ entry, otherwise modify existing one. Nil BUT-SYM means use
(let* ((actype)
(hbdata (list (hattr:get b 'lbl-key)
(hattr:get b 'action)
;; Hyperbole V1 referent compatibility, always nil in V2
(hattr:get b 'referent)
;; Save actype without class prefix.
(and (setq actype (hattr:get b 'actype))
Expand Down
Loading

0 comments on commit c4c5daa

Please sign in to comment.