Skip to content

Commit

Permalink
Fix hyrolo-to-entry-beginning
Browse files Browse the repository at this point in the history
Fix byte-compiler warnings
  • Loading branch information
rswgnu committed Jan 16, 2024
1 parent a85f06a commit 48210fb
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 61 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2024-01-15 Bob Weiner <[email protected]>

* hyrolo.el (hyrolo-to-entry-beginning): Rewrite to move properly.
(hyrolo-move-backward): Remove, no longer used.

2024-01-16 Mats Lidell <[email protected]>

* test/hyrolo-tests.el
Expand Down
3 changes: 2 additions & 1 deletion hsettings.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 15-Apr-91 at 00:48:49
;; Last-Mod: 3-Oct-23 at 17:22:51 by Mats Lidell
;; Last-Mod: 15-Jan-24 at 23:57:25 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand All @@ -26,6 +26,7 @@
;;; Other required Elisp libraries
;;; ************************************************************************

(require 'cl-lib)
(require 'hversion)
(require 'hvar)
(require 'browse-url)
Expand Down
7 changes: 6 additions & 1 deletion hsys-org-roam.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 26-Feb-23 at 11:20:15 by Bob Weiner
;; Last-Mod: 6-Jan-24 at 00:54:15 by Mats Lidell
;; Last-Mod: 15-Jan-24 at 23:54:00 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand All @@ -22,6 +22,11 @@
;; assign them UUIDs required for indexing by Org Roam.

;;; Code:
;;; ************************************************************************
;;; Other required Elisp libraries
;;; ************************************************************************

(require 'package)

;;; ************************************************************************
;;; Public declarations
Expand Down
15 changes: 8 additions & 7 deletions hsys-org.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 2-Jul-16 at 14:54:14
;; Last-Mod: 14-Jan-24 at 12:07:26 by Bob Weiner
;; Last-Mod: 16-Jan-24 at 00:16:13 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -35,6 +35,7 @@
(require 'org)
(require 'org-element)
(require 'org-fold nil t)
(require 'org-macs)
(require 'package)
;; Avoid any potential library name conflict by giving the load directory.
(require 'set (expand-file-name "set" hyperb:dir))
Expand All @@ -50,13 +51,13 @@
:type 'function
:group 'org)

;; `org-show-context' is obsolete as of Org 9.6, use `org-fold-show-context'
;; instead.
(unless (fboundp #'org-fold-show-context)
(with-suppressed-warnings ((obsolete org-show-context))
(defalias 'org-fold-show-context #'org-show-context)))

(defvar hyperbole-mode-map) ; "hyperbole.el"
(defvar org--inhibit-version-check) ; "org-macs.el"

(declare-function org-babel-get-src-block-info "org-babel")
(declare-function org-fold-show-context "org-fold")
(declare-function org-link-open-from-string "ol")
(declare-function outline-on-heading-p "outline")

(declare-function smart-eobp "hui-mouse")
(declare-function smart-eolp "hui-mouse")
Expand Down
14 changes: 7 additions & 7 deletions hui-treemacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 19-Nov-17
;; Last-Mod: 3-Oct-23 at 23:01:16 by Mats Lidell
;; Last-Mod: 16-Jan-24 at 00:21:50 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand All @@ -21,12 +21,12 @@
;;; Other required Elisp libraries
;;; ************************************************************************

(when (or (require 'treemacs nil t)
(and (require 'package)
(package-installed-p 'treemacs)
(package-activate 'treemacs)))
(require 'package)
(require 'seq)

(require 'treemacs)
(or (require 'treemacs nil t)
(and (package-installed-p 'treemacs)
(package-activate 'treemacs)))

(defvar treemacs-version)

Expand Down Expand Up @@ -141,4 +141,4 @@ Suitable for use as a value of `action-key-modeline-buffer-id-function'."

(provide 'hui-treemacs)
;;; hui-treemacs.el ends here
)

3 changes: 2 additions & 1 deletion hui-window.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 21-Sep-92
;; Last-Mod: 27-Dec-23 at 23:59:25 by Bob Weiner
;; Last-Mod: 15-Jan-24 at 23:52:17 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand All @@ -30,6 +30,7 @@
(require 'hycontrol)
;; If installed, use pulse library for momentary highlighting of buffer/file item lines.
(require 'pulse nil t)
(require 'seq)
(require 'hui-select)

;;; ************************************************************************
Expand Down
7 changes: 4 additions & 3 deletions hypb.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 6-Oct-91 at 03:42:38
;; Last-Mod: 14-Jan-24 at 10:47:40 by Bob Weiner
;; Last-Mod: 15-Jan-24 at 23:51:41 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand All @@ -19,8 +19,9 @@
;;; Other required Elisp libraries
;;; ************************************************************************

;; Load Org here for `org-show-all'.
(eval-and-compile (mapc #'require '(compile hversion hact locate cl-lib org)))
;; Load Org here for `org-fold-show-all'.
(eval-and-compile (mapc #'require '(compile hversion hact locate
cl-lib org package)))

;;; ************************************************************************
;;; Public declarations
Expand Down
61 changes: 20 additions & 41 deletions hyrolo.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 7-Jun-89 at 22:08:29
;; Last-Mod: 15-Jan-24 at 21:27:59 by Bob Weiner
;; Last-Mod: 15-Jan-24 at 23:50:21 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -93,6 +93,7 @@
(declare-function hui:hbut-act "hui")
(declare-function ibut:at-p "hbut")
(declare-function kcell-view:indent "kotl/kview")
(declare-function kcell-view:level "kotl/kview")

(declare-function hmouse-pulse-line "hui-window")
(declare-function hpath:find "hpath")
Expand Down Expand Up @@ -2354,15 +2355,13 @@ begins or nil if not found."
With optional prefix arg INCLUDE-SUB-ENTRIES non-nil, move to the
beginning of the highest ancestor level. Return final point."
(interactive "P")
(hyrolo-move-backward
(lambda (include-sub-entries)
(outline-back-to-heading)
(when include-sub-entries
(unless (<= (hyrolo-outline-level) 1)
(outline-up-heading 80)))
(when (hyrolo-hdr-move-after-p)
(hyrolo-outline-next-visible-heading 1)))
include-sub-entries))
(when (hyrolo-hdr-in-p)
(hyrolo-hdr-to-first-line-p))
(if include-sub-entries
(unless (<= (hyrolo-outline-level) 1)
(hyrolo-outline-up-heading 80))
(hyrolo-outline-back-to-heading))
(point))

(defun hyrolo-to-entry-end (&optional include-sub-entries)
"Move point past the end of the current entry.
Expand Down Expand Up @@ -2803,29 +2802,6 @@ Any call to this function should be wrapped in a call to
"Pop to BUFFER."
(pop-to-buffer buffer other-window-flag))

(defun hyrolo-move-backward (func &rest args)
"Move back past any file header and apply FUNC to ARGS.
Return final point."
(let ((opoint (point)))
;; Prevent error when calling 'func' when within a file header.
(while (and (or (looking-at hyrolo-hdr-regexp)
(looking-at hbut:source-prefix))
(hyrolo-outline-previous-heading)))
(when (/= (point) opoint)
(forward-line 1))
(hyrolo-funcall-match
(lambda ()
(apply func args)
(when (or (looking-at hyrolo-hdr-regexp)
(looking-at hbut:source-prefix))
(forward-line 1)
(re-search-backward hyrolo-hdr-regexp nil t 2))
(when (> (point) opoint)
(goto-char opoint)))
;; Narrow to current match buffer when given a lambda func.
(not (symbolp func))))
(point))

(defun hyrolo-move-forward (func &rest args)
"Move forward past any file header and apply FUNC to ARGS.
If FUNC is a lambda (not a function symbol), then temporarily
Expand Down Expand Up @@ -2903,8 +2879,7 @@ prior to applying FUNC."
(error "(hryolo-map-matches): No HyRolo matches in current buffer"))
(let ((display-buf (get-buffer hyrolo-display-buffer)))
(if (eq (current-buffer) display-buf)
(let ((outline-regexp hyrolo-hdr-and-entry-regexp)
(bounds hyrolo--cache-loc-match-bounds)
(let ((bounds hyrolo--cache-loc-match-bounds)
(ofont-lock font-lock-mode)
(omode major-mode)
(ostart (point-min))
Expand All @@ -2923,7 +2898,8 @@ prior to applying FUNC."
(let ((font-lock-mode))
(hyrolo-cache-set-major-mode (1+ start))
(setq font-lock-mode nil) ;; Prevent Org mode from font-locking
(funcall func))))
(let ((outline-regexp hyrolo-hdr-and-entry-regexp))
(funcall func)))))
(when narrow-flag
;; Restore original restriction
(narrow-to-region ostart oend))
Expand All @@ -2940,8 +2916,9 @@ prior to applying FUNC."
;; hyrolo uses reveal-mode, redisplay will rexpand
;; hidden entries to make point visible.
(hyrolo-back-to-visible-point)))
(save-excursion
(funcall func)))))
(let ((outline-regexp hyrolo-hdr-and-entry-regexp))
(save-excursion
(funcall func))))))

(defun hyrolo-funcall-match (func &optional narrow-flag backward-flag)
"Apply FUNC with no arguments to the entry at point.
Expand All @@ -2957,7 +2934,7 @@ on a file boundary, move point back a character to select the
proper major mode."
(let ((display-buf (get-buffer hyrolo-display-buffer)))
(if (eq (current-buffer) display-buf)
(let ((outline-regexp hyrolo-hdr-and-entry-regexp))
(progn
(when (< (length hyrolo--cache-loc-match-bounds) 1)
(error "(hryolo-funcall-match): No HyRolo matches in display buffer"))
(let ((ofont-lock font-lock-mode)
Expand All @@ -2978,7 +2955,8 @@ proper major mode."
(hyrolo-cache-set-major-mode (1+ start)))
;; Prevent Org and Outline minor modes from font-locking
(setq font-lock-mode nil)
(funcall func)))
(let ((outline-regexp hyrolo-hdr-and-entry-regexp))
(funcall func))))
(with-current-buffer display-buf
;; func may have changed the current buffer
(when narrow-flag
Expand All @@ -2997,7 +2975,8 @@ proper major mode."
;; hyrolo uses reveal-mode, redisplay will rexpand
;; hidden entries to make point visible.
(hyrolo-back-to-visible-point)))))
(funcall func))))
(let ((outline-regexp hyrolo-hdr-and-entry-regexp))
(funcall func)))))

(defun hyrolo-cache-location-start-and-end ()
"Return a list of the (start end) of location matches that point is within.
Expand Down

0 comments on commit 48210fb

Please sign in to comment.