update packages

This commit is contained in:
2026-06-27 11:34:21 +02:00
parent 4be4f859c4
commit 1aaef48596
246 changed files with 7997 additions and 4359 deletions

View File

@@ -1,7 +1,7 @@
;; -*- no-byte-compile: t; lexical-binding: nil -*-
(define-package "indent-guide" "20260211.1005"
(define-package "indent-guide" "20260515.1152"
"Show vertical lines to guide indentation."
()
:url "http://hins11.yu-yake.com/"
:commit "f3455c6c798b568a6ea1013b7eea1153d2e092be"
:revdesc "f3455c6c798b")
:url "http://zk-phi.github.io/"
:commit "ab71cac290505caf6c374cb8594b0b78d5109af1"
:revdesc "ab71cac29050")

View File

@@ -17,9 +17,9 @@
;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
;; Author: zk_phi
;; URL: http://hins11.yu-yake.com/
;; Package-Version: 20260211.1005
;; Package-Revision: f3455c6c798b
;; URL: http://zk-phi.github.io/
;; Package-Version: 20260515.1152
;; Package-Revision: ab71cac29050
;;; Commentary:
@@ -71,12 +71,13 @@
;; 2.2.0 add option "indent-guide-threshold"
;; 2.3.0 use regexp search to find the beginning of level
;; 2.3.1 add option "indent-guide-lispy-modes"
;; 2.4.0 add option "indent-guide-char-top" and "-bottom"
;;; Code:
(require 'cl-lib)
(defconst indent-guide-version "2.4")
(defconst indent-guide-version "2.4.0")
;; * customs
@@ -85,7 +86,7 @@
:group 'environment)
(defcustom indent-guide-char "|"
"Character used for the guide line."
"Character used for the guide line."
:type 'string
:group 'indent-guide)
@@ -146,14 +147,6 @@ blocks are NOT placed at beginning of line."
;; * utilities
(defun indent-guide--active-overlays ()
"Return the list of all overlays created by indent-guide."
(delq nil
(mapcar
(lambda (ov)
(and (eq (overlay-get ov 'category) 'indent-guide) ov))
(overlays-in (point-min) (point-max)))))
(defun indent-guide--indentation-candidates (level)
"*Internal function for `indent-guide--beginning-of-level'."
(cond ((<= level 0)
@@ -169,21 +162,39 @@ blocks are NOT placed at beginning of line."
(cons (make-string level ?\s)
(indent-guide--indentation-candidates (1- level))))))
;; Note(vmargb): `indent-guide--beginning-of-level' is called repeatedly
;; even within the same indentation level when the cursor is moved around
;; so we cache and reuse it until the user changes to another indent level
(defvar-local indent-guide--regex-cache nil
"Stores the last computed regex with the inputs used to build it.
Format: ((BASE-LEVEL . TAB-WIDTH) . REGEX-STRING).")
(defun indent-guide--beginning-of-level ()
"Move to the beginning of current indentation level and return
the point. When no such points are found, just return nil."
the point. When no such points are found, just return nil."
(back-to-indentation)
(let* ((base-level (if (not (eolp))
(current-column)
(max (save-excursion
(skip-chars-forward "\s\t\n")
(skip-chars-forward " \t\n")
(current-column))
(save-excursion
(skip-chars-backward "\s\t\n")
(skip-chars-backward " \t\n")
(back-to-indentation)
(current-column)))))
(candidates (indent-guide--indentation-candidates (1- base-level)))
(regex (concat "^" (regexp-opt candidates t) "[^\s\t\n]")))
(cache-key (cons base-level tab-width)) ; key: indent depth & tab width
;; check if current inputs match regex-cache
(regex (if (equal (car indent-guide--regex-cache) cache-key)
(cdr indent-guide--regex-cache) ; reuse regex string
; recompute regex
(let ((candidates (indent-guide--indentation-candidates
(1- base-level))))
(setq indent-guide--regex-cache
(cons cache-key
(concat "^"
(regexp-opt candidates t)
"[^ \t\n]")))
(cdr indent-guide--regex-cache)))))
(unless (zerop base-level)
(and (search-backward-regexp regex nil t)
(goto-char (match-end 1))))))
@@ -195,7 +206,7 @@ the point. When no such points are found, just return nil."
indent-guide-char
(cond
((= line line-start) (or indent-guide-char-top indent-guide-char))
((= line line-end) (or indent-guide-char-bottom indent-guide-char))
((= line line-end) (or indent-guide-char-bottom indent-guide-char))
(t indent-guide-char)))
)
@@ -220,7 +231,7 @@ the point. When no such points are found, just return nil."
(lambda (ov)
(when (eq (overlay-get ov 'category) 'indent-guide)
ov))
(overlays-in (point) (point))))
(overlays-at (point))))
;; we already have an overlay here => append to the existing overlay
;; (important when "recursive" is enabled)
(setq string (let ((str (overlay-get ov 'before-string)))
@@ -278,11 +289,11 @@ the point. When no such points are found, just return nil."
(interactive)
;;; NOTE(arka): redraw only when needed
(unless (active-minibuffer-window)
(indent-guide-remove)
(let ((win-start (window-start))
(win-end (window-end nil t))
line-col line-start line-end)
;;; only clear overlays in the visible viewport
(indent-guide-remove win-start win-end)
;; decide line-col, line-start
(save-excursion
(indent-guide--beginning-of-level)
@@ -313,32 +324,41 @@ the point. When no such points are found, just return nil."
(indent-guide--make-overlay (+ line-start tmp) line-col line-start line-end))
(remove-overlays (point) (point) 'category 'indent-guide)))))
(defun indent-guide-remove ()
(dolist (ov (indent-guide--active-overlays))
(delete-overlay ov)))
;; use built-in `remove-overlays'
(defun indent-guide-remove (&optional beg end)
"Remove indent-guide overlays between BEG and END.
Defaults to the whole buffer if not provided."
(remove-overlays (or beg (point-min)) (or end (point-max))
'category 'indent-guide))
;; * minor-mode
(defun indent-guide-post-command-hook ()
(if (null indent-guide-delay)
(indent-guide-show)
(when (null indent-guide--timer-object)
(setq indent-guide--timer-object
(run-with-idle-timer indent-guide-delay nil
(lambda ()
(indent-guide-show)
(setq indent-guide--timer-object nil)))))))
;; use named function to prevent a lambda closure being
;; allocated repeatedly on every debounce
(defun indent-guide--run-timer ()
(indent-guide-show)
(setq indent-guide--timer-object nil))
;;; NOTE(arka): root cause of flickering effect. we don't actually need
;;; pre-hook to redraw guides on each command.
;;; pre-hook to redraw guides on each command.
;; (defun indent-guide-pre-command-hook ()
;; ;; some commands' behavior may affected by indent-guide overlays, so
;; ;; remove all overlays in pre-command-hook.
;; (indent-guide-remove))
;;; NOTE(arka): fn to fix flickering effect when scrolling.
(defun indent-guide--window-scroll-hook (&rest _)
(indent-guide-show))
;; Note(vmargb): the timer now behaves like a proper `debounce'
;; every new command cancels the old idle timer and schedules a new one
;; so `indent-guide-show' only runs after the user has paused, not after
;; the first command in a burst.
;; Used by both hooks: `post-command-hook' & `window-scroll-functions'.
(defun indent-guide--request-show (&rest _)
(if (null indent-guide-delay)
(indent-guide-show) ; no delay, show immediately
(when indent-guide--timer-object ; is delay, so cancel/debounce
(cancel-timer indent-guide--timer-object))
(setq indent-guide--timer-object ; schedule new timer
(run-with-idle-timer indent-guide-delay nil
#'indent-guide--run-timer))))
;;;###autoload
(define-minor-mode indent-guide-mode
@@ -349,10 +369,10 @@ the point. When no such points are found, just return nil."
(if indent-guide-mode
(progn
;;; NOTE(arka): only use post-hook. pre-hook is now depricated
(add-hook 'post-command-hook 'indent-guide-post-command-hook nil t)
(add-hook 'window-scroll-functions 'indent-guide--window-scroll-hook nil t))
(remove-hook 'post-command-hook 'indent-guide-post-command-hook t)
(remove-hook 'window-scroll-functions 'indent-guide--window-scroll-hook t)))
(add-hook 'post-command-hook 'indent-guide--request-show nil t)
(add-hook 'window-scroll-functions 'indent-guide--request-show nil t))
(remove-hook 'post-command-hook 'indent-guide--request-show t)
(remove-hook 'window-scroll-functions 'indent-guide--request-show t)))
;;;###autoload
(define-globalized-minor-mode indent-guide-global-mode