From: "João Távora" <joaotavora@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>, monnier@iro.umontreal.ca
Cc: larsi@gnus.org, cpitclaudel@gmail.com, tzz@lifelogs.com,
emacs-devel@gnu.org
Subject: [PATCH] New option to make C-x 4 a use file-less ChangeLog buffers (was Re: git history tracking across renames (and emacs support))
Date: Sat, 14 Jul 2018 18:36:57 +0100 [thread overview]
Message-ID: <87sh4lwwg6.fsf_-_@gmail.com> (raw)
In-Reply-To: <831sc8fttu.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 12 Jul 2018 16:48:45 +0300")
[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
> [...] perhaps add-log.el could be extended to be able to use a buffer
> name, not just a file name, for where to put the log messages. It
> already allows you to customize the file name; it could do something
> similar with a buffer name, and that buffer could have no file name.
> Then a large part of your problems would go away, AFAIU.
Hi Eli,
Find attached a patch that does exactly this. It is only lightly
tested, so I need a clinical eye that I didn't break anything.
Fortunately, it is quite short. Appropriately, I used it to compose the
commit message (and I don't have any ChangeLog files lying around).
If this is accepted, I can submit more patches for more related
functionality. The next two I imagine, in this order, are:
* C-c C-c (commit-time in vc-log) somehow disables the entries collected
by C-c C-a in the ChangeLog buffer.
* Use a single ChangeLog buffer indexed by projects (Stefan's idea)
Thanks,
João
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-New-option-to-make-C-x-4-a-use-file-less-ChangeLog-b.patch --]
[-- Type: text/x-diff, Size: 6411 bytes --]
From 867540c9310ee12ca477e744571d93f56f5f888d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= <joaotavora@gmail.com>
Date: Sat, 14 Jul 2018 18:29:48 +0100
Subject: [PATCH] New option to make C-x 4 a use file-less ChangeLog buffers
* lisp/vc/add-log.el (add-log-file-name): Update docstring.
(add-log-use-pseudo-changelog): New defcustom.
(add-log-find-changelog-buffer): New helper.
(add-change-log-entry): Can work with ChangeLog file-less
buffers. Change name of argument FILE-NAME arg to be more
explicit. Explain new meaning of arg in docstring.
(add-log--changelog-buffer-p): New helper.
* lisp/vc/log-edit.el (log-edit-changelog-entries): Use
add-log-use-pseudo-changelog and add-log-find-changelog-buffer.
---
lisp/vc/add-log.el | 67 +++++++++++++++++++++++++++++++++++++--------
lisp/vc/log-edit.el | 6 ++--
2 files changed, 59 insertions(+), 14 deletions(-)
diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el
index 4d69aac454..983024327c 100644
--- a/lisp/vc/add-log.el
+++ b/lisp/vc/add-log.el
@@ -744,6 +744,7 @@ find-change-log
file-name)
(defun add-log-file-name (buffer-file log-file)
+ "Compute file-name of BUFFER-FILE as displayed in LOG-FILE."
;; Never want to add a change log entry for the ChangeLog file itself.
(unless (or (null buffer-file) (string= buffer-file log-file))
(if add-log-file-name-function
@@ -767,15 +768,49 @@ add-log-file-name
(file-name-sans-versions buffer-file)
buffer-file))))
+(defcustom add-log-use-pseudo-changelog nil
+ "If non-nil, don't create ChangeLog files for log entries."
+ :type :boolean)
+
+(put 'add-log-use-pseudo-changelog 'safe-local-variable 'booleanp)
+
+(defun add-log--pseudo-changelog-buffer-name (changelog-file-name)
+ "Compute suitable name for a pseudo-ChangeLog buffer."
+ (format "*PseudoChangeLog for %s*"
+ (file-name-directory changelog-file-name)))
+
+(defun add-log--changelog-buffer-p (changelog-file-name buffer)
+ "Tell if BUFFER is a ChangeLog for CHANGELOG-FILE-NAME."
+ (with-current-buffer buffer
+ (if buffer-file-name
+ (equal buffer-file-name changelog-file-name)
+ (equal (add-log--pseudo-changelog-buffer-name changelog-file-name)
+ (buffer-name)))))
+
+(defun add-log-find-changelog-buffer (changelog-file-name)
+ "Find a ChangeLog buffer for CHANGELOG-FILE-NAME.
+Respect `add-log-use-pseudo-changelog', which see."
+ (if (or (file-exists-p changelog-file-name)
+ (not add-log-use-pseudo-changelog))
+ (find-file-noselect changelog-file-name)
+ (get-buffer-create
+ (add-log--pseudo-changelog-buffer-name changelog-file-name))))
+
;;;###autoload
-(defun add-change-log-entry (&optional whoami file-name other-window new-entry
+(defun add-change-log-entry (&optional whoami
+ changelog-file-name
+ other-window new-entry
put-new-entry-on-new-line)
- "Find change log file, and add an entry for today and an item for this file.
-Optional arg WHOAMI (interactive prefix) non-nil means prompt for user
-name and email (stored in `add-log-full-name' and `add-log-mailing-address').
+ "Find ChangeLog buffer, add an entry for today and an item for this file.
+Optional arg WHOAMI (interactive prefix) non-nil means prompt for
+user name and email (stored in `add-log-full-name' and
+`add-log-mailing-address').
-Second arg FILE-NAME is file name of the change log.
-If nil, use the value of `change-log-default-name'.
+Second arg CHANGELOG-FILE-NAME is file name of the change log.
+If nil, use the value of `change-log-default-name'. If the file
+thus named exists, it's used for the new entry. If it doesn't
+exist, it is created, unless `add-log-use-pseudo-changelog' in
+which case a suitably named file-less buffer is used.
Third arg OTHER-WINDOW non-nil means visit in other window.
@@ -804,20 +839,28 @@ add-change-log-entry
(change-log-version-number-search)))
(buf-file-name (funcall add-log-buffer-file-name-function))
(buffer-file (if buf-file-name (expand-file-name buf-file-name)))
- (file-name (expand-file-name (find-change-log file-name buffer-file)))
+ (changelog-file-name (expand-file-name (find-change-log
+ changelog-file-name
+ buffer-file)))
;; Set ITEM to the file name to use in the new item.
- (item (add-log-file-name buffer-file file-name)))
+ (item (add-log-file-name buffer-file changelog-file-name)))
- (unless (equal file-name buffer-file-name)
+ ;; don't add entries from the ChangeLog file/buffer to itself.
+ (unless (equal changelog-file-name buffer-file-name)
(cond
- ((equal file-name (buffer-file-name (window-buffer)))
+ ((add-log--changelog-buffer-p
+ changelog-file-name
+ (window-buffer))
;; If the selected window already shows the desired buffer don't show
;; it again (particularly important if other-window is true).
;; This is important for diff-add-change-log-entries-other-window.
(set-buffer (window-buffer)))
((or other-window (window-dedicated-p))
- (find-file-other-window file-name))
- (t (find-file file-name))))
+ (switch-to-buffer-other-window
+ (add-log-find-changelog-buffer changelog-file-name)))
+ (t
+ (switch-to-buffer
+ (add-log-find-changelog-buffer changelog-file-name)))))
(or (derived-mode-p 'change-log-mode)
(change-log-mode))
(undo-boundary)
diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el
index 6ff782a606..f071d029a5 100644
--- a/lisp/vc/log-edit.el
+++ b/lisp/vc/log-edit.el
@@ -913,8 +913,10 @@ log-edit-changelog-entries
(setq change-log-default-name nil)
(find-change-log)))))
(when (or (find-buffer-visiting changelog-file-name)
- (file-exists-p changelog-file-name))
- (with-current-buffer (find-file-noselect changelog-file-name)
+ (file-exists-p changelog-file-name)
+ add-log-use-pseudo-changelog)
+ (with-current-buffer
+ (add-log-find-changelog-buffer changelog-file-name)
(unless (eq major-mode 'change-log-mode) (change-log-mode))
(goto-char (point-min))
(if (looking-at "\\s-*\n") (goto-char (match-end 0)))
--
2.17.1
next prev parent reply other threads:[~2018-07-14 17:36 UTC|newest]
Thread overview: 232+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-15 7:39 bug#28842: gnus-sync is missing Andreas Schwab
2017-12-09 19:58 ` Ted Zlatanov
2017-12-10 11:37 ` Andreas Schwab
2017-12-10 13:15 ` Ted Zlatanov
2017-12-10 13:41 ` Andreas Schwab
2017-12-11 14:57 ` Ted Zlatanov
2017-12-11 15:40 ` Andreas Schwab
2017-12-11 15:49 ` Ted Zlatanov
2017-12-11 15:51 ` Andreas Schwab
2017-12-11 22:37 ` Richard Stallman
2017-12-12 17:15 ` Ted Zlatanov
2017-12-12 22:08 ` Richard Stallman
2017-12-12 23:41 ` Ted Zlatanov
2017-12-15 21:26 ` The name gnus-cloud.el Richard Stallman
2017-12-16 22:34 ` Ted Zlatanov
2017-12-17 22:22 ` Richard Stallman
2017-12-17 22:31 ` Lars Ingebrigtsen
2017-12-17 22:57 ` Eric Abrahamsen
2017-12-18 21:15 ` Richard Stallman
2017-12-17 23:20 ` Stephen Berman
2017-12-18 21:17 ` Richard Stallman
2017-12-17 23:06 ` Stefan Monnier
2017-12-18 0:33 ` Ted Zlatanov
2017-12-18 3:31 ` Eli Zaretskii
2017-12-18 21:16 ` Richard Stallman
2017-12-19 3:37 ` Eli Zaretskii
2017-12-21 16:50 ` Richard Stallman
2017-12-21 17:13 ` Eli Zaretskii
2017-12-22 18:47 ` Richard Stallman
2017-12-22 18:57 ` Eli Zaretskii
2017-12-22 19:20 ` Eli Zaretskii
2017-12-23 14:58 ` Richard Stallman
2017-12-23 15:04 ` Eli Zaretskii
2017-12-24 20:34 ` Richard Stallman
2017-12-25 16:06 ` Eli Zaretskii
2017-12-25 22:27 ` Paul Eggert
2017-12-26 19:40 ` Richard Stallman
2018-07-10 13:16 ` Ted Zlatanov
2017-12-24 20:34 ` Richard Stallman
2017-12-25 16:09 ` Eli Zaretskii
2017-12-31 16:27 ` Steinar Bang
2017-12-31 16:54 ` Eli Zaretskii
2017-12-31 18:12 ` Óscar Fuentes
2017-12-31 18:26 ` Eli Zaretskii
2018-01-01 0:48 ` Steinar Bang
2018-01-01 4:40 ` Eli Zaretskii
2017-12-31 18:27 ` Andreas Schwab
2018-01-01 1:05 ` Steinar Bang
2018-01-01 4:42 ` Eli Zaretskii
2018-01-01 10:07 ` git history tracking across renames (and emacs support) (Was: The name gnus-cloud.el) Steinar Bang
2018-01-01 10:59 ` git history tracking across renames (and emacs support) Andreas Schwab
2018-01-01 21:40 ` Steinar Bang
2018-01-01 11:00 ` Andreas Schwab
2018-01-01 21:37 ` Steinar Bang
2018-01-01 11:06 ` Andreas Schwab
2018-01-01 21:36 ` Steinar Bang
2018-01-01 21:59 ` Andreas Schwab
2018-01-01 22:42 ` Steinar Bang
2018-01-01 22:04 ` Óscar Fuentes
2018-01-01 22:45 ` Noam Postavsky
2018-01-02 0:02 ` Óscar Fuentes
2018-01-02 1:15 ` git history tracking across renames (and emacs support) (Was: The name gnus-cloud.el) Richard Stallman
2018-01-02 8:06 ` Paul Eggert
2018-01-02 8:49 ` git history tracking across renames (and emacs support) Lars Ingebrigtsen
2018-07-10 13:14 ` Ted Zlatanov
2018-07-10 15:05 ` Marcin Borkowski
2018-07-10 15:36 ` Eli Zaretskii
2018-07-10 20:54 ` Ted Zlatanov
2018-07-10 23:04 ` Basil L. Contovounesios
2018-07-11 3:32 ` Eli Zaretskii
2018-07-11 3:53 ` Stefan Monnier
2018-07-11 4:44 ` Marcin Borkowski
2018-07-11 8:22 ` Eli Zaretskii
2018-07-11 13:54 ` git history tracking across renames (and emacs support), Re: git history tracking across renames (and emacs support), Re: git history tracking across renames (and emacs support), " Ted Zlatanov
2018-07-11 15:42 ` Eli Zaretskii
2018-07-11 16:09 ` Clément Pit-Claudel
2018-07-11 17:13 ` Eric Abrahamsen
2018-07-11 22:50 ` Richard Stallman
2018-07-11 23:04 ` Noam Postavsky
2018-07-12 23:35 ` Richard Stallman
2018-07-13 20:13 ` Jonas Bernoulli
2018-07-14 7:05 ` Eli Zaretskii
2018-07-11 17:31 ` Ted Zlatanov
2018-07-11 18:13 ` Eli Zaretskii
2018-07-11 20:14 ` Paul Eggert
2018-07-11 22:36 ` João Távora
2018-07-12 2:42 ` Eli Zaretskii
2018-07-12 9:04 ` João Távora
2018-07-12 13:48 ` Eli Zaretskii
2018-07-12 16:26 ` João Távora
2018-07-12 16:38 ` Eli Zaretskii
2018-07-12 16:47 ` João Távora
2018-07-12 16:59 ` Eli Zaretskii
2018-07-12 16:40 ` Stefan Monnier
2018-07-12 16:56 ` João Távora
2018-07-12 17:01 ` Eli Zaretskii
2018-07-12 19:37 ` Ted Zlatanov
2018-07-13 6:16 ` Eli Zaretskii
2018-07-12 17:17 ` Stefan Monnier
2018-07-12 23:12 ` João Távora
2018-07-13 18:47 ` Stefan Monnier
2018-07-14 17:36 ` João Távora [this message]
2018-07-15 5:33 ` [PATCH] New option to make C-x 4 a use file-less ChangeLog buffers Basil L. Contovounesios
2018-07-15 10:41 ` João Távora
2018-07-15 14:11 ` Basil L. Contovounesios
2018-07-16 2:15 ` [PATCH] New option to make C-x 4 a use file-less ChangeLog buffers (was Re: git history tracking across renames (and emacs support)) Stefan Monnier
2018-07-16 10:10 ` João Távora
2018-07-16 12:33 ` Stefan Monnier
2018-07-16 14:02 ` João Távora
2018-07-16 15:44 ` Stefan Monnier
2018-07-16 18:00 ` João Távora
2018-07-16 18:22 ` Stefan Monnier
2018-07-16 18:50 ` João Távora
2018-07-16 21:09 ` Stefan Monnier
2018-07-21 10:45 ` Eli Zaretskii
2018-07-16 15:50 ` Eli Zaretskii
2018-07-16 23:02 ` João Távora
2018-07-21 10:42 ` Eli Zaretskii
2018-07-21 13:02 ` João Távora
2018-07-21 13:30 ` Eli Zaretskii
2018-07-21 15:08 ` João Távora
2018-07-21 16:13 ` Eli Zaretskii
2018-10-08 1:10 ` Ted Zlatanov
2018-10-08 1:31 ` João Távora
2018-07-12 13:36 ` git history tracking across renames (and emacs support) Stefan Monnier
2018-07-12 15:53 ` Basil L. Contovounesios
2018-07-12 16:00 ` Stefan Monnier
2018-07-12 16:48 ` Robert Pluim
2018-07-12 17:03 ` Stefan Monnier
2018-07-12 20:01 ` Robert Pluim
2018-07-12 20:06 ` Stefan Monnier
2018-07-12 20:28 ` Robert Pluim
2018-07-13 3:46 ` Stefan Monnier
2018-07-13 8:18 ` Robert Pluim
2018-07-13 12:16 ` Stefan Monnier
2018-07-13 13:07 ` Robert Pluim
2018-07-13 15:29 ` Clément Pit-Claudel
2018-07-13 15:49 ` Stefan Monnier
2018-07-12 16:40 ` João Távora
2018-07-12 16:59 ` Stefan Monnier
2018-07-12 23:33 ` João Távora
2018-07-13 18:55 ` Stefan Monnier
2018-07-13 19:45 ` João Távora
2018-07-13 20:33 ` Stefan Monnier
2018-07-11 17:08 ` Radon Rosborough
2018-07-11 17:56 ` Paul Eggert
2018-07-11 18:10 ` Eli Zaretskii
2018-07-11 22:51 ` Richard Stallman
2018-07-12 14:10 ` Eli Zaretskii
2018-07-11 22:51 ` Richard Stallman
2018-07-12 19:46 ` Ted Zlatanov
2018-07-12 23:03 ` Paul Eggert
2018-07-12 23:39 ` Richard Stallman
2018-07-11 18:25 ` Eli Zaretskii
2018-07-12 17:03 ` Radon Rosborough
2018-07-12 17:37 ` Eli Zaretskii
2018-07-13 4:33 ` Radon Rosborough
2018-07-13 8:14 ` Eli Zaretskii
2018-07-13 14:15 ` Paul Eggert
2018-07-13 14:39 ` Eli Zaretskii
2018-07-13 16:39 ` Stefan Monnier
2018-07-13 23:11 ` Richard Stallman
2018-07-14 6:58 ` Commit header lines (was: git history tracking across renames (and emacs support)) Eli Zaretskii
2018-07-14 16:09 ` Paul Eggert
2018-07-14 16:23 ` Eli Zaretskii
2018-07-14 21:57 ` Paul Eggert
2018-07-12 19:42 ` git history tracking across renames (and emacs support) Ted Zlatanov
2018-07-13 6:16 ` Eli Zaretskii
2018-01-02 16:15 ` git history tracking across renames (and emacs support) (Was: The name gnus-cloud.el) Eli Zaretskii
2018-01-03 2:50 ` Paul Eggert
2018-01-03 3:24 ` git history tracking across renames (and emacs support) Stefan Monnier
2018-01-03 15:36 ` Eli Zaretskii
2018-01-03 18:20 ` Stefan Monnier
2018-01-03 18:56 ` Eli Zaretskii
2018-01-03 20:17 ` Stefan Monnier
2018-01-03 20:43 ` Eli Zaretskii
2018-01-03 22:02 ` Stefan Monnier
2018-01-04 3:33 ` Eli Zaretskii
2018-01-04 5:00 ` Stefan Monnier
2018-01-04 6:39 ` Eli Zaretskii
2018-01-04 8:03 ` Paul Eggert
2018-01-04 14:25 ` Stefan Monnier
2018-01-04 16:13 ` Eli Zaretskii
2018-01-04 13:15 ` Dmitry Gutov
2018-01-05 3:51 ` Stefan Monnier
2018-01-03 18:29 ` Alan Mackenzie
2018-01-03 22:45 ` Stefan Monnier
2018-01-04 12:02 ` Alan Mackenzie
2018-01-04 18:05 ` Stefan Monnier
2018-01-03 15:32 ` git history tracking across renames (and emacs support) (Was: The name gnus-cloud.el) Eli Zaretskii
2018-01-03 20:11 ` git history tracking across renames (and emacs support) Stefan Monnier
2018-01-03 16:42 ` Stephen Leake
2018-01-04 11:46 ` Richard Stallman
2018-01-03 3:08 ` git history tracking across renames (and emacs support) (Was: The name gnus-cloud.el) Richard Stallman
2018-01-03 3:28 ` git history tracking across renames (and emacs support) Stefan Monnier
2018-01-08 2:16 ` git history tracking across renames (and emacs support) (Was: The name gnus-cloud.el) Richard Stallman
2018-01-08 4:22 ` Paul Eggert
2018-01-08 18:30 ` Eli Zaretskii
2018-01-08 18:41 ` Paul Eggert
2018-01-08 19:13 ` Eli Zaretskii
2018-01-08 19:29 ` Paul Eggert
2018-01-08 21:08 ` Eli Zaretskii
2018-01-09 2:55 ` Richard Stallman
2018-01-09 7:27 ` Paul Eggert
2018-01-10 3:03 ` Richard Stallman
2018-01-10 8:22 ` Paul Eggert
2018-01-10 15:32 ` Eli Zaretskii
2018-01-11 22:08 ` git history tracking across renames (and emacs support) Stefan Monnier
2018-01-12 8:21 ` Eli Zaretskii
2018-01-13 2:33 ` Paul Eggert
2018-01-13 5:13 ` Stefan Monnier
2018-01-13 8:31 ` Eli Zaretskii
2018-01-13 10:31 ` Tim Landscheidt
2018-01-13 17:42 ` Stefan Monnier
2018-01-13 19:22 ` Eli Zaretskii
2018-01-13 21:43 ` Stefan Monnier
2018-01-13 19:35 ` Paul Eggert
2018-01-13 19:42 ` Eli Zaretskii
2018-01-13 20:22 ` Paul Eggert
2018-01-14 3:31 ` Eli Zaretskii
2018-01-13 8:26 ` Eli Zaretskii
2018-01-16 2:16 ` git history tracking across renames (and emacs support) (Was: The name gnus-cloud.el) Richard Stallman
2018-01-09 2:54 ` Richard Stallman
2018-01-02 22:04 ` git history tracking across renames (and emacs support) Steinar Bang
2018-01-02 5:20 ` Stefan Monnier
2018-01-02 17:34 ` The name gnus-cloud.el Karl Fogel
2018-01-02 20:42 ` Chad Brown
2017-12-18 21:15 ` Richard Stallman
2017-12-19 6:09 ` John Wiegley
2017-12-19 7:42 ` Eli Zaretskii
2017-12-21 16:51 ` Richard Stallman
2017-12-19 9:09 ` joakim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sh4lwwg6.fsf_-_@gmail.com \
--to=joaotavora@gmail.com \
--cc=cpitclaudel@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
--cc=monnier@iro.umontreal.ca \
--cc=tzz@lifelogs.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.