emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/hl-block-mode e7ab79e713 36/64: Cleanup: add code-sections


From: ELPA Syncer
Subject: [nongnu] elpa/hl-block-mode e7ab79e713 36/64: Cleanup: add code-sections
Date: Thu, 7 Jul 2022 12:00:07 -0400 (EDT)

branch: elpa/hl-block-mode
commit e7ab79e7139e898423eb510d52978fbadcdcf556
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Cleanup: add code-sections
---
 hl-block-mode.el | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/hl-block-mode.el b/hl-block-mode.el
index bcd12f1261..7aea45af68 100644
--- a/hl-block-mode.el
+++ b/hl-block-mode.el
@@ -37,6 +37,10 @@
 
 (require 'seq)
 
+
+;; ---------------------------------------------------------------------------
+;; Custom Variables
+
 (defcustom hl-block-bracket ?{
   "Character to use as a starting bracket (defaults to '{').
 Set to nil to use all brackets."
@@ -58,6 +62,19 @@ Set to nil to use all brackets."
   :group 'hl-block-mode
   :type 'string)
 
+
+;; ---------------------------------------------------------------------------
+;; Internal Variables
+
+(defvar-local hl-block-overlay nil)
+
+;; Global timer.
+(defvar hl-block--delay-timer nil)
+
+
+;; ---------------------------------------------------------------------------
+;; Internal Functions/Macros
+
 (defun hl-block--syntax-prev-bracket (pt)
   "A version of `syntax-ppss' to match curly braces.
 PT is typically the '(point)'."
@@ -92,8 +109,6 @@ PT is typically the '(point)'."
 Inverse of `color-values'."
   (format "#%02x%02x%02x" (ash r -8) (ash g -8) (ash b -8)))
 
-(defvar-local hl-block-overlay nil)
-
 (defun hl-block--overlay-clear ()
   "Clear all overlays."
   (mapc 'delete-overlay hl-block-overlay)
@@ -139,9 +154,6 @@ Inverse of `color-values'."
               (setq end-prev end)))
           (cdr block-list))))))
 
-;; Timer
-(defvar hl-block--delay-timer nil)
-
 (defun hl-block--overlay-refresh-from-timer ()
   "Ensure this mode has not been disabled before highlighting.
 This can happen when switching buffers."
@@ -155,6 +167,10 @@ This can happen when switching buffers."
   (setq hl-block--delay-timer
     (run-with-idle-timer hl-block-delay t 
'hl-block--overlay-refresh-from-timer)))
 
+
+;; ---------------------------------------------------------------------------
+;; Internal Mode Management
+
 (defun hl-block-mode-enable ()
   "Turn on 'hl-block-mode' for the current buffer."
   (add-hook 'post-command-hook #'hl-block--overlay-delay nil t))
@@ -171,6 +187,9 @@ This can happen when switching buffers."
   (when (and (not (minibufferp)) (not (bound-and-true-p hl-block-mode)))
     (hl-block-mode 1)))
 
+;; ---------------------------------------------------------------------------
+;; Public API
+
 ;;;###autoload
 (define-minor-mode hl-block-mode
   "Highlight block under the cursor."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]