update packages and add valign
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
|
||||
;; Author: zk_phi
|
||||
;; URL: http://hins11.yu-yake.com/
|
||||
;; Package-Version: 20210115.400
|
||||
;; Package-Revision: d388c3387781
|
||||
;; Package-Version: 20260211.1005
|
||||
;; Package-Revision: f3455c6c798b
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
(require 'cl-lib)
|
||||
|
||||
(defconst indent-guide-version "2.3.1")
|
||||
(defconst indent-guide-version "2.4")
|
||||
|
||||
;; * customs
|
||||
|
||||
@@ -85,7 +85,17 @@
|
||||
:group 'environment)
|
||||
|
||||
(defcustom indent-guide-char "|"
|
||||
"Character used as vertical line."
|
||||
"Character used for the guide line."
|
||||
:type 'string
|
||||
:group 'indent-guide)
|
||||
|
||||
(defcustom indent-guide-char-top nil
|
||||
"when non-nil, character used for the top of the guide line."
|
||||
:type 'string
|
||||
:group 'indent-guide)
|
||||
|
||||
(defcustom indent-guide-char-bottom nil
|
||||
"when non-nil, character used for the bottom of the guide line."
|
||||
:type 'string
|
||||
:group 'indent-guide)
|
||||
|
||||
@@ -178,9 +188,21 @@ the point. When no such points are found, just return nil."
|
||||
(and (search-backward-regexp regex nil t)
|
||||
(goto-char (match-end 1))))))
|
||||
|
||||
;;; NOTE(arka): custom fn for decorated guide line
|
||||
(defun indent-guide--choose-char (line line-start line-end)
|
||||
"Return the appropriate guide character for LINE."
|
||||
(if (= line-start line-end)
|
||||
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))
|
||||
(t indent-guide-char)))
|
||||
)
|
||||
|
||||
;; * generate guides
|
||||
|
||||
(defun indent-guide--make-overlay (line col)
|
||||
;;; NOTE(arka): extra `line-start` and `line-end` are parameters added for decorated guide line
|
||||
(defun indent-guide--make-overlay (line col line-start line-end)
|
||||
"draw line at (line, col)"
|
||||
(let (diff string ov prop)
|
||||
(save-excursion
|
||||
@@ -204,10 +226,14 @@ the point. When no such points are found, just return nil."
|
||||
(setq string (let ((str (overlay-get ov 'before-string)))
|
||||
(concat str
|
||||
(make-string (- diff (length str)) ?\s)
|
||||
(propertize indent-guide-char 'face 'indent-guide-face)))
|
||||
;;; NOTE(arka): automatic indentaiton guide character selection
|
||||
;;; based on line number count.
|
||||
(propertize (indent-guide--choose-char line line-start line-end)
|
||||
'face 'indent-guide-face)))
|
||||
prop 'before-string)
|
||||
(setq string (concat (make-string diff ?\s)
|
||||
(propertize indent-guide-char 'face 'indent-guide-face))
|
||||
(propertize (indent-guide--choose-char line line-start line-end)
|
||||
'face 'indent-guide-face))
|
||||
prop 'before-string
|
||||
ov (make-overlay (point) (point)))))
|
||||
((< diff 0) ; the column is inside a tab
|
||||
@@ -226,19 +252,22 @@ the point. When no such points are found, just return nil."
|
||||
str)
|
||||
prop 'display)
|
||||
(setq string (concat (make-string (+ tab-width diff) ?\s)
|
||||
(propertize indent-guide-char 'face 'indent-guide-face)
|
||||
(propertize (indent-guide--choose-char line line-start line-end)
|
||||
'face 'indent-guide-face)
|
||||
(make-string (1- (- diff)) ?\s))
|
||||
prop 'display
|
||||
ov (make-overlay (point) (1- (point))))))
|
||||
((looking-at "\t") ; okay but looking at tab
|
||||
;; <-tab-width->
|
||||
;; [|]
|
||||
(setq string (concat (propertize indent-guide-char 'face 'indent-guide-face)
|
||||
(setq string (concat (propertize (indent-guide--choose-char line line-start line-end)
|
||||
'face 'indent-guide-face)
|
||||
(make-string (1- tab-width) ?\s))
|
||||
prop 'display
|
||||
ov (make-overlay (point) (1+ (point)))))
|
||||
(t ; okay and looking at a space
|
||||
(setq string (propertize indent-guide-char 'face 'indent-guide-face)
|
||||
(setq string (propertize (indent-guide--choose-char line line-start line-end)
|
||||
'face 'indent-guide-face)
|
||||
prop 'display
|
||||
ov (make-overlay (point) (1+ (point))))))
|
||||
(when ov
|
||||
@@ -247,8 +276,10 @@ the point. When no such points are found, just return nil."
|
||||
|
||||
(defun indent-guide-show ()
|
||||
(interactive)
|
||||
(unless (or (indent-guide--active-overlays)
|
||||
(active-minibuffer-window))
|
||||
;;; 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)
|
||||
@@ -279,7 +310,7 @@ the point. When no such points are found, just return nil."
|
||||
(setq line-end (line-number-at-pos)))))
|
||||
;; draw line
|
||||
(dotimes (tmp (- (1+ line-end) line-start))
|
||||
(indent-guide--make-overlay (+ line-start tmp) line-col))
|
||||
(indent-guide--make-overlay (+ line-start tmp) line-col line-start line-end))
|
||||
(remove-overlays (point) (point) 'category 'indent-guide)))))
|
||||
|
||||
(defun indent-guide-remove ()
|
||||
@@ -298,10 +329,16 @@ the point. When no such points are found, just return nil."
|
||||
(indent-guide-show)
|
||||
(setq indent-guide--timer-object nil)))))))
|
||||
|
||||
(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): root cause of flickering effect. we don't actually need
|
||||
;;; 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))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode indent-guide-mode
|
||||
@@ -311,10 +348,11 @@ the point. When no such points are found, just return nil."
|
||||
:global nil
|
||||
(if indent-guide-mode
|
||||
(progn
|
||||
(add-hook 'pre-command-hook 'indent-guide-pre-command-hook nil t)
|
||||
(add-hook 'post-command-hook 'indent-guide-post-command-hook nil t))
|
||||
(remove-hook 'pre-command-hook 'indent-guide-pre-command-hook t)
|
||||
(remove-hook 'post-command-hook 'indent-guide-post-command-hook t)))
|
||||
;;; 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)))
|
||||
|
||||
;;;###autoload
|
||||
(define-globalized-minor-mode indent-guide-global-mode
|
||||
|
||||
Reference in New Issue
Block a user