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

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

[nongnu] elpa/doc-show-inline 4295439062 10/12: Add doc-show-inline-excl


From: ELPA Syncer
Subject: [nongnu] elpa/doc-show-inline 4295439062 10/12: Add doc-show-inline-exclude-blank-lines option
Date: Thu, 7 Jul 2022 11:58:57 -0400 (EDT)

branch: elpa/doc-show-inline
commit 42954390621f281930a70104162db1bb70532a1b
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Add doc-show-inline-exclude-blank-lines option
---
 changelog.rst      |  4 ++++
 doc-show-inline.el | 35 +++++++++++++++++++++++++++++++++++
 readme.rst         |  4 ++++
 3 files changed, 43 insertions(+)

diff --git a/changelog.rst b/changelog.rst
index fc7fb07572..7da0963dc1 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -3,6 +3,10 @@
 Change Log
 ##########
 
+- 2022-03-14
+  - Add option ``doc-show-inline-exclude-blank-lines`` to exclude doc-strings 
with blank lines
+    between the declarations and the doc-strings.
+
 - 2021-12-15
   - Fix error with C/C++ range checking causing an error in font locking.
 
diff --git a/doc-show-inline.el b/doc-show-inline.el
index 9eab0ef53c..139e2c8187 100644
--- a/doc-show-inline.el
+++ b/doc-show-inline.el
@@ -62,6 +62,12 @@ Set to 0.0 to highlight immediately (as part of syntax 
highlighting)."
   "Optionally skip comments that match this regular expression."
   :type '(choice (const nil) (regexp)))
 
+(defcustom doc-show-inline-exclude-blank-lines 0
+  "Optionally skip comments which have blank lines above the declaration.
+Ignore comments that have at least this many blank lines after the doc-string.
+Zero disables."
+  :type 'integer)
+
 (defcustom doc-show-inline-face-background-highlight -0.04
   "Use to tint the background color for overlay text (between -1.0 and 1.0).
 Ignored when `doc-show-inline-face'
@@ -301,6 +307,35 @@ the point should not be moved by this function."
                 (point))
               ;; Skip this comment.
               nil)
+
+            ;; Optionally exclude blank lines between the comment and the 
function definition.
+            (
+              (and
+                ;; Checking blank lines?
+                (not (zerop doc-show-inline-exclude-blank-lines))
+                (let ((blank-lines 0))
+                  (save-excursion
+                    (goto-char pos-end)
+                    ;; It's important the point is at the beginning of the line
+                    ;; so `looking-at-p' works as expected.
+                    (beginning-of-line)
+                    (while
+                      (and
+                        (looking-at-p "[[:blank:]]*$")
+                        (< (setq blank-lines (1+ blank-lines)) 
doc-show-inline-exclude-blank-lines)
+                        (zerop (forward-line -1)))))
+                  (eq blank-lines doc-show-inline-exclude-blank-lines)))
+
+              (doc-show-inline--log-info
+                "comment \"%s\" in %S at point %d was skipped because of at 
least %d blank lines"
+                sym
+                (current-buffer)
+                pos-beg
+                doc-show-inline-exclude-blank-lines)
+
+              ;; Found at least `doc-show-inline-exclude-blank-lines' 
blank-lines, skipping.
+              nil)
+
             ;; Optionally exclude a regexp.
             (
               (and
diff --git a/readme.rst b/readme.rst
index e52a653d96..2fd9408e93 100644
--- a/readme.rst
+++ b/readme.rst
@@ -38,6 +38,10 @@ Customization
 ``doc-show-inline-idle-delay`` (float ``0.75``)
    The idle delay to use before updating doc-strings.
 
+``doc-show-inline-exclude-blank-lines`` (integer ``0``)
+   Exclude doc-strings when there are at least this many blank lines between 
the declaration
+   and the doc-string (zero disables).
+
 ``doc-show-inline-exclude-regexp`` (regexp / nil ``nil``)
    Optionally exclude comments that contain text matching this regular 
expression.
 



reply via email to

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