From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: [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: Tue, 17 Jul 2018 00:02:47 +0100 Message-ID: <87zhyqbx7s.fsf@gmail.com> References: <86wp12qtgo.fsf@dod.no> <83tvw6chqv.fsf@gnu.org> <86shbprix7.fsf_-_@dod.no> <838t6jgl1k.fsf@gnu.org> <601m6cc6.fsf@lifelogs.com> <83o9fefnv9.fsf@gnu.org> <83in5lg4ol.fsf@gnu.org> <83efg9fxnj.fsf@gnu.org> <838t6hfa4h.fsf@gnu.org> <87h8l4lt9q.fsf@gmail.com> <831sc8fttu.fsf@gnu.org> <87sh4lwwg6.fsf_-_@gmail.com> <83r2k389j9.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1531782107 8765 195.159.176.226 (16 Jul 2018 23:01:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 16 Jul 2018 23:01:47 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: tzz@lifelogs.com, larsi@gnus.org, cpitclaudel@gmail.com, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 17 01:01:42 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ffCUv-00026b-5D for ged-emacs-devel@m.gmane.org; Tue, 17 Jul 2018 01:01:41 +0200 Original-Received: from localhost ([::1]:54405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffCX0-0001jF-H5 for ged-emacs-devel@m.gmane.org; Mon, 16 Jul 2018 19:03:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffCWC-0001j9-1a for emacs-devel@gnu.org; Mon, 16 Jul 2018 19:03:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffCW7-0003za-3M for emacs-devel@gnu.org; Mon, 16 Jul 2018 19:03:00 -0400 Original-Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:35979) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ffCW6-0003xB-LJ; Mon, 16 Jul 2018 19:02:55 -0400 Original-Received: by mail-wr1-x441.google.com with SMTP id h9-v6so33489537wro.3; Mon, 16 Jul 2018 16:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=zcGk1LKMh9O7q8GzBikqP9u2R4UEtHiAQC3Xv8Lw0ho=; b=M+I/HtqXKShBdmo8mUfQ/WVeIkq8rfJ4mkLwoXkNoIuyyAlRUFvxTMVrT0nvLcG+xs 2wJxpeMKDoNaG0bOAC/Stv2F2QieNI2Ncsq4dypMro+Z6x8JhCk/A7G0eEG6Anab5tWr whhNXeHXTWblavbQ3iORPLKqf+m5n2dkmiZUieEYHMn49fPzXFPgIBvtV+nkRmbqKScH /+h+QittH6LxmAePAdw217vbYFepSCiL6eNTAvJES13hb0aIey0XONXsQ2i8obLXtnHv SmBIjKl2w4I1PwlH76LNChZhTlGYglYfD1SY1fKp0zTH8z6GN0aqiNxgeanJSJLa7O1A Zx8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=zcGk1LKMh9O7q8GzBikqP9u2R4UEtHiAQC3Xv8Lw0ho=; b=WYxCxZ/MVqqMQvbveUXLrVKTJG5/HbOsRRKgdCE9c/bnDA6hC815tsrfbI9CVNrZd0 EeuY+pcS5LHA5xChdqPHkov/Ayazxa1Plzwj85Owp+7wu3UKDtESz0w34Z350f+soBBV 9mj7mhzobazkbWQI1gMuPc0ZKEk8rnY2u5Qshq10FPuqGuf40lBiCx6ikUTTxjJ5EMYT SDzikpewO5mq21vEqCljHF7FckNHnqIDVWT4QXWnDKkvDG/M0dBMz/ragn708CbXIKm1 FGvu/PmcntsxsM8g9VHFx3+ecn8QNTsDkWZJZNjiwKVTOEB6UR84gnmWo07tcbvSAKmi lzuA== X-Gm-Message-State: AOUpUlGiXsBOYyTDrZONYPhIUrEflSBJ07JALaXYIc0WzkFU3ELN+Ji6 Pi8diYpMnEY5Cz8Dqesx1Cc= X-Google-Smtp-Source: AAOMgpcoXgqIRtu67f34WPNh0etlk9GdNnJIkPHryXnAFXjuVvlJ333eqoiKGcbhVGUB2FMeX6E5ug== X-Received: by 2002:adf:afd3:: with SMTP id y19-v6mr14717029wrd.176.1531782173428; Mon, 16 Jul 2018 16:02:53 -0700 (PDT) Original-Received: from lolita.yourcompany.com (188.139.62.94.rev.vodafone.pt. [94.62.139.188]) by smtp.gmail.com with ESMTPSA id c13-v6sm31253454wrt.24.2018.07.16.16.02.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 16:02:52 -0700 (PDT) In-Reply-To: <83r2k389j9.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 16 Jul 2018 18:50:18 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:227488 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> From: Jo=C3=A3o T=C3=A1vora >> Cc: larsi@gnus.org, tzz@lifelogs.com, emacs-devel@gnu.org, cpitclaude= l@gmail.com >> Date: Sat, 14 Jul 2018 18:36:57 +0100 >>=20 >> Eli Zaretskii writes: >>=20 >> > [...] 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. >>=20 >> Hi Eli, >>=20 >> 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). >>=20 >> If this is accepted, I can submit more patches for more related >> functionality. The next two I imagine, in this order, are: >>=20 >> * C-c C-c (commit-time in vc-log) somehow disables the entries collected >> by C-c C-a in the ChangeLog buffer. >>=20 >> * Use a single ChangeLog buffer indexed by projects (Stefan's idea) > > Thanks. I didn't forget about this and didn't lose it. I'm just a > bit busy these days, and may need a couple more days before I get to > reviewing this. I'm saving Stefan's comments and your responses for > that time. > > Stay tuned. No worries. When you do get around to it, have a look at the patch I attach to this mail instead, because it integrates a few of Stefan's suggestions (the part we don't yet agree is how, if at all, to add uniquify.el into the equation...). Jo=C3=A3o --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-New-option-to-make-C-x-4-a-use-file-less-ChangeLog-b.patch >From 2287a08e58cb2fc3ee82dbf3861e7c8d9d1c9b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= 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 | 71 ++++++++++++++++++++++++++++++++++++--------- lisp/vc/log-edit.el | 6 ++-- 2 files changed, 62 insertions(+), 15 deletions(-) diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el index 4d69aac454..d8517d6196 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,51 @@ add-log-file-name (file-name-sans-versions buffer-file) buffer-file)))) +(defcustom add-log-use-pseudo-changelog t + "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 "*changes to %s*" + (abbreviate-file-name + (file-name-directory changelog-file-name)))) + +(defun add-log--changelog-buffer-p (changelog-file-name buffer) + "Tell if BUFFER holds 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'). - -Second arg FILE-NAME is file name of the change log. -If nil, use the value of `change-log-default-name'. + "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 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' is t, +in which case a suitably named file-less buffer is used for +keeping entries pertaining to CHANGELOG-FILE-NAME's directory. Third arg OTHER-WINDOW non-nil means visit in other window. @@ -804,20 +841,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 --=-=-=--