unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* add-log.el
@ 2005-10-28 11:16 Karl Chen
  2005-10-28 12:28 ` add-log.el Miles Bader
  0 siblings, 1 reply; 6+ messages in thread
From: Karl Chen @ 2005-10-28 11:16 UTC (permalink / raw)



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  <quarl@cs.berkeley.edu>

        * 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

^ permalink raw reply	[flat|nested] 6+ messages in thread
* add-log.el
@ 2006-12-16 17:15 Sebastian Rose
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Rose @ 2006-12-16 17:15 UTC (permalink / raw)


Hi there,

pardon me for posting to this group, but after searching for a way to
contact someone who probably feels responsable for add-log.el, I think
this is the place to start.




The problem:

I wrote a small peace of code, that shall hold for add-log.el's
add-log-file-name-function and customized change-log according to this.
Everythting works fine so far.

Unfortunately the code relies on a local variable in add-log.el:

logfile, one of the parameters to add-log-file-name(), that is
originally a local variable in add-change-log-entry().




The Question:

Is there an other way to find out the path and filename of the logfile
the user has choosen?

My add-log.el has no version... but it came with emacs-21.4.1 on my
Debian.

If not - how about using a more global, documented and reliable technic
to achieve this? How about sending patches?




The Code:

mtn-get-parent-directory is a helperfunction, that returns the real name
(no linknames) of the arguments parent directory. The whole of it can be
reviewed at http://venge.net/monotone/wiki/ChangeLog.

--------------------------------------------------------

(defun mtn-add-log-file-name(original-name)
  "Return the filename printed in _MTN/log (or ChangeLog) relative to
the projects root. That is the driectory the file ChangeLog lives in,
if not a monotone project, _MTN/../ otherwise."

  (let ((directory (mtn-get-parent-directory log-file))
        (file (file-truename original-name)))

    (if (string= change-log-default-name "log")
        ;; monotone
        (let ((directory  (mtn-get-parent-directory directory)))
          (file-relative-name file directory))
      ;; else no monotone:
      (file-relative-name file directory))))

--------------------------------------------------------


-- 
Sebastian Rose <sebastian_rose@gmx.de>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-12-16 17:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-28 11:16 add-log.el Karl Chen
2005-10-28 12:28 ` add-log.el Miles Bader
2005-10-28 13:16   ` add-log.el Karl Chen
2005-10-28 13:28     ` add-log.el Karl Chen
2005-10-29  5:13   ` add-log.el Richard M. Stallman
  -- strict thread matches above, loose matches on Subject: below --
2006-12-16 17:15 add-log.el Sebastian Rose

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).