Mercurial > emacs
comparison lisp/add-log.el @ 31794:7e8ab579609b
(add-log-file-name): New function (split out of add-change-log-entry).
(add-change-log-entry): Use it.
Call add-log-file-name-function with the changelog file name if
the current buffer is not associated with any file.
Avoid find-file if the selected window is dedicated.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 20 Sep 2000 22:21:52 +0000 |
parents | 601145997e91 |
children | b7491dcc3530 |
comparison
equal
deleted
inserted
replaced
31793:8ddefe8b533e | 31794:7e8ab579609b |
---|---|
324 (setq file-name file1))))) | 324 (setq file-name file1))))) |
325 ;; Make a local variable in this buffer so we needn't search again. | 325 ;; Make a local variable in this buffer so we needn't search again. |
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. |
332 Optional arg WHOAMI (interactive prefix) non-nil means prompt for user | 348 Optional arg WHOAMI (interactive prefix) non-nil means prompt for user |
333 name and site. | 349 name and site. |
353 ;; full name which look silly when inserted. Rather than do | 369 ;; full name which look silly when inserted. Rather than do |
354 ;; anything about that here, let user give prefix argument so that | 370 ;; anything about that here, let user give prefix argument so that |
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) |
389 (change-log-mode)) | 392 (change-log-mode)) |
390 (undo-boundary) | 393 (undo-boundary) |