aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2000-09-29 18:03:51 +0000
committerStefan Monnier2000-09-29 18:03:51 +0000
commitd68f7f1b1194516a95f07ad8f2dfea56be533e38 (patch)
tree613f6788fc00228b69c4dbbb9e74fac01c1cd9b2
parent513f1fd931177ab56e13ed85faebdb16dbe8bb78 (diff)
downloademacs-d68f7f1b1194516a95f07ad8f2dfea56be533e38.tar.gz
emacs-d68f7f1b1194516a95f07ad8f2dfea56be533e38.zip
(find-change-log): New arg BUFFER-FILE.
(add-log-file-name): Obey add-log-file-name-function. (add-log-buffer-file-name-function): New var. (add-change-log-entry): Use it.
-rw-r--r--lisp/add-log.el69
1 files changed, 40 insertions, 29 deletions
diff --git a/lisp/add-log.el b/lisp/add-log.el
index 5a137998f5d..e40b691f064 100644
--- a/lisp/add-log.el
+++ b/lisp/add-log.el
@@ -116,6 +116,13 @@ this variable."
116 :type 'boolean 116 :type 'boolean
117 :group 'change-log) 117 :group 'change-log)
118 118
119(defcustom add-log-buffer-file-name-function nil
120 "*If non-nil, function to call to identify the full filename of a buffer.
121This function is called with no argument. If this is nil, the default is to
122use `buffer-file-name'."
123 :type 'function
124 :group 'change-log)
125
119(defcustom add-log-file-name-function nil 126(defcustom add-log-file-name-function nil
120 "*If non-nil, function to call to identify the filename for a ChangeLog entry. 127 "*If non-nil, function to call to identify the filename for a ChangeLog entry.
121This function is called with one argument, the value of variable 128This function is called with one argument, the value of variable
@@ -303,8 +310,7 @@ nil, by matching `change-log-version-number-regexp-list'."
303 (/ size 10) 310 (/ size 10)
304 size)) 311 size))
305 version) 312 version)
306 (or (and buffer-file-name 313 (or (and buffer-file-name (vc-workfile-version buffer-file-name))
307 (vc-workfile-version buffer-file-name))
308 (save-restriction 314 (save-restriction
309 (widen) 315 (widen)
310 (let ((regexps change-log-version-number-regexp-list)) 316 (let ((regexps change-log-version-number-regexp-list))
@@ -317,7 +323,7 @@ nil, by matching `change-log-version-number-regexp-list'."
317 323
318 324
319;;;###autoload 325;;;###autoload
320(defun find-change-log (&optional file-name) 326(defun find-change-log (&optional file-name buffer-file)
321 "Find a change log file for \\[add-change-log-entry] and return the name. 327 "Find a change log file for \\[add-change-log-entry] and return the name.
322 328
323Optional arg FILE-NAME specifies the file to use. 329Optional arg FILE-NAME specifies the file to use.
@@ -330,7 +336,8 @@ simply find it in the current directory. Otherwise, search in the current
330directory and its successive parents for a file so named. 336directory and its successive parents for a file so named.
331 337
332Once a file is found, `change-log-default-name' is set locally in the 338Once a file is found, `change-log-default-name' is set locally in the
333current buffer to the complete file name." 339current buffer to the complete file name.
340Optional arg BUFFER-FILE overrides `buffer-file-name'."
334 ;; If user specified a file name or if this buffer knows which one to use, 341 ;; If user specified a file name or if this buffer knows which one to use,
335 ;; just use that. 342 ;; just use that.
336 (or file-name 343 (or file-name
@@ -340,9 +347,10 @@ current buffer to the complete file name."
340 (progn 347 (progn
341 ;; Chase links in the source file 348 ;; Chase links in the source file
342 ;; and use the change log in the dir where it points. 349 ;; and use the change log in the dir where it points.
343 (setq file-name (or (and buffer-file-name 350 (setq file-name (or (and (or buffer-file buffer-file-name)
344 (file-name-directory 351 (file-name-directory
345 (file-chase-links buffer-file-name))) 352 (file-chase-links
353 (or buffer-file buffer-file-name))))
346 default-directory)) 354 default-directory))
347 (if (file-directory-p file-name) 355 (if (file-directory-p file-name)
348 (setq file-name (expand-file-name (change-log-name) file-name))) 356 (setq file-name (expand-file-name (change-log-name) file-name)))
@@ -376,18 +384,20 @@ current buffer to the complete file name."
376(defun add-log-file-name (buffer-file log-file) 384(defun add-log-file-name (buffer-file log-file)
377 ;; Never want to add a change log entry for the ChangeLog file itself. 385 ;; Never want to add a change log entry for the ChangeLog file itself.
378 (unless (or (null buffer-file) (string= buffer-file log-file)) 386 (unless (or (null buffer-file) (string= buffer-file log-file))
379 (setq buffer-file 387 (if add-log-file-name-function
380 (if (string-match 388 (funcall add-log-file-name-function buffer-file)
381 (concat "^" (regexp-quote (file-name-directory log-file))) 389 (setq buffer-file
382 buffer-file) 390 (if (string-match
383 (substring buffer-file (match-end 0)) 391 (concat "^" (regexp-quote (file-name-directory log-file)))
384 (file-name-nondirectory buffer-file))) 392 buffer-file)
385 ;; If we have a backup file, it's presumably because we're 393 (substring buffer-file (match-end 0))
386 ;; comparing old and new versions (e.g. for deleted 394 (file-name-nondirectory buffer-file)))
387 ;; functions) and we'll want to use the original name. 395 ;; If we have a backup file, it's presumably because we're
388 (if (backup-file-name-p buffer-file) 396 ;; comparing old and new versions (e.g. for deleted
389 (file-name-sans-versions buffer-file) 397 ;; functions) and we'll want to use the original name.
390 buffer-file))) 398 (if (backup-file-name-p buffer-file)
399 (file-name-sans-versions buffer-file)
400 buffer-file))))
391 401
392;;;###autoload 402;;;###autoload
393(defun add-change-log-entry (&optional whoami file-name other-window new-entry) 403(defun add-change-log-entry (&optional whoami file-name other-window new-entry)
@@ -419,17 +429,18 @@ non-nil, otherwise in local time."
419 (setq add-log-mailing-address 429 (setq add-log-mailing-address
420 (read-input "Mailing address: " add-log-mailing-address)))) 430 (read-input "Mailing address: " add-log-mailing-address))))
421 431
422 (setq file-name (expand-file-name (or file-name (find-change-log file-name)))) 432 (let* ((defun (add-log-current-defun))
423 433 (version (and change-log-version-info-enabled
424 (let ((defun (add-log-current-defun)) 434 (change-log-version-number-search)))
425 (version (and change-log-version-info-enabled 435 (buffer-file
426 (change-log-version-number-search))) 436 (expand-file-name (if add-log-buffer-file-name-function
427 ;; Set ENTRY to the file name to use in the new entry. 437 (funcall add-log-buffer-file-name-function)
428 (entry (if buffer-file-name 438 buffer-file-name)))
429 (add-log-file-name buffer-file-name file-name) 439 (file-name (expand-file-name
430 (if add-log-file-name-function 440 (or file-name (find-change-log file-name buffer-file))))
431 (funcall add-log-file-name-function file-name)))) 441 ;; Set ENTRY to the file name to use in the new entry.
432 bound) 442 (entry (add-log-file-name buffer-file file-name))
443 bound)
433 444
434 (if (or (and other-window (not (equal file-name buffer-file-name))) 445 (if (or (and other-window (not (equal file-name buffer-file-name)))
435 (window-dedicated-p (selected-window))) 446 (window-dedicated-p (selected-window)))