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

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

[nongnu] elpa/raku-mode acc516e76d 225/253: Uncomment code blocks in POD


From: ELPA Syncer
Subject: [nongnu] elpa/raku-mode acc516e76d 225/253: Uncomment code blocks in POD.
Date: Sat, 29 Jan 2022 08:29:01 -0500 (EST)

branch: elpa/raku-mode
commit acc516e76d7bf3e30ac0e72c6d29545dedbe09b0
Author: Tim Van den Langenbergh <tmt_vdl@gmx.com>
Commit: Tim Van den Langenbergh <tmt_vdl@gmx.com>

    Uncomment code blocks in POD.
    
    Per @Altai-man's suggestion.
    Note: basic string matching ergo ends code blocks on `=end code`, even when 
in
    a string.
---
 raku-font-lock.el | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/raku-font-lock.el b/raku-font-lock.el
index b39ff7bb4d..880fb30701 100644
--- a/raku-font-lock.el
+++ b/raku-font-lock.el
@@ -372,16 +372,31 @@ opening delimiter."
         (put-text-property (1- (point)) (point)
                            'syntax-table (string-to-syntax ">")))))
 
+(defun raku-syntax-propertize-pod-code-blocks (limit)
+  "Add syntax properties to code blocks in POD."
+  (while (search-forward "=begin code" limit t)
+    (let ((code-beg (point))
+          (code-end (- (search-forward "=end code" limit t)
+                       (length "=end code"))))
+      (put-text-property code-beg (1+ code-beg)
+                         'syntax-table (string-to-syntax ">"))
+      (put-text-property (1- code-end) code-end
+                         'syntax-table (string-to-syntax "<"))
+      (remove-text-properties code-beg code-end '(syntax-multiline nil)))))
+
 (defun raku-syntax-propertize-pod (limit)
   "Add syntax properties to POD."
-  (let ((pod-beg (- (point) (length "=begin pod"))))
-    (put-text-property pod-beg (1+ pod-beg)
-                       'syntax-table (string-to-syntax "<"))
-    (if (re-search-forward "=end pod" limit 'noerror)
-        (let ((pod-end (point)))
-          (put-text-property pod-beg pod-end 'syntax-multiline t)
-          (put-text-property (1- pod-end) pod-end
-                             'syntax-table (string-to-syntax ">"))))))
+  (let ((pod-beg (- (point) (length "=begin pod")))
+        (pod-end (search-forward "=end pod" limit t)))
+    (save-excursion
+      (put-text-property (1- pod-beg) pod-beg
+                         'syntax-table (string-to-syntax "<"))
+      (put-text-property pod-end (1+ pod-end)
+                         'syntax-table (string-to-syntax ">"))
+      (put-text-property pod-beg pod-end
+                         'syntax-multiline t)
+      (goto-char pod-beg)
+      (raku-syntax-propertize-pod-code-blocks pod-end))))
 
 (defun raku-syntax-propertize-angles (open-angles)
   "Add syntax properties to angle-bracketed quotes (e.g. <foo> and «bar»).



reply via email to

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