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

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

[nongnu] elpa/annotate 3108c44c53 123/372: - moving some args checks fro


From: ELPA Syncer
Subject: [nongnu] elpa/annotate 3108c44c53 123/372: - moving some args checks from 'annotate-create-annotation' to
Date: Fri, 4 Feb 2022 16:58:29 -0500 (EST)

branch: elpa/annotate
commit 3108c44c5308f6d26e3cb143bf38cc69e300298a
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>

    - moving  some   args  checks  from   'annotate-create-annotation'  to
      'annotate-annotate' where they do make more sense;
    - fixed variable scoping in a local funcion;
    - expanded a bit a docstring.
---
 annotate.el | 64 ++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 34 insertions(+), 30 deletions(-)

diff --git a/annotate.el b/annotate.el
index 5b5a76d761..170d966018 100644
--- a/annotate.el
+++ b/annotate.el
@@ -278,9 +278,11 @@ modified (for example a newline is inserted)."
       (annotate-change-annotation (point))
       (font-lock-fontify-buffer nil))
      (t
-      (cl-destructuring-bind (start end) (annotate-bounds)
-        (annotate-create-annotation start end nil nil)
-        (font-lock-fontify-block 1))))
+      (cl-destructuring-bind (start end)
+          (annotate-bounds)
+        (let ((annotation-text (read-from-minibuffer "Annotation: ")))
+          (annotate-create-annotation start end annotation-text nil)
+          (font-lock-fontify-block 1)))))
     (set-buffer-modified-p t)))
 
 (defun annotate-next-annotation ()
@@ -986,7 +988,7 @@ essentially what you get from:
   "Create a new annotation for selected region.
 
 Here the argument 'annotation-text' is the string that appears
-in the margin of the window and 'annotated-text' is the string
+on the margin of the window and 'annotated-text' is the string
 that is underlined.
 
 If this function is called from procedure
@@ -1001,11 +1003,15 @@ changed and annotate-mode could not track the
 changes (e.g. save the file when annotate-mode was not
 active/loaded) in this case the matching
 text ('annotated-text') is searched in a region surrounding the
-interval and, if found, the buffer is annotated right there."
+interval and, if found, the buffer is annotated right there.
+
+The searched interval can be customized setting the variable:
+'annotate-search-region-lines-delta'.
+"
   (cl-labels ((create-annotation     (start end annotation-text)
                                      (let ((highlight (make-overlay start 
end)))
                                        (overlay-put highlight 'face 
'annotate-highlight)
-                                       (overlay-put highlight 'annotation 
annotation)))
+                                       (overlay-put highlight 'annotation 
annotation-text)))
               (beginning-of-nth-line (start line-count)
                                      (save-excursion
                                        (goto-char start)
@@ -1032,32 +1038,30 @@ interval and, if found, the buffer is annotated right 
there."
                                              (setf start (1+ start)
                                                    end   (1+ end)))))
                                        nil)))
-    (let ((annotation (or annotation-text
-                          (read-from-minibuffer "Annotation: "))))
-      (when (not (or (null annotation)
-                     (string= "" annotation)))
-        (if (not (annotate-string-empty-p annotated-text))
-            (let ((text-to-match (ignore-errors
-                                   (buffer-substring-no-properties start 
end))))
-              (if (and text-to-match
-                       (string= text-to-match annotated-text))
-                  (create-annotation start end annotation)
-                (let* ((starting-point-matching (go-backward start))
-                       (ending-point-match      (go-forward  start))
-                       (length-match            (- end start))
-                       (new-match               (guess-match-and-add 
starting-point-matching
-                                                                     (+ 
starting-point-matching
-                                                                        
length-match)
-                                                                     
annotated-text
-                                                                     
ending-point-match)))
-                  (and new-match
-                       (create-annotation new-match (+ new-match length-match) 
annotation)))))
-          (create-annotation start end annotation))
-        (when (use-region-p)
-          (deactivate-mark))))
+      (if (not (annotate-string-empty-p annotated-text))
+          (let ((text-to-match (ignore-errors
+                                 (buffer-substring-no-properties start end))))
+            (if (and text-to-match
+                     (string= text-to-match annotated-text))
+                (create-annotation start end annotation-text)
+              (let* ((starting-point-matching (go-backward start))
+                     (ending-point-match      (go-forward  start))
+                     (length-match            (- end start))
+                     (new-match               (guess-match-and-add 
starting-point-matching
+                                                                   (+ 
starting-point-matching
+                                                                      
length-match)
+                                                                   
annotated-text
+                                                                   
ending-point-match)))
+                (and new-match
+                     (create-annotation new-match
+                                        (+ new-match length-match)
+                                        annotation-text)))))
+        (create-annotation start end annotation-text))
+      (when (use-region-p)
+        (deactivate-mark)))
     (save-excursion
       (goto-char end)
-      (font-lock-fontify-block 1))))
+      (font-lock-fontify-block 1)))
 
 (defun annotate-change-annotation (pos)
   "Change annotation at point. If empty, delete annotation."



reply via email to

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