unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#52167: 29.0.50; [ada-mode] Preserve default value of project-read-file-name-function
@ 2021-11-28 20:39 Kévin Le Gouguec
  2022-05-28 11:15 ` Stephen Leake
  0 siblings, 1 reply; 2+ messages in thread
From: Kévin Le Gouguec @ 2021-11-28 20:39 UTC (permalink / raw)
  To: 52167; +Cc: ada-mode-users

[-- Attachment #1: Type: text/plain, Size: 1037 bytes --]

Package: emacs, ada-mode
X-Debbugs-CC: ada-mode-users@nongnu.org

Hello,

ada-mode depends on uniquify-files, which ends with this:

> ;;;###autoload
> (setq-default project-read-file-name-function #'uniq-file-read)

This unconditionally changes the prompt for project-find-file at
startup.  I think this is a bit of an overreach: users who install
ada-mode are not necessarily looking for a new project-find-file prompt
for *all* their projects, including those unrelated to Ada.

I'm attaching

- a patch for uniquify-files to remove the above snippet, and add a bit
  of commentary explaining how to opt in to uniq-file-read,

- a patch for ada-mode to explicitly let-bind
  project-read-file-name-function before calling project-find-file,

- two more patches for ada-mode, which I didn't squash with the first
  one because I'm not 100% sure they are desirable: one to make
  ada-find-file support future Emacs versions; another to use
  ada-find-file in ada-mode-menu.

Let me know if this needs more work; thanks for your time.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Preserve-default-value-of-project-read-file-name-fun.patch --]
[-- Type: text/x-diff, Size: 1468 bytes --]

From 38a1d0ae71b13b7676ea0ede0a605ff6f23aceed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legouguec@gmail.com>
Date: Sat, 27 Nov 2021 23:52:50 +0100
Subject: [PATCH] Preserve default value of project-read-file-name-function

This package can be pulled as a dependency (e.g. of ada-mode),
unbeknownst to the user who might not expect nor desire this setting.

* uniquify-files.el: Do not unconditionally change
project-read-file-name-function; expand commentary to let users know
how to opt in.
---
 uniquify-files.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/uniquify-files.el b/uniquify-files.el
index d9430539fe..a314d001fc 100644
--- a/uniquify-files.el
+++ b/uniquify-files.el
@@ -33,6 +33,11 @@
 ;; We accomplish this by preprocessing the list of absolute file names
 ;; to be in that style, in an alist with the original absolute file
 ;; names, and do completion on that alist.
+;;
+;; To use it with `project-find-file', customize
+;; `project-read-file-name-function':
+;;
+;; (setq project-read-file-name-function 'uniq-file-read)
 
 (require 'cl-lib)
 (require 'files)
@@ -317,8 +322,5 @@ done on UNIQIFIED-NAME, PRED is called with ABS-NAME."
                  prompt table predicate hist default)))
     (cdr (assoc found alist))))
 
-;;;###autoload
-(setq-default project-read-file-name-function #'uniq-file-read)
-
 (provide 'uniquify-files)
 ;;; uniquify-files.el ends here
-- 
2.34.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-Explicitly-bind-project-read-file-name-function.patch --]
[-- Type: text/x-diff, Size: 2097 bytes --]

From 5ee3ab88fb9c439165a23fad03468c62e2f3ce4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legouguec@gmail.com>
Date: Sun, 28 Nov 2021 00:19:20 +0100
Subject: [PATCH 1/3] Explicitly bind project-read-file-name-function

* ada-mode.el (ada-find-file): let-bind
project-read-file-name-function.
* NEWS: announce the change.
---
 NEWS        | 13 +++++++++++++
 ada-mode.el |  9 +++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index fe3e518f11..ff64186a13 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,19 @@ Please send ada-mode bug reports to bug-gnu-emacs@gnu.org, with
 'ada-mode' in the subject. If possible, use M-x report-emacs-bug.
 
 \f
+* Ada Mode x.x.x
+xx Xxx xxxx
+
+** Adapt to change in uniquify-files.
+   uniquify-files no longer sets project-read-file-name-function by
+   default.  ada-find-file (C-c C-t) will still use this package's
+   completion style, but project-find-file (C-x p f) will not by
+   default.
+
+   Set project-read-file-name-function to uniq-file-read if you would
+   like to keep using uniquify-files's completion style outside of
+   ada-find-file.
+
 * Ada Mode 7.2.0
 21 Nov 2021
 
diff --git a/ada-mode.el b/ada-mode.el
index a65c7b47da..9997f35c99 100644
--- a/ada-mode.el
+++ b/ada-mode.el
@@ -1462,12 +1462,13 @@ For `wisi-indent-calculate-functions'.
   "Find a file in the current project.
 Prompts with completion, defaults to filename at point."
   (interactive)
-  ;; In emacs 27, we can just call 'project-find-file;
-  ;; project-read-file-name-function handles the uniquify-files alist
-  ;; completion table. In emacs 26, we must do that ourselves.
+  ;; In emacs 27, we can just set project-read-file-name-function to
+  ;; tell 'project-find-file to use the uniquify-files alist
+  ;; completion table.  In emacs 26, we must do that ourselves.
   (cl-ecase emacs-major-version
     (27
-     (project-find-file))
+     (let ((project-read-file-name-function #'uniq-file-read))
+       (project-find-file)))
 
     (26
      (let* ((def (thing-at-point 'filename))
-- 
2.34.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0002-ada-mode.el-ada-mode-menu-Prefer-ada-find-file.patch --]
[-- Type: text/x-diff, Size: 920 bytes --]

From a221c350e7697c6000c1b0030d964501426a1b2b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legouguec@gmail.com>
Date: Sun, 28 Nov 2021 00:46:48 +0100
Subject: [PATCH 2/3] * ada-mode.el (ada-mode-menu): Prefer ada-find-file

---
 ada-mode.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ada-mode.el b/ada-mode.el
index 9997f35c99..fa2c4a4f7a 100644
--- a/ada-mode.el
+++ b/ada-mode.el
@@ -246,7 +246,7 @@ nil, only the file name."
      )
     ("Navigate"
      ["Other file"                    ada-find-other-file          t]
-     ["Find file in project"          project-find-file            t]
+     ["Find file in project"          ada-find-file                t]
      ["Goto declaration/body"         wisi-goto-spec/body          t]
      ["Goto next statement keyword"   forward-sexp   t]
      ["Goto prev statement keyword"   backward-sexp   t]
-- 
2.34.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0003-ada-mode.el-ada-find-file-Support-future-Emacs-versi.patch --]
[-- Type: text/x-diff, Size: 2082 bytes --]

From b0bd0e796333f80a21c5d73d2cde97d7cf18b095 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legouguec@gmail.com>
Date: Sun, 28 Nov 2021 00:48:35 +0100
Subject: [PATCH 3/3] * ada-mode.el (ada-find-file): Support future Emacs
 versions

---
 ada-mode.el | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/ada-mode.el b/ada-mode.el
index fa2c4a4f7a..980fcb081e 100644
--- a/ada-mode.el
+++ b/ada-mode.el
@@ -1465,23 +1465,20 @@ Prompts with completion, defaults to filename at point."
   ;; In emacs 27, we can just set project-read-file-name-function to
   ;; tell 'project-find-file to use the uniquify-files alist
   ;; completion table.  In emacs 26, we must do that ourselves.
-  (cl-ecase emacs-major-version
-    (27
-     (let ((project-read-file-name-function #'uniq-file-read))
-       (project-find-file)))
-
-    (26
-     (let* ((def (thing-at-point 'filename))
-	    (project (project-current))
-	    (all-files (project-files project nil))
-	    (alist (uniq-file-uniquify all-files))
-	    (table (apply-partially #'uniq-file-completion-table alist))
-            (file (project--completing-read-strict
-                   "Find file" table nil nil def)))
-       (if (string= file "")
-           (user-error "You didn't specify the file")
-	 (find-file (cdr (assoc file alist))))))
-    ))
+  (require 'project)
+  (if (boundp 'project-read-file-name-function)
+      (let ((project-read-file-name-function #'uniq-file-read))
+        (project-find-file))
+    (let* ((def (thing-at-point 'filename))
+	   (project (project-current))
+	   (all-files (project-files project nil))
+	   (alist (uniq-file-uniquify all-files))
+	   (table (apply-partially #'uniq-file-completion-table alist))
+           (file (project--completing-read-strict
+                  "Find file" table nil nil def)))
+      (if (string= file "")
+          (user-error "You didn't specify the file")
+	(find-file (cdr (assoc file alist)))))))
 
 ;;;; compatibility with previous ada-mode versions
 
-- 
2.34.0


[-- Attachment #6: Type: text/plain, Size: 808 bytes --]


In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
 of 2021-11-26 built on hirondell
Repository revision: 11860f89a593a8cfe7efb94e86370bbbe4318fba
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)

Configured using:
 'configure --with-xwidgets --with-cairo --with-gconf --with-xinput2'

Configured features:
ACL CAIRO DBUS FREETYPE GCONF GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ
JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#52167: 29.0.50; [ada-mode] Preserve default value of project-read-file-name-function
  2021-11-28 20:39 bug#52167: 29.0.50; [ada-mode] Preserve default value of project-read-file-name-function Kévin Le Gouguec
@ 2022-05-28 11:15 ` Stephen Leake
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Leake @ 2022-05-28 11:15 UTC (permalink / raw)
  To: 52167-close

Closed by ada-mode version 7.2.1, uniquify-files version 1.0.4.
-- 
-- Stephe





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-28 11:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-28 20:39 bug#52167: 29.0.50; [ada-mode] Preserve default value of project-read-file-name-function Kévin Le Gouguec
2022-05-28 11:15 ` Stephen Leake

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).