diff options
| -rw-r--r-- | lisp/add-log.el | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/lisp/add-log.el b/lisp/add-log.el index 0d253614945..baed50419ee 100644 --- a/lisp/add-log.el +++ b/lisp/add-log.el | |||
| @@ -326,6 +326,22 @@ current buffer to the complete file name." | |||
| 326 | (set (make-local-variable 'change-log-default-name) file-name) | 326 | (set (make-local-variable 'change-log-default-name) file-name) |
| 327 | file-name) | 327 | file-name) |
| 328 | 328 | ||
| 329 | (defun add-log-file-name (buffer-file log-file) | ||
| 330 | ;; Never want to add a change log entry for the ChangeLog file itself. | ||
| 331 | (unless (or (null buffer-file) (string= buffer-file log-file)) | ||
| 332 | (setq buffer-file | ||
| 333 | (if (string-match | ||
| 334 | (concat "^" (regexp-quote (file-name-directory log-file))) | ||
| 335 | buffer-file) | ||
| 336 | (substring buffer-file (match-end 0)) | ||
| 337 | (file-name-nondirectory buffer-file))) | ||
| 338 | ;; If we have a backup file, it's presumably because we're | ||
| 339 | ;; comparing old and new versions (e.g. for deleted | ||
| 340 | ;; functions) and we'll want to use the original name. | ||
| 341 | (if (backup-file-name-p buffer-file) | ||
| 342 | (file-name-sans-versions buffer-file) | ||
| 343 | buffer-file))) | ||
| 344 | |||
| 329 | ;;;###autoload | 345 | ;;;###autoload |
| 330 | (defun add-change-log-entry (&optional whoami file-name other-window new-entry) | 346 | (defun add-change-log-entry (&optional whoami file-name other-window new-entry) |
| 331 | "Find change log file and add an entry for today. | 347 | "Find change log file and add an entry for today. |
| @@ -355,34 +371,21 @@ non-nil, otherwise in local time." | |||
| 355 | ;; s/he can edit the full name field in prompter if s/he wants. | 371 | ;; s/he can edit the full name field in prompter if s/he wants. |
| 356 | (setq add-log-mailing-address | 372 | (setq add-log-mailing-address |
| 357 | (read-input "Mailing address: " add-log-mailing-address)))) | 373 | (read-input "Mailing address: " add-log-mailing-address)))) |
| 374 | |||
| 375 | (setq file-name (expand-file-name (or file-name (find-change-log file-name)))) | ||
| 376 | |||
| 358 | (let ((defun (add-log-current-defun)) | 377 | (let ((defun (add-log-current-defun)) |
| 359 | (version (and change-log-version-info-enabled | 378 | (version (and change-log-version-info-enabled |
| 360 | (change-log-version-number-search))) | 379 | (change-log-version-number-search))) |
| 361 | bound entry) | 380 | ;; Set ENTRY to the file name to use in the new entry. |
| 362 | 381 | (entry (if buffer-file-name | |
| 363 | (setq file-name (expand-file-name (find-change-log file-name))) | 382 | (add-log-file-name buffer-file-name file-name) |
| 364 | 383 | (if add-log-file-name-function | |
| 365 | ;; Set ENTRY to the file name to use in the new entry. | 384 | (funcall add-log-file-name-function file-name)))) |
| 366 | (and buffer-file-name | 385 | bound) |
| 367 | ;; Never want to add a change log entry for the ChangeLog file itself. | 386 | |
| 368 | (not (string= buffer-file-name file-name)) | 387 | (if (or (and other-window (not (equal file-name buffer-file-name))) |
| 369 | (if add-log-file-name-function | 388 | (window-dedicated-p (selected-window))) |
| 370 | (setq entry | ||
| 371 | (funcall add-log-file-name-function buffer-file-name)) | ||
| 372 | (setq entry | ||
| 373 | (if (string-match | ||
| 374 | (concat "^" (regexp-quote (file-name-directory | ||
| 375 | file-name))) | ||
| 376 | buffer-file-name) | ||
| 377 | (substring buffer-file-name (match-end 0)) | ||
| 378 | (file-name-nondirectory buffer-file-name))) | ||
| 379 | ;; If we have a backup file, it's presumably because we're | ||
| 380 | ;; comparing old and new versions (e.g. for deleted | ||
| 381 | ;; functions) and we'll want to use the original name. | ||
| 382 | (if (backup-file-name-p entry) | ||
| 383 | (setq entry (file-name-sans-versions entry))))) | ||
| 384 | |||
| 385 | (if (and other-window (not (equal file-name buffer-file-name))) | ||
| 386 | (find-file-other-window file-name) | 389 | (find-file-other-window file-name) |
| 387 | (find-file file-name)) | 390 | (find-file file-name)) |
| 388 | (or (eq major-mode 'change-log-mode) | 391 | (or (eq major-mode 'change-log-mode) |