GNU bug report logs - #43165
[PATCH] Add load this file lisp function.

Previous Next

Package: emacs;

Reported by: Jen-Chieh Shen <jcs090218 <at> gmail.com>

Date: Wed, 2 Sep 2020 03:17:02 UTC

Severity: normal

Tags: patch, wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 43165 in the body.
You can then email your comments to 43165 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#43165; Package emacs. (Wed, 02 Sep 2020 03:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jen-Chieh Shen <jcs090218 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 02 Sep 2020 03:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jen-Chieh Shen <jcs090218 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Add load this file lisp function.
Date: Wed, 2 Sep 2020 11:16:40 +0800
[Message part 1 (text/plain, inline)]
Hi,

I think `load-this-file` could be kind of handy.Is related to `kill-buffer`
and `kill-this-buffer`, etc.

What do you guys think?

Best,

Jen-Chieh Shen



From 50101ae92761a51032c469353ff5fb203b83e6ad Mon Sep 17 00:00:00 2001
From: jenchieh <jcs090218 <at> gmail.com>
Date: Wed, 2 Sep 2020 11:11:57 +0800
Subject: [PATCH] Add load this file lisp function.

---
 lisp/files.el | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lisp/files.el b/lisp/files.el
index 3403e257a1..374df0d85d 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -900,6 +900,11 @@ recursion."
        (read-file-name "Load file: " nil nil 'lambda))))
   (load (expand-file-name file) nil nil t))

+(defun load-this-file ()
+  "Load current Lisp file."
+  (interactive)
+  (load-file (buffer-file-name)))
+
 (defun locate-file (filename path &optional suffixes predicate)
   "Search for FILENAME through PATH.
 If found, return the absolute file name of FILENAME; otherwise
-- 
2.27.0.windows.1
[Message part 2 (text/html, inline)]
[load-this-file.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43165; Package emacs. (Wed, 02 Sep 2020 09:44:01 GMT) Full text and rfc822 format available.

Message #8 received at 43165 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jen-Chieh Shen <jcs090218 <at> gmail.com>
Cc: 43165 <at> debbugs.gnu.org
Subject: Re: bug#43165: [PATCH] Add load this file lisp function.
Date: Wed, 02 Sep 2020 11:43:25 +0200
Jen-Chieh Shen <jcs090218 <at> gmail.com> writes:

> I think `load-this-file` could be kind of handy.Is related to `kill-buffer` and
> `kill-this-buffer`, etc.
>
> What do you guys think?

[...]

> +(defun load-this-file ()
> +  "Load current Lisp file."
> +  (interactive)
> +  (load-file (buffer-file-name)))

This doesn't really seem all that useful -- `M-x load-file RET M-n RET'
gives you the same result.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43165; Package emacs. (Wed, 02 Sep 2020 10:24:02 GMT) Full text and rfc822 format available.

Message #11 received at 43165 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jen-Chieh Shen <jcs090218 <at> gmail.com>
Cc: 43165 <at> debbugs.gnu.org
Subject: Re: bug#43165: [PATCH] Add load this file lisp function.
Date: Wed, 02 Sep 2020 12:23:43 +0200
(Please keep the debbugs address in the Cc field when responding.)

Jen-Chieh Shen <jcs090218 <at> gmail.com> writes:

> It’s fine, I am just an extreme lazy guy that doesn’t even want to
> type in the file I want to load. Imagine like type in, M-x load-file
> then type in the file path. It causes TWO steps! TWO steps! And if you
> do that a couple of times then this wouldn’t be fun at all. Lol

Like I said, you don't have to type in the file path.  Just do:

>  This doesn't really seem all that useful -- `M-x load-file RET M-n RET'
>  gives you the same result.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43165; Package emacs. (Wed, 02 Sep 2020 15:52:02 GMT) Full text and rfc822 format available.

Message #14 received at 43165 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Jen-Chieh Shen <jcs090218 <at> gmail.com>
Cc: 43165 <at> debbugs.gnu.org
Subject: RE: bug#43165: [PATCH] Add load this file lisp function.
Date: Wed, 2 Sep 2020 08:51:48 -0700 (PDT)
> Just do: `M-x load-file RET M-n RET'

I was going to say this yesterday, when I saw
the enhancement request.

Just do: `M-x load-file RET RET'.  No need for
`M-n'.  Of course, one needs to know this, to
do it.  I've been doing it forever.  Would I
want a key for it?  Not I.

But it's true that we have `kill-this-buffer'.

The reason we have `kill-this-buffer', I believe,
is just for a menu item (`Close': `<menu-bar>
<file> <kill-buffer>').  It makes little sense
to bind it to a keyboard key.  But someone could.

`load-file' is in the same boat, I think. There's
little use for a `load-this-file' command, in
terms of keyboard key bindings.  But I suppose
it could serve (like `Close') as a menu item.

Actually, there's a difference from `kill-buffer':
the risk of killing something unintended versus
the risk of loading something unintended.  Maybe
the same reason we show the default in the prompt,
for `kill-buffer'.

If you were to bind `kill-this-buffer' to a key,
and accidentally hit that key, bye-bye wrong
buffer, perhaps.  In a menu that's less likely
to happen.  For `load-this-file' there's less of
a "danger", if you accidentally try to load the
current file when you shouldn't.

I don't see a need for such a command, personally,
but about the same thing goes for `kill-this-buffer'.

Note, BTW, that we don't even bind `load-file'
by default.  It's not really a command that users
use every 10 minutes.

Personally, I'd say we don't need a `load-this-file'.
Just one opinion.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43165; Package emacs. (Thu, 03 Sep 2020 20:29:02 GMT) Full text and rfc822 format available.

Message #17 received at 43165 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: Jen-Chieh Shen <jcs090218 <at> gmail.com>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 43165 <at> debbugs.gnu.org
Subject: Re: bug#43165: [PATCH] Add load this file lisp function.
Date: Thu, 3 Sep 2020 20:28:02 +0000
Drew Adams <drew.adams <at> oracle.com> writes:

>> Just do: `M-x load-file RET M-n RET'
>
> I was going to say this yesterday, when I saw
> the enhancement request.
>
> Just do: `M-x load-file RET RET'.  No need for
> `M-n'.

I agree that we should not add this.  Or we would start adding '-this-'
versions for every command that asks for a file.  (Can we see some hands
for `M-x find-this-file'? ;-))

But it depends also on your completion framework, which might be the
motivation behind this request.  Ivy helpfully suggests to load the
current directory "." in this case, for example.  But that's a bug
report for the Ivy developers to handle (or maybe my messed up
configuration).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43165; Package emacs. (Fri, 04 Sep 2020 01:53:02 GMT) Full text and rfc822 format available.

Message #20 received at 43165 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Jen-Chieh Shen <jcs090218 <at> gmail.com>, 43165 <at> debbugs.gnu.org,
 Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#43165: [PATCH] Add load this file lisp function.
Date: Fri, 04 Sep 2020 03:52:27 +0200
Stefan Kangas <stefan <at> marxist.se> writes:

> I agree that we should not add this.  Or we would start adding '-this-'
> versions for every command that asks for a file.  (Can we see some hands
> for `M-x find-this-file'? ;-))

The other thing is that loading the current file is something you'd
seldom do -- you just say `M-x eval-buffer' instead.  (And that function
used to be called, funnily enough, `eval-current-buffer'.  OK, it'd have
been funnier if it had been `eval-this-buffer'.)

So I don't think adding this command would be generally useful, and I'm
closing this bug report.

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




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 04 Sep 2020 01:53:03 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 43165 <at> debbugs.gnu.org and Jen-Chieh Shen <jcs090218 <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 04 Sep 2020 01:53:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43165; Package emacs. (Fri, 04 Sep 2020 02:14:01 GMT) Full text and rfc822 format available.

Message #27 received at 43165 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Stefan Kangas <stefan <at> marxist.se>
Cc: Jen-Chieh Shen <jcs090218 <at> gmail.com>, 43165 <at> debbugs.gnu.org
Subject: RE: bug#43165: [PATCH] Add load this file lisp function.
Date: Thu, 3 Sep 2020 19:13:22 -0700 (PDT)
> The other thing is that loading the current file is something you'd
> seldom do -- you just say `M-x eval-buffer' instead.

That I disagree with.  There are several differences,
and I don't think `eval-buffer' is more commonly used
to get the common effect.

`eval-buffer' acts only on the buffer restriction,
for one major difference.





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 02 Oct 2020 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 354 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.