Discussion:
bug#43165: [PATCH] Add load this file lisp function.
(too old to reply)
Jen-Chieh Shen
2020-09-02 03:16:40 UTC
Permalink
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 <***@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
Lars Ingebrigtsen
2020-09-02 09:43:25 UTC
Permalink
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
Lars Ingebrigtsen
2020-09-02 10:23:43 UTC
Permalink
(Please keep the debbugs address in the Cc field when responding.)
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
This doesn't really seem all that useful -- `M-x load-file RET M-n RET'
gives you the same result.
Drew Adams
2020-09-02 15:51:48 UTC
Permalink
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.

Loading...