emacs-diffs
[Top][All Lists]
Advanced

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

master f9a22cf78d: Fixes in prog-fill-reindent-defun


From: Juri Linkov
Subject: master f9a22cf78d: Fixes in prog-fill-reindent-defun
Date: Wed, 28 Dec 2022 12:22:22 -0500 (EST)

branch: master
commit f9a22cf78d1a7f6472b09c3046c6a7f6984bc2d2
Author: Theodor Thornhill <theo@thornhill.no>
Commit: Juri Linkov <juri@linkov.net>

    Fixes in prog-fill-reindent-defun
    
    Ensure that we don't consider lines such as
    
        switch (foo) {
            case 2:  // If point on 'c' in 'case'
                return 2;
    
    not to be considered for filling.
    
    Also make sure we check for the active region, to replicate the normal
    fill-paragraph behavior.
    
    * lisp/progmodes/prog-mode.el (prog-fill-reindent-defun): Adjust
    regex, and make sure fill-paragraph checks for active region.
    
    (bug#60360, bug#60322)
---
 lisp/progmodes/prog-mode.el | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index aa37a4ac86..5e692980b2 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -164,10 +164,8 @@ or follows point."
                  (treesit-node-type (treesit-node-at (point)))))))
       (if (or treesit-text-node
               (nth 8 (syntax-ppss))
-              (re-search-forward comment-start-skip (line-end-position) t))
-          (if (memq fill-paragraph-function '(t nil))
-              (lisp-fill-paragraph argument)
-            (funcall fill-paragraph-function argument))
+              (re-search-forward "^\\s<" (line-end-position) t))
+          (fill-paragraph argument (region-active-p))
         (beginning-of-defun)
         (let ((start (point)))
           (end-of-defun)



reply via email to

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