[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/indent-bars ebf1c637e8 425/431: Implement indent-bars.e
From: |
ELPA Syncer |
Subject: |
[elpa] externals/indent-bars ebf1c637e8 425/431: Implement indent-bars.el suggestions for inclusion in ELPA |
Date: |
Mon, 16 Sep 2024 12:59:58 -0400 (EDT) |
branch: externals/indent-bars
commit ebf1c637e83415b0972f8d19fa23f44e1683144d
Author: Philip Kaludercic <philipk@posteo.net>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
Implement indent-bars.el suggestions for inclusion in ELPA
---
indent-bars.el | 115 ++++++++++++++++++++++++++++-----------------------------
1 file changed, 56 insertions(+), 59 deletions(-)
diff --git a/indent-bars.el b/indent-bars.el
index 2e4d6477ee..c6fb77f66d 100644
--- a/indent-bars.el
+++ b/indent-bars.el
@@ -3,11 +3,9 @@
;; Author: J.D. Smith
;; Homepage: https://github.com/jdtsmith/indent-bars
-;; Package-Requires: ((emacs "27.1") (compat "29.1.4.5"))
+;; Package-Requires: ((emacs "27.1") (compat "29.1"))
;; Version: 0.7.1
;; Keywords: convenience
-;; Prefix: indent-bars
-;; Separator: -
;; indent-bars is free software: you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
@@ -34,7 +32,7 @@
;; uses vertical bar characters instead of stipple patterns. Optional
;; treesitter support is also available; see indent-bars-ts.el.
-;; For Developers:
+;;;; For Developers:
;;
;; To efficiently accommodate simultaneous alternative bar styling, we
;; do two things:
@@ -434,7 +432,7 @@ specifies using character bars exclusively. See
(defcustom indent-bars-no-stipple-char ?\│
"Character to display when stipple is unavailable (as in the terminal)."
- :type 'char
+ :type 'character
:set #'indent-bars--custom-set
:group 'indent-bars)
@@ -518,26 +516,25 @@ returned."
((not (numberp b)) t)
((not (numberp a)) nil)
(t (< a b))))
- (delq nil
- (seq-map
- (lambda (x)
- (let ((n (symbol-name x)))
- (if (string-match regexp n)
- (cons (string-to-number (match-string 1
n))
- x))))
- (face-list))))))
+ (mapcan
+ (lambda (x)
+ (let ((n (symbol-name x)))
+ (if (string-match regexp n)
+ (list (cons (string-to-number (match-string 1
n))
+ x)))))
+ (face-list)))))
(defun indent-bars--unpack-palette (palette)
"Process a face or color-based PALETTE."
- (delq nil
- (cl-loop for el in palette
- collect (cond
- ((and (consp el) (facep (car el)))
- (face-background (car el)))
- ((facep el)
- (face-foreground el))
- ((color-defined-p el) el)
- (t nil)))))
+ (cl-loop for el in palette
+ when (cond
+ ((and (consp el) (facep (car el)))
+ (face-background (car el)))
+ ((facep el)
+ (face-foreground el))
+ ((color-defined-p el) el))
+ collect it))
+
;;;; Style
(defvar indent-bars-style nil
"The `indent-bars-style' struct for the main style.")
@@ -679,9 +676,9 @@ See `indent-bars-highlight-current-depth' for
configuration."
"Return the color appropriate for indentation DEPTH in STYLE.
If CURRENT-HIGHLIGHT is non-nil, return the appropriate highlight
color, if setup (see `indent-bars-highlight-current-depth')."
- (let* ((palette (or (and current-highlight
- (ibs/current-depth-palette style))
- (ibs/depth-palette style))))
+ (let ((palette (or (and current-highlight
+ (ibs/current-depth-palette style))
+ (ibs/depth-palette style))))
(cond
((vectorp palette)
(aref palette (mod (1- depth) (length palette))))
@@ -878,8 +875,8 @@ returned."
"Reset all styles' colors and faces.
Useful for calling after theme changes."
(interactive)
- (dolist (s indent-bars--styles)
- (indent-bars--initialize-style s)))
+ (mapc #'indent-bars--initialize-style
+ indent-bars--styles))
(defun indent-bars--initialize-style (style)
"Initialize STYLE."
@@ -924,16 +921,15 @@ Note that the first bar is expected at
`indent-bars-starting-column'."
(defun indent-bars--context-depth ()
"Return the maximum `current-indentation' around current line.
Skips any fully blank lines."
- (let (b (p (point)))
- (beginning-of-line)
- (skip-chars-backward "[:space:]\n")
- (setq b (current-indentation))
- (goto-char p)
- (forward-line 1)
- (skip-chars-forward "[:space:]\n")
- (prog1
- (max (current-indentation) b)
- (goto-char p))))
+ (let ((prior-indent
+ (save-excursion
+ (beginning-of-line)
+ (skip-chars-backward "[:space:]\n")
+ (current-indentation))))
+ (save-excursion
+ (forward-line 1)
+ (skip-chars-forward "[:space:]\n")
+ (max (current-indentation) prior-indent))))
(defvar-local indent-bars--update-depth-function nil)
(defvar-local indent-bars--ppss nil)
@@ -1045,10 +1041,10 @@ properties to existing non-tab whitespace), bars will be
in this case) expected to be located at END, will have its
display properties set to fill out the remaining bars, if any are
needed."
- (let* ((tabs (when (and indent-tabs-mode
- (save-excursion
- (goto-char start) (looking-at "^\t+")))
- (- (match-end 0) (match-beginning 0))))
+ (let* ((tabs (and indent-tabs-mode
+ (save-excursion
+ (goto-char start) (looking-at "^\t+"))
+ (- (match-end 0) (match-beginning 0))))
(vp indent-bars--offset)
(style (or style indent-bars-style))
(bar 1) prop fun tnum bars-drawn)
@@ -1077,21 +1073,21 @@ needed."
(prog1
(if (> switch-after 0) style style2)
(cl-decf switch-after)
- (if (<= switch-after 0)
- (setq switch-after t))))
+ (when (<= switch-after 0)
+ (setq switch-after t))))
((eq switch-after t) style2)
(t style))
bar))
(cl-incf bar)
(cl-incf pos indent-bars-spacing))
;; STILL bars to show: invent them (if requested)
- (if (and invent (<= bar nbars))
- (put-text-property
- end (1+ end) 'indent-bars-display
- (concat (indent-bars--blank-string
- style (- pos end) (- nbars bar -1) bar nil
- switch-after style2)
- "\n")))))))
+ (when (and invent (<= bar nbars))
+ (put-text-property
+ end (1+ end) 'indent-bars-display
+ (concat (indent-bars--blank-string
+ style (- pos end) (- nbars bar -1) bar nil
+ switch-after style2)
+ "\n")))))))
(defsubst indent-bars--context-bars (end)
"Maximum number of bars at point and END.
@@ -1109,8 +1105,8 @@ passed, uses `indent-bars-style' for drawing."
(let ((n (save-excursion
(goto-char beg)
(indent-bars--current-indentation-depth))))
- (when (> n 0) (indent-bars--draw-line style n beg end nil
- switch-after style2))))
+ (and (> n 0) (indent-bars--draw-line style n beg end nil
+ switch-after style2))))
(defun indent-bars--display-blank-lines (beg end &optional style switch-after
style2)
"Display the appropriate bars over the blank-only lines from BEG..END.
@@ -1165,9 +1161,10 @@ the dynamic variables `jit-lock-start' and
`jit-lock-end'."
(cons start end))
(defvar-local indent-bars--display-function
- 'indent-bars--display)
+ #'indent-bars--display)
(defvar-local indent-bars--display-blank-lines-function
- 'indent-bars--display-blank-lines)
+ #'indent-bars--display-blank-lines)
+
(defun indent-bars--draw-all-bars-between (start end)
"Search for and draw all bars between START and END.
The beginning of line at START is used to locate real and (if
@@ -1252,9 +1249,9 @@ greater than zero."
(defun indent-bars--update-current-depth-highlight-in-buffer (buf depth)
"Highlight bar at DEPTH in buffer BUF."
- (if (buffer-live-p buf)
- (with-current-buffer buf
- (indent-bars--update-current-depth-highlight depth))))
+ (when (buffer-live-p buf)
+ (with-current-buffer buf
+ (indent-bars--update-current-depth-highlight depth))))
(defun indent-bars--highlight-current-depth (&optional force)
"Refresh current indentation depth highlight.
@@ -1696,8 +1693,8 @@ Adapted from `highlight-indentation-mode'."
(indent-bars-teardown)))
;; Theme support
-(if (boundp 'enable-theme-functions)
- (add-hook 'enable-theme-functions #'indent-bars-reset-styles))
+(when (boundp 'enable-theme-functions)
+ (add-hook 'enable-theme-functions #'indent-bars-reset-styles))
(provide 'indent-bars)
- [elpa] externals/indent-bars 2ca5192273 372/431: Update README.md, (continued)
- [elpa] externals/indent-bars 2ca5192273 372/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars b433467d57 376/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars e693dd5239 409/431: teardown: avoid buffer modification, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 7cf880d7cd 391/431: Reduce default bar blend, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 075e1b3ccc 400/431: ts: fix font-lock-fontify-buffer-function save logic, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars eca496b2db 392/431: improve commentary, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars dc44a8e889 404/431: Merge branch 'main' into dev, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars fc8f492364 397/431: indent-bars-ts: improve commentary, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 86835d8faa 402/431: ts--context-fontify: use with-silent-modifications, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 6f6915dec4 411/431: Add Ada and GPR support., ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars ebf1c637e8 425/431: Implement indent-bars.el suggestions for inclusion in ELPA,
ELPA Syncer <=
- [elpa] externals/indent-bars ceb3dd1e31 418/431: guess-spacing: add typescript-ts-mode support, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 188d8540bf 395/431: Update ts--context-fontify to work in all buffers, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 7c7a7a7a10 423/431: improve commentary, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 6868e36bea 417/431: Protect against no wrap context node, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars f926ed81ae 424/431: Bump version and mention what's new, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars aac2e73b00 428/431: Merge pull request #57 from paaguti/main, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars c2240b7f10 001/431: Initial commit, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 0de108e783 017/431: improve setup/teardown and add reset command, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 940a56c434 016/431: Use 'face instead of 'font-lock-face, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars ee50054337 025/431: Comment, ELPA Syncer, 2024/09/16