emacs-devel
[Top][All Lists]
Advanced

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

Re: add-change-log-entry


From: martin rudalics
Subject: Re: add-change-log-entry
Date: Fri, 20 Jul 2007 10:27:44 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

 > It is not clean to make this work in font-lock mode only.

Agreed.

 > It is worth a bit more complexity to make the code work in
 > all cases.  And it is also more modular not to depend on
 > what font-lock does for this mode.

I moved the stuff away from `after-change-functions' _and_ font-lock
mode.  Could people please try whether it works as intended.

*** add-log.el  Wed Jul 18 20:19:46 2007
--- add-log.el  Fri Jul 20 10:26:14 2007
***************
*** 665,670 ****
--- 665,713 ----
  (defvar change-log-indent-text 0)
  
  (defun change-log-indent ()
+   ;; The following form is an attempt to split parenthesized lists
+   ;; correctly with (auto-)filling.  For example, an overlong line
+   ;;
+   ;; * file-name.ext (very-long-foo, very-long-bar, very-long-foobar):
+   ;;
+   ;; should be now broken as
+   ;;
+   ;; * file-name.ext (very-long-foo, very-long-bar)
+   ;; (very-long-foobar):
+   ;;
+   ;; instead of
+   ;; 
+   ;; * file-name.ext (very-long-foo, very-long-bar,
+   ;; very-long-foobar):
+   ;;
+   ;; because fontification doesn't like the latter.
+   (save-excursion
+     (end-of-line 0)
+     (skip-chars-backward " \t")
+     (when (and (equal (char-before) ?\,)
+              (> (point) (1+ (point-min))))
+       (condition-case nil
+         (when (save-excursion
+                 (and (prog2
+                          (up-list -1)
+                          (equal (char-after) ?\()
+                        (skip-chars-backward " \t"))
+                      (or (bolp)
+                          ;; Skip everything but a whitespace or asterisk.
+                          (and (not (zerop (skip-chars-backward "^ \t\n*")))
+                               (skip-chars-backward " \t")
+                               ;; We want one asterisk here.
+                               (= (skip-chars-backward "*") -1)
+                               (skip-chars-backward " \t")
+                               (bolp)))))
+           ;; Delete the comma.
+           (delete-char -1)
+           ;; Close list on previous line.
+           (insert ")")
+           (skip-chars-forward " \t\n")
+           ;; Start list on new line.
+           (insert-before-markers "("))
+       (error nil))))
    (let* ((indent
          (save-excursion
            (beginning-of-line)
***************
*** 681,687 ****
         (pos (save-excursion (indent-line-to indent) (point))))
      (if (> pos (point)) (goto-char pos))))
  
- 
  (defvar smerge-resolve-function)
  
  ;;;###autoload
--- 724,729 ----
***************
*** 732,738 ****
    (interactive "P")
    (let ((end (progn (forward-paragraph) (point)))
        (beg (progn (backward-paragraph) (point)))
!       (paragraph-start (concat paragraph-start "\\|\\s *\\s(")))
      (fill-region beg end justify)
      t))
  
--- 774,783 ----
    (interactive "P")
    (let ((end (progn (forward-paragraph) (point)))
        (beg (progn (backward-paragraph) (point)))
!       ;; Added lines starting with asterisk.
!       (paragraph-start (concat paragraph-start "\\|\\s *\\(?:\\s(\\|\\*\\)"))
!       ;; Make sure we call `change-log-indent'.
!       (fill-indent-according-to-mode t))
      (fill-region beg end justify)
      t))
  

reply via email to

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