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

* Re: add-log.el
  2005-10-28 11:16 add-log.el Karl Chen
@ 2005-10-28 12:28 ` Miles Bader
  2005-10-28 13:16   ` add-log.el Karl Chen
  2005-10-29  5:13   ` add-log.el Richard M. Stallman
  0 siblings, 2 replies; 6+ messages in thread
From: Miles Bader @ 2005-10-28 12:28 UTC (permalink / raw)
  Cc: Emacs Developement List

2005/10/28, Karl Chen <quarl@cs.berkeley.edu>:
> +(defcustom add-log-indent-text 0
> +  "*How many spaces to indent subsequent lines in a change entry."

It doesn't seem correct to set this sort of parameter using defcustom
-- the proper value depends on the _file_ not the user.

What about making a derived-mode that derives from change-log-mode and
overrides only that one parameter?

-miles
--
Do not taunt Happy Fun Ball.

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

* Re: add-log.el
  2005-10-28 12:28 ` add-log.el Miles Bader
@ 2005-10-28 13:16   ` Karl Chen
  2005-10-28 13:28     ` add-log.el Karl Chen
  2005-10-29  5:13   ` add-log.el Richard M. Stallman
  1 sibling, 1 reply; 6+ messages in thread
From: Karl Chen @ 2005-10-28 13:16 UTC (permalink / raw)
  Cc: Emacs Developement List, miles

>>>>> On 2005-10-28 05:28 PDT, Miles Bader writes:

    Miles> 2005/10/28, Karl Chen <quarl@cs.berkeley.edu>:
    >> +(defcustom add-log-indent-text 0
    >> + "*How many spaces to indent subsequent lines in a change
    >>    entry."

    Miles> It doesn't seem correct to set this sort of parameter
    Miles> using defcustom -- the proper value depends on the
    Miles> _file_ not the user.

I don't disagree.  Defvar would be fine too.  It previously wasn't
documented.

However I would like to point out that this isn't any different
from other "style" parameters such as c-basic-offset,
python-indent, tab-width, etc., which are all customizable.  They
can also be file local variables or automatically inferred from
the file.

    Miles> What about making a derived-mode that derives from
    Miles> change-log-mode and overrides only that one parameter?

Not sure what you mean?  I don't have any problem with a setq in a
hook.  I actually don't use customize.  I just wanted to document
the variable.


-- 
Karl 2005-10-28 06:07

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

* Re: add-log.el
  2005-10-28 13:16   ` add-log.el Karl Chen
@ 2005-10-28 13:28     ` Karl Chen
  0 siblings, 0 replies; 6+ messages in thread
From: Karl Chen @ 2005-10-28 13:28 UTC (permalink / raw)
  Cc: Emacs Developement List, miles

Now that I think about it, add-log's use of left-margin should be
documented too.  Perhaps 

(defcustom change-log-left-margin 8
 "*Left-margin to use in change-log-mode.")

And

(setq left-margin change-log-left-margin) 


-- 
Karl 2005-10-28 06:26

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

* Re: add-log.el
  2005-10-28 12:28 ` add-log.el Miles Bader
  2005-10-28 13:16   ` add-log.el Karl Chen
@ 2005-10-29  5:13   ` Richard M. Stallman
  1 sibling, 0 replies; 6+ messages in thread
From: Richard M. Stallman @ 2005-10-29  5:13 UTC (permalink / raw)
  Cc: quarl, emacs-devel

    > +(defcustom add-log-indent-text 0
    > +  "*How many spaces to indent subsequent lines in a change entry."

    It doesn't seem correct to set this sort of parameter using defcustom
    -- the proper value depends on the _file_ not the user.

I tend to agree that this should be an ordinary defvar, not a
defcustom.

But there are other variables for which arguably the same thing is the
case: add-log-time-format, and add-log-keep-changes-together.  Should
they be changed to defvars?

The first, perhaps nobody ever thinks of changing.  The second,
perhaps is a matter of personal preference as well as a matter of each
file's convention.

If we leave them as defcustoms, maybe this one should be a defcustom
too, just for regularity.

    What about making a derived-mode that derives from change-log-mode and
    overrides only that one parameter?

That would be much more cumbersome than setting the variable
in an ordinary local variables list.

^ 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).