emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-26 b9d7c90: In f90.el, set fill-paragraph-function t


From: Glenn Morris
Subject: [Emacs-diffs] emacs-26 b9d7c90: In f90.el, set fill-paragraph-function to a useful value
Date: Wed, 8 Nov 2017 20:16:48 -0500 (EST)

branch: emacs-26
commit b9d7c902603a49d2624bdd35efdfba1785a4bce5
Author: Glenn Morris <address@hidden>
Commit: Glenn Morris <address@hidden>

    In f90.el, set fill-paragraph-function to a useful value
    
    * lisp/progmodes/f90.el (f90-mode-map) <menu>: Add fill-paragraph.
    (f90-mode): Set fill-paragraph-function.
    (f90-fill-paragraph): New command.
---
 lisp/progmodes/f90.el | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el
index 7215628..0cd665c 100644
--- a/lisp/progmodes/f90.el
+++ b/lisp/progmodes/f90.el
@@ -133,7 +133,7 @@
 ;;   f90-indent-region    (can be called by calling indent-region)
 ;;   f90-indent-subprogram
 ;;   f90-break-line                 f90-join-lines
-;;   f90-fill-region
+;;   f90-fill-region                f90-fill-paragraph
 ;;   f90-insert-end
 ;;   f90-upcase-keywords            f90-upcase-region-keywords
 ;;   f90-downcase-keywords          f90-downcase-region-keywords
@@ -784,6 +784,7 @@ Can be overridden by the value of 
`font-lock-maximum-decoration'.")
         ["Indent Region" f90-indent-region :active mark-active]
         ["Fill Region" f90-fill-region :active mark-active
          :help "Fill long lines in the region"]
+        ["Fill Statement/Comment" fill-paragraph :active t]
         "--"
         ["Break Line at Point" f90-break-line :active t
          :help "Break the current line at point"]
@@ -1185,6 +1186,7 @@ with no args, if that value is non-nil."
   (set (make-local-variable 'abbrev-all-caps) t)
   (set (make-local-variable 'normal-auto-fill-function) 'f90-do-auto-fill)
   (setq indent-tabs-mode nil)           ; auto buffer local
+  (set (make-local-variable 'fill-paragraph-function) 'f90-fill-paragraph)
   (set (make-local-variable 'font-lock-defaults)
        '((f90-font-lock-keywords f90-font-lock-keywords-1
                                  f90-font-lock-keywords-2
@@ -2158,6 +2160,20 @@ Like `join-line', but handles F90 syntax."
     (if (featurep 'xemacs)
         (zmacs-deactivate-region)
       (deactivate-mark))))
+
+(defun f90-fill-paragraph (&optional justify)
+  "In a comment, fill it as a paragraph, else fill the current statement.
+For use as the value of `fill-paragraph-function'.
+Passes optional argument JUSTIFY to `fill-comment-paragraph'.
+Always returns non-nil (to prevent `fill-paragraph' being called)."
+  (interactive "*P")
+  (or (fill-comment-paragraph justify)
+      (save-excursion
+        (f90-next-statement)
+        (let ((end (if (bobp) (point) (1- (point)))))
+          (f90-previous-statement)
+          (f90-fill-region (point) end)))
+      t))
 
 (defconst f90-end-block-optional-name
   '("program" "module" "subroutine" "function" "type")



reply via email to

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