* bug#43165: [PATCH] Add load this file lisp function. @ 2020-09-02 3:16 Jen-Chieh Shen 2020-09-02 9:43 ` Lars Ingebrigtsen 0 siblings, 1 reply; 7+ messages in thread From: Jen-Chieh Shen @ 2020-09-02 3:16 UTC (permalink / raw) To: 43165 [-- Attachment #1.1: Type: text/plain, Size: 974 bytes --] 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@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 [-- Attachment #1.2: Type: text/html, Size: 1336 bytes --] [-- Attachment #2: load-this-file.patch --] [-- Type: application/octet-stream, Size: 817 bytes --] From 50101ae92761a51032c469353ff5fb203b83e6ad Mon Sep 17 00:00:00 2001 From: jenchieh <jcs090218@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 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#43165: [PATCH] Add load this file lisp function. 2020-09-02 3:16 bug#43165: [PATCH] Add load this file lisp function Jen-Chieh Shen @ 2020-09-02 9:43 ` Lars Ingebrigtsen [not found] ` <CAMiGhTPP=1ez0x=v19RKHEVPkCfU_AEbN=mDeamXfXey99R3Zw@mail.gmail.com> 0 siblings, 1 reply; 7+ messages in thread From: Lars Ingebrigtsen @ 2020-09-02 9:43 UTC (permalink / raw) To: Jen-Chieh Shen; +Cc: 43165 Jen-Chieh Shen <jcs090218@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 ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <CAMiGhTPP=1ez0x=v19RKHEVPkCfU_AEbN=mDeamXfXey99R3Zw@mail.gmail.com>]
* bug#43165: [PATCH] Add load this file lisp function. [not found] ` <CAMiGhTPP=1ez0x=v19RKHEVPkCfU_AEbN=mDeamXfXey99R3Zw@mail.gmail.com> @ 2020-09-02 10:23 ` Lars Ingebrigtsen 2020-09-02 15:51 ` Drew Adams 0 siblings, 1 reply; 7+ messages in thread From: Lars Ingebrigtsen @ 2020-09-02 10:23 UTC (permalink / raw) To: Jen-Chieh Shen; +Cc: 43165 (Please keep the debbugs address in the Cc field when responding.) Jen-Chieh Shen <jcs090218@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. ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#43165: [PATCH] Add load this file lisp function. 2020-09-02 10:23 ` Lars Ingebrigtsen @ 2020-09-02 15:51 ` Drew Adams 2020-09-03 20:28 ` Stefan Kangas 0 siblings, 1 reply; 7+ messages in thread From: Drew Adams @ 2020-09-02 15:51 UTC (permalink / raw) To: Lars Ingebrigtsen, Jen-Chieh Shen; +Cc: 43165 > 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. ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#43165: [PATCH] Add load this file lisp function. 2020-09-02 15:51 ` Drew Adams @ 2020-09-03 20:28 ` Stefan Kangas 2020-09-04 1:52 ` Lars Ingebrigtsen 0 siblings, 1 reply; 7+ messages in thread From: Stefan Kangas @ 2020-09-03 20:28 UTC (permalink / raw) To: Drew Adams; +Cc: Jen-Chieh Shen, Lars Ingebrigtsen, 43165 Drew Adams <drew.adams@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). ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#43165: [PATCH] Add load this file lisp function. 2020-09-03 20:28 ` Stefan Kangas @ 2020-09-04 1:52 ` Lars Ingebrigtsen 2020-09-04 2:13 ` Drew Adams 0 siblings, 1 reply; 7+ messages in thread From: Lars Ingebrigtsen @ 2020-09-04 1:52 UTC (permalink / raw) To: Stefan Kangas; +Cc: Jen-Chieh Shen, 43165 Stefan Kangas <stefan@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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#43165: [PATCH] Add load this file lisp function. 2020-09-04 1:52 ` Lars Ingebrigtsen @ 2020-09-04 2:13 ` Drew Adams 0 siblings, 0 replies; 7+ messages in thread From: Drew Adams @ 2020-09-04 2:13 UTC (permalink / raw) To: Lars Ingebrigtsen, Stefan Kangas; +Cc: Jen-Chieh Shen, 43165 > 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. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-09-04 2:13 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-09-02 3:16 bug#43165: [PATCH] Add load this file lisp function Jen-Chieh Shen 2020-09-02 9:43 ` Lars Ingebrigtsen [not found] ` <CAMiGhTPP=1ez0x=v19RKHEVPkCfU_AEbN=mDeamXfXey99R3Zw@mail.gmail.com> 2020-09-02 10:23 ` Lars Ingebrigtsen 2020-09-02 15:51 ` Drew Adams 2020-09-03 20:28 ` Stefan Kangas 2020-09-04 1:52 ` Lars Ingebrigtsen 2020-09-04 2:13 ` Drew Adams
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).