unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#49865: 28.0.50; Customize project-find-file without thing-at-pont
@ 2021-08-04  6:16 Manuel Uberti
  2021-08-04  8:37 ` Lars Ingebrigtsen
  2021-08-06  0:36 ` Dmitry Gutov
  0 siblings, 2 replies; 10+ messages in thread
From: Manuel Uberti @ 2021-08-04  6:16 UTC (permalink / raw)
  To: 49865

Hi,

when I use project-find-file it always picks up the thing at point even when it 
is something I am pretty sure that does not correspond to a filename, which, in 
my case, is all the times.

I see that in project.el, project-find-file uses project-find-file-in:

;;;###autoload
(defun project-find-file ()
   "Visit a file (with completion) in the current project.

The completion default is the filename at point, determined by
`thing-at-point' (whether such file exists or not)."
   (interactive)
   (let* ((pr (project-current t))
          (dirs (list (project-root pr))))
     (project-find-file-in (thing-at-point 'filename) dirs pr)))

Would it be possible to make it customizable with regards to that
(thing-at-point 'filename)?

At the moment I am using this in my init.el, which I have bound to f in 
project-prefix-map:

(defun mu-project-find-file ()
   "Visit a file (with completion) in the current project."
   (interactive)
   (let* ((pr (project-current t))
          (dirs (list (project-root pr))))
     (project-find-file-in nil dirs pr)))

So what I would like is a defcustom that makes me choose whether to pass nil or 
(thing-at-point ...) to project-find-file-in.

I know that this is not a real bug because I can still type whatever I want 
after calling project-find-file, so I totally understand if this is not 
something worth new code in project.el. It's just that I don't see the point for 
project-find-file to suggest me as defaults things like "defun" or "interactive".


Thank you.



In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.18, cairo 
version 1.16.0)
  of 2021-08-04 built on hathaway
Repository revision: bee3e51550174047c73a1e942c16c8d45e2db1b8
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12009000
System Description: Ubuntu 20.04 LTS

Configured using:
  'configure --with-harfbuzz --with-native-compilation'

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

Important settings:
   value of $LC_MONETARY: it_IT.UTF-8
   value of $LC_NUMERIC: it_IT.UTF-8
   value of $LC_TIME: it_IT.UTF-8
   value of $LANG: en_US.UTF-8
   value of $XMODIFIERS: @im=ibus
   locale-coding-system: utf-8-unix

Major mode: ELisp/l

Minor modes in effect:
   electric-pair-mode: t
   flyspell-mode: t
   delete-selection-mode: t
   auto-image-file-mode: t
   show-paren-mode: t
   global-so-long-mode: t
   global-company-mode: t
   company-mode: t
   envrc-global-mode: t
   envrc-mode: t
   flymake-mode: t
   goto-address-prog-mode: t
   hl-line-mode: t
   global-git-commit-mode: t
   magit-auto-revert-mode: t
   shell-command-with-editor-mode: t
   shell-dirtrack-mode: t
   minibuffer-depth-indicate-mode: t
   minibuffer-electric-default-mode: t
   savehist-mode: t
   global-diff-hl-mode: t
   diff-hl-mode: t
   vertico-mode: t
   recentf-mode: t
   save-place-mode: t
   mu-keys-mode: t
   global-eldoc-mode: t
   eldoc-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   window-divider-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   buffer-read-only: t
   column-number-mode: t
   line-number-mode: t
   transient-mark-mode: t
   view-mode: t

Load-path shadows:
/home/manuel/.emacs.d/elpa/transient-20210723.1601/transient hides 
/usr/local/share/emacs/28.0.50/lisp/transient

Features:
(shadow sort mail-extr emacsbug sendmail noutline outline checkdoc pulse
color view jka-compr help-fns radix-tree elec-pair package-lint-flymake
package-lint let-alist finder finder-inf lisp-mnt bug-reference flyspell
ispell delsel image-file image-converter paren so-long company-oddmuse
company-keywords company-etags etags fileloop generator xref
company-gtags company-dabbrev-code company-dabbrev company-files
company-clang company-capf company-cmake company-semantic
company-template company-bbdb company envrc inheritenv flymake-proselint
flymake-proc flymake compile keychain-environment goto-addr thingatpt
hl-line face-remap vc-git magit-extras magit-bookmark magit-submodule
magit-obsolete magit-blame magit-stash magit-reflog magit-bisect
magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit
magit-sequence magit-notes magit-worktree magit-tag magit-merge
magit-branch magit-reset magit-files magit-refs magit-status magit
magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff
smerge-mode diff git-commit log-edit message rmc puny dired-x dired-aux
dired dired-loaddefs rfc822 mml mml-sec epa derived epg epg-config
gnus-util rmail rmail-loaddefs time-date mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr
mailabbrev mail-utils gmm-utils mailheader add-log magit-core
magit-autorevert magit-margin magit-transient magit-process with-editor
shell pcomplete comint server ansi-color magit-mode transient
format-spec magit-git magit-section magit-utils crm dash cursor-sensor
project autorevert filenotify mb-depth minibuf-eldef savehist
consult-vertico consult bookmark text-property-search pp diff-hl
log-view pcvs-util vc-dir ewoc vc vc-dispatcher diff-mode orderless
vertico modus-operandi-theme modus-themes mode-local advice find-func
recentf tree-widget wid-edit saveplace delight comp comp-cstr warnings
packages pdf-loader cl-extra help-mode hydra ring lv built-ins rx pcase
ibuf-macs core-settings edmacro kmacro disp-table core-packages
no-littering core-lib easy-mmode tex-site info package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 409418 31095)
  (symbols 48 43772 1)
  (strings 32 99103 5677)
  (string-bytes 1 3151508)
  (vectors 16 43539)
  (vector-slots 8 919095 45828)
  (floats 8 278 522)
  (intervals 56 1423 131)
  (buffers 992 19))

-- 
Manuel Uberti
www.manueluberti.eu





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

* bug#49865: 28.0.50; Customize project-find-file without thing-at-pont
  2021-08-04  6:16 bug#49865: 28.0.50; Customize project-find-file without thing-at-pont Manuel Uberti
@ 2021-08-04  8:37 ` Lars Ingebrigtsen
  2021-08-04  8:37   ` Lars Ingebrigtsen
  2021-08-06  0:51   ` Dmitry Gutov
  2021-08-06  0:36 ` Dmitry Gutov
  1 sibling, 2 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-04  8:37 UTC (permalink / raw)
  To: Manuel Uberti; +Cc: 49865

Manuel Uberti <manuel.uberti@inventati.org> writes:

> when I use project-find-file it always picks up the thing at point
> even when it is something I am pretty sure that does not correspond to
> a filename, which, in my case, is all the times.
>
> I see that in project.el, project-find-file uses project-find-file-in:
>
> ;;;###autoload
> (defun project-find-file ()
>   "Visit a file (with completion) in the current project.
>
> The completion default is the filename at point, determined by
> `thing-at-point' (whether such file exists or not)."
>   (interactive)
>   (let* ((pr (project-current t))
>          (dirs (list (project-root pr))))
>     (project-find-file-in (thing-at-point 'filename) dirs pr)))

This reminded me that I've been meaning to add a thing-at-point target
that is like `filename', but returns nil if the file named doesn't
exist, so I've now done this in Emacs 28.

Perhaps project.el should use it here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#49865: 28.0.50; Customize project-find-file without thing-at-pont
  2021-08-04  8:37 ` Lars Ingebrigtsen
@ 2021-08-04  8:37   ` Lars Ingebrigtsen
  2021-08-04  9:07     ` Manuel Uberti
  2021-08-06  0:51   ` Dmitry Gutov
  1 sibling, 1 reply; 10+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-04  8:37 UTC (permalink / raw)
  To: Manuel Uberti; +Cc: 49865

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Perhaps project.el should use it here?

In Emacs 28 (and up) only, of course.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#49865: 28.0.50; Customize project-find-file without thing-at-pont
  2021-08-04  8:37   ` Lars Ingebrigtsen
@ 2021-08-04  9:07     ` Manuel Uberti
  0 siblings, 0 replies; 10+ messages in thread
From: Manuel Uberti @ 2021-08-04  9:07 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 49865, Dmitry Gutov

On 04/08/21 10:37, Lars Ingebrigtsen wrote:
> Lars Ingebrigtsen <larsi@gnus.org> writes:
> 
>> Perhaps project.el should use it here?
> 
> In Emacs 28 (and up) only, of course.
> 

Thank you Lars!

I don't know if Dmitry got these emails, but since he worked quite a lot on 
project.el I Cc'd him.

-- 
Manuel Uberti
www.manueluberti.eu





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

* bug#49865: 28.0.50; Customize project-find-file without thing-at-pont
  2021-08-04  6:16 bug#49865: 28.0.50; Customize project-find-file without thing-at-pont Manuel Uberti
  2021-08-04  8:37 ` Lars Ingebrigtsen
@ 2021-08-06  0:36 ` Dmitry Gutov
  2021-08-06  5:27   ` Manuel Uberti
  1 sibling, 1 reply; 10+ messages in thread
From: Dmitry Gutov @ 2021-08-06  0:36 UTC (permalink / raw)
  To: Manuel Uberti, 49865

Hi Manuel,

Good timing.

On 04.08.2021 09:16, Manuel Uberti wrote:
> when I use project-find-file it always picks up the thing at point even 
> when it is something I am pretty sure that does not correspond to a 
> filename, which, in my case, is all the times.

I have just pushed a patch previously discussed in bug#49204 which 
changes this behavior as well (commit fa89537).

Let me know how you like it. It should make the "thing at point" thing 
less in-your-face, but one could still reach for it when needed.

 > I know that this is not a real bug because I can still type whatever 
I want after calling project-find-file, so I totally understand if this 
is not something worth new code in project.el. It's just that I don't 
see the point for project-find-file to suggest me as defaults things 
like "defun" or "interactive".

Seeing "(default defun): " in the prompt must have been annoying. Though 
I think it was the most problematic when the string at point is long.





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

* bug#49865: 28.0.50; Customize project-find-file without thing-at-pont
  2021-08-04  8:37 ` Lars Ingebrigtsen
  2021-08-04  8:37   ` Lars Ingebrigtsen
@ 2021-08-06  0:51   ` Dmitry Gutov
  1 sibling, 0 replies; 10+ messages in thread
From: Dmitry Gutov @ 2021-08-06  0:51 UTC (permalink / raw)
  To: Lars Ingebrigtsen, Manuel Uberti; +Cc: 49865

Hi Lars,

On 04.08.2021 11:37, Lars Ingebrigtsen wrote:
> This reminded me that I've been meaning to add a thing-at-point target
> that is like `filename', but returns nil if the file named doesn't
> exist, so I've now done this in Emacs 28.
> 
> Perhaps project.el should use it here?

I don't know if it will be the best choice here.

First of all, we already have the hook file-name-at-point-functions, 
which is consulted by read-file-name--defaults. So one can already e.g. 
move point to some existing file name, press C-x C-f M-n and with the 
power of the ffap package have the file name inserted.

But when we're completing project-wide, there will also be references 
that are not relative to the current directory (and instead relate to 
some project-configured path). Like

#include "stuff/thingy.h"

or

require 'actor/abc'

...where the string is both not relative to the current dir and is 
missing the extension.

ffap actually includes support for this, like having

(require 'cl-lib)

be recognized as '.../lisp/emacs-lisp/cl-lib.el', but it only works for 
a limited set of languages, and OOTB only for Elisp (for all others you 
need to configure variables like ffap-c++-path).





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

* bug#49865: 28.0.50; Customize project-find-file without thing-at-pont
  2021-08-06  0:36 ` Dmitry Gutov
@ 2021-08-06  5:27   ` Manuel Uberti
  2021-08-06  8:45     ` Dmitry Gutov
  0 siblings, 1 reply; 10+ messages in thread
From: Manuel Uberti @ 2021-08-06  5:27 UTC (permalink / raw)
  To: Dmitry Gutov, 49865

On 06/08/21 02:36, Dmitry Gutov wrote:
> I have just pushed a patch previously discussed in bug#49204 which changes this 
> behavior as well (commit fa89537).
> 
> Let me know how you like it. It should make the "thing at point" thing less 
> in-your-face, but one could still reach for it when needed.

Hi Dmitry,

thank you for the quick fix. The only thing that may look unfamiliar is the new 
prompt.

Let's see if I can give you an example:

- C-x p p, I pick '.emacs.d'
- f
- the prompt shows 'Find file in /home/manuel/.emacs.d'
- now I type 'valu' because I want to visit 
'/home/manuel/.emacs.d/etc/transient/values.el'
- the prompt shows 'Find file in /home/manuel/.emacs.d/valu'

At first I thought hitting RET would take me to '/home/manuel/.emacs.d/valu' 
instead of '/home/manuel/.emacs.d/etc/transient/values.el'. It doesn't, of 
course, but maybe having a prompt like 'Find file in /home/manuel/.emacs.d: 
valu' makes it clearer?

-- 
Manuel Uberti
www.manueluberti.eu





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

* bug#49865: 28.0.50; Customize project-find-file without thing-at-pont
  2021-08-06  5:27   ` Manuel Uberti
@ 2021-08-06  8:45     ` Dmitry Gutov
  2021-08-06  8:51       ` Manuel Uberti
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Gutov @ 2021-08-06  8:45 UTC (permalink / raw)
  To: Manuel Uberti, 49865

On 06.08.2021 08:27, Manuel Uberti wrote:
> At first I thought hitting RET would take me to 
> '/home/manuel/.emacs.d/valu' instead of 
> '/home/manuel/.emacs.d/etc/transient/values.el'. It doesn't, of course, 
> but maybe having a prompt like 'Find file in /home/manuel/.emacs.d: 
> valu' makes it clearer?

Thanks for the catch, this got lost with the change.





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

* bug#49865: 28.0.50; Customize project-find-file without thing-at-pont
  2021-08-06  8:45     ` Dmitry Gutov
@ 2021-08-06  8:51       ` Manuel Uberti
  2021-08-06 10:40         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 10+ messages in thread
From: Manuel Uberti @ 2021-08-06  8:51 UTC (permalink / raw)
  To: Dmitry Gutov, 49865

On 06/08/21 10:45, Dmitry Gutov wrote:
> Thanks for the catch, this got lost with the change.

It's perfect now, thanks a lot for this.

Unless Lars has something more to add, I think this can be considered solved now.

-- 
Manuel Uberti
www.manueluberti.eu





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

* bug#49865: 28.0.50; Customize project-find-file without thing-at-pont
  2021-08-06  8:51       ` Manuel Uberti
@ 2021-08-06 10:40         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-06 10:40 UTC (permalink / raw)
  To: Manuel Uberti; +Cc: 49865, Dmitry Gutov

Manuel Uberti <manuel.uberti@inventati.org> writes:

> Unless Lars has something more to add, I think this can be considered
> solved now.

Looks good to me, too, so I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2021-08-06 10:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-04  6:16 bug#49865: 28.0.50; Customize project-find-file without thing-at-pont Manuel Uberti
2021-08-04  8:37 ` Lars Ingebrigtsen
2021-08-04  8:37   ` Lars Ingebrigtsen
2021-08-04  9:07     ` Manuel Uberti
2021-08-06  0:51   ` Dmitry Gutov
2021-08-06  0:36 ` Dmitry Gutov
2021-08-06  5:27   ` Manuel Uberti
2021-08-06  8:45     ` Dmitry Gutov
2021-08-06  8:51       ` Manuel Uberti
2021-08-06 10:40         ` Lars Ingebrigtsen

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).