emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r108162: * lisp/vc/log-edit.el: Add G


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r108162: * lisp/vc/log-edit.el: Add GNU coding standards highlighting.
Date: Tue, 08 May 2012 11:19:18 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 108162
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Tue 2012-05-08 11:19:18 -0400
message:
  * lisp/vc/log-edit.el: Add GNU coding standards highlighting.
  (log-edit-font-lock-gnu-style)
  (log-edit-font-lock-gnu-keywords): New vars.
  (log-edit-font-lock-keywords): New fun.
  (log-edit-mode): Don't fold case in font-lock.
  (log-edit-font-lock-keywords): Do not assume case-folding.
  * .dir-locals.el (log-edit-mode): Enable gnu-style checks.
modified:
  .dir-locals.el
  ChangeLog
  lisp/ChangeLog
  lisp/vc/log-edit.el
=== modified file '.dir-locals.el'
--- a/.dir-locals.el    2011-09-19 08:26:50 +0000
+++ b/.dir-locals.el    2012-05-08 15:19:18 +0000
@@ -5,7 +5,8 @@
  ;; You must set bugtracker_debbugs_url in your bazaar.conf for this to work.
  ;; See admin/notes/bugtracker.
  (log-edit-mode . ((log-edit-rewrite-fixes
-                    "[ \n](bug#\\([0-9]+\\))" . "debbugs:\\1")))
+                    "[ \n](bug#\\([0-9]+\\))" . "debbugs:\\1")
+                   (log-edit-font-lock-gnu-style . t)))
  (change-log-mode . ((add-log-time-zone-rule . t)
                     (fill-column . 74)
                     (bug-reference-url-format . "http://debbugs.gnu.org/%s";)

=== modified file 'ChangeLog'
--- a/ChangeLog 2012-05-08 07:18:18 +0000
+++ b/ChangeLog 2012-05-08 15:19:18 +0000
@@ -1,3 +1,7 @@
+2012-05-08  Stefan Monnier  <address@hidden>
+
+       * .dir-locals.el (log-edit-mode): Enable gnu-style checks.
+
 2012-05-08  Glenn Morris  <address@hidden>
 
        * make-dist: No more doc/lispref/*.el.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-05-08 14:19:08 +0000
+++ b/lisp/ChangeLog    2012-05-08 15:19:18 +0000
@@ -1,5 +1,12 @@
 2012-05-08  Stefan Monnier  <address@hidden>
 
+       * vc/log-edit.el: Add GNU coding standards highlighting.
+       (log-edit-font-lock-gnu-style)
+       (log-edit-font-lock-gnu-keywords): New vars.
+       (log-edit-font-lock-keywords): New fun.
+       (log-edit-mode): Don't fold case in font-lock.
+       (log-edit-font-lock-keywords): Do not assume case-folding.
+
        * imenu.el: Misc cleanup.  Make docstrings out of comments.
        Use lexical-binding.
        (imenu--index-alist, imenu--last-menubar-index-alist)

=== modified file 'lisp/vc/log-edit.el'
--- a/lisp/vc/log-edit.el       2012-04-09 13:05:48 +0000
+++ b/lisp/vc/log-edit.el       2012-05-08 15:19:18 +0000
@@ -349,7 +349,7 @@
 (defvar log-edit-font-lock-keywords
   ;; Copied/inspired by message-font-lock-keywords.
   `((log-edit-match-to-eoh
-     (,(concat "^\\(\\([a-z]+\\):\\)" log-edit-header-contents-regexp)
+     (,(concat "^\\(\\([[:alpha:]]+\\):\\)" log-edit-header-contents-regexp)
       (progn (goto-char (match-beginning 0)) (match-end 0)) nil
       (1 (if (assoc (match-string 2) log-edit-headers-alist)
              'log-edit-header
@@ -360,6 +360,48 @@
              'log-edit-header)
          nil lax)))))
 
+(defvar log-edit-font-lock-gnu-style nil
+  "If non-nil, highlight common failures to follow the GNU coding standards.")
+(put 'log-edit-font-lock-gnu-style 'safe-local-variable 'booleanp)
+
+(defconst log-edit-font-lock-gnu-keywords
+    ;; Use
+    ;;   * foo.el (bla, bli)
+    ;;   (blo, blu): Toto.
+    ;; Rather than
+    ;;   * foo.el (bla, bli,
+    ;;   blo, blu): Toto.
+  '(("^[ \t]*\\(?:\\* .*\\)?\\(([^\n)]*,\\s-*\\)$"
+     (1 '(face font-lock-warning-face
+          help-echo "Continue function lists with \")\\n(\".") t))
+    ;; Don't leave a lone word on a single line.
+    ;;("^\\s-*\\(\\S-*[^\n:)]\\)\\s-*$" (1 font-lock-warning-face t))
+    ;; Don't cut a sentence right after the first word (better to move
+    ;; the sentence on the next line, then).
+    ;;("[.:]\\s-+\\(\\sw+\\)\\s-*$" (1 font-lock-warning-face t))
+    ;; Change Log entries should use present tense.
+    ("):[ \t\n]*[[:alpha:]]+\\(ed\\)\\>"
+     (1 '(face font-lock-warning-face help-echo "Use present tense.") t))
+    ;; Change log entries start with a capital letter.
+    ("): [a-z]" (0 '(face font-lock-warning-face help-echo "Capitalize.") t))
+    ("[^[:upper:]]\\(\\. [[:upper:]]\\)"
+     (1 '(face font-lock-warning-face
+          help-echo "Use two spaces to end a sentence") t))
+    ("^("
+     (0 (let ((beg (max (point-min) (- (match-beginning 0) 2))))
+          (put-text-property beg (match-end 0) 'font-lock-multiline t)
+          (if (eq (char-syntax (char-after beg)) ?w)
+              '(face font-lock-warning-face
+                help-echo "Punctuate previous line.")))
+        t))
+    ))
+
+(defun log-edit-font-lock-keywords ()
+  (if log-edit-font-lock-gnu-style
+      (append log-edit-font-lock-keywords
+              log-edit-font-lock-gnu-keywords)
+    log-edit-font-lock-keywords))
+
 ;;;###autoload
 (defun log-edit (callback &optional setup params buffer mode &rest _ignore)
   "Setup a buffer to enter a log message.
@@ -416,7 +458,7 @@
 
 \\{log-edit-mode-map}"
   (set (make-local-variable 'font-lock-defaults)
-       '(log-edit-font-lock-keywords t t))
+       '(log-edit-font-lock-keywords t))
   (make-local-variable 'log-edit-comment-ring-index)
   (hack-dir-local-variables-non-file-buffer))
 


reply via email to

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