[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
add-log.el
From: |
Karl Chen |
Subject: |
add-log.el |
Date: |
Fri, 28 Oct 2005 04:16:06 -0700 |
I'd like to use change-log-mode in ChangeLog files outside of the
Emacs project. What do you think of these changes?
(And should the variables indent-tabs-mode, tab-always-indent
really be set by add-log.el?)
2005-10-28 Karl Chen <address@hidden>
* add-log.el (add-log-indent-text): Document as a defcustom.
(change-log-bullet): New face for bullets.
(change-log-font-lock-keywords): Fontify bullets; recognize
bullets other than *. Don't fontify entries not in the "filename
(function):" format.
(change-log--file-match): New temporary variable used by above.
--- add-log.el (revision 8993)
+++ add-log.el (working copy)
@@ -166,6 +166,12 @@
:type '(repeat regexp)
:group 'change-log)
+(defcustom add-log-indent-text 0
+ "*How many spaces to indent subsequent lines in a change entry."
+ :version "21.1"
+ :type 'integer
+ :group 'change-log)
+
(defface change-log-date
'((t (:inherit font-lock-string-face)))
"Face used to highlight dates in date lines."
@@ -190,6 +196,12 @@
;; backward-compatibility alias
(put 'change-log-email-face 'face-alias 'change-log-email)
+(defface change-log-bullet
+ '((t (:inherit font-lock-preprocessor-face)))
+ "Face for highlighting bullets."
+ :version "21.4"
+ :group 'change-log)
+
(defface change-log-file
'((t (:inherit font-lock-function-name-face)))
"Face for highlighting file names."
@@ -230,6 +242,9 @@
;; backward-compatibility alias
(put 'change-log-acknowledgement-face 'face-alias 'change-log-acknowledgement)
+(defvar change-log--file-match nil
+ "Temporary variable internal to change-log font-lock code.")
+
(defvar change-log-font-lock-keywords
'(;;
;; Date lines, new (2000-01-01) and old (Sat Jan 1 00:00:00 2000) styles.
@@ -244,16 +259,45 @@
(1 'change-log-name)
(2 'change-log-email)))
;;
- ;; File names.
- ("^\\( +\\|\t\\)\\* \\([^ ,:([\n]+\\)"
- (2 'change-log-file)
+ ;; Change entries
+ ("^\\( +\\|\t\\)\\([*-•]\\) "
+ (2 'change-log-bullet)
+
+ ;; File name
+ ("\\=\\([^ ,:([\n]+\\)" nil
+ ;; this actually saves the beginning of the expression since it's
+ ;; evaluated on the previous match data
+ (setq change-log--file-match (match-end 0))
+ (1 'change-log-file))
+
;; Possibly further names in a list:
- ("\\=, \\([^ ,:([\n]+\\)" nil nil (1 'change-log-file))
+ ("\\=, *\\([^ ,:([\n]+\\)" nil nil (1 'change-log-file))
;; Possibly a parenthesized list of names:
("\\= (\\([^(),\n]+\\|(\\(setf\\|SETF\\) [^() ,\n]+)\\)"
nil nil (1 'change-log-list))
("\\=, *\\([^(),\n]+\\|(\\(setf\\|SETF\\) [^() ,\n]+)\\)"
- nil nil (1 'change-log-list)))
+ nil nil (1 'change-log-list))
+
+ ("\\=)" nil nil)
+
+ ((lambda (x)
+ (prog1
+ (if change-log--file-match
+ (prog1
+ (if (looking-at ":")
+ nil
+ ;; We didn't find a colon, so this is not in the format
+ ;; "* filename (function): ". Undo the fontification of
+ ;; the first word.
+ (set-match-data (list change-log--file-match (point)))
+ t)
+ (setq change-log--file-match nil)))
+ (forward-char 1)))
+ nil nil
+ (0 'normal t))
+
+ )
+
;;
;; Function or variable names.
("^\\( +\\|\t\\)(\\([^(),\n]+\\|(\\(setf\\|SETF\\) [^() ,\n]+)\\)"
@@ -646,8 +690,6 @@
(add-change-log-entry whoami file-name t))
;;;###autoload (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
-(defvar add-log-indent-text 0)
-
(defun add-log-indent ()
(let* ((indent
(save-excursion
@@ -659,7 +701,7 @@
;; but I'll get it has at least two adjacent digits.
(string-match "[[:digit:]][[:digit:]]" (match-string 1)))
0)
- ((looking-at "[^*(]")
+ ((looking-at "[^*-•(]")
(+ (current-left-margin) add-log-indent-text))
(t (current-left-margin)))))
(pos (save-excursion (indent-line-to indent) (point))))
--
Karl 2005-10-28 04:06