bug#69097: [PATCH] Add 'kill-region-or-word' command
Eli Zaretskii writes: >> From: Sean Whitton >> Date: Mon, 06 May 2024 17:51:48 +0100 >> >> On Mon 06 May 2024 at 05:46pm +01, Sean Whitton wrote: >> > >> > In bash on Linux [...] >> >> I specifically called out Linux because while GNU readline has a >> unix-word-rubout command, C-w in the Linux tty is actually implemented >> in the Linux-specific tty layer, below readline. > > Evidently, the above is inaccurate, because I see the same behavior in > Bash on MS-Windows. Ping. I am not sure how to proceed on this patch. IIRC the issue was that the notion of a word differs in Emacs and in Bash. I am still in favour of utilising Emacs's definition, as it remains more useful for some given major mode and the fact that it is easier to implement. -- Philip Kaludercic on peregrine
bug#72961: Possible documentation improvement: Clarification for package installation
Eli Zaretskii writes: >> From: Krystian Samp >> Date: Mon, 2 Sep 2024 12:41:11 +0200 >> >> I was reading the section on "Libraries of Lisp Code for Emacs" (section >> 28.8) in the Emacs manual, and I >> encountered a passage that seems a bit unclear. The text suggests that when >> using package-install, Emacs >> might automatically add initialization code to the init.el file, which >> doesn’t seem to match my experience. >> >> Specifically, the manual states: "Installing a package using package-install >> takes care of placing the package’s >> Lisp files in a directory where Emacs will find it, and also writes the >> necessary initialization code into your init >> files [...]" >> >> From my understanding, package-install does not modify init.el directly, >> which is how I interpret the >> documentation above. Instead, Emacs calls package-initialize which makes the >> installed packages available, >> automatically. >> >> I want to check if this is a valid concern / interpretation that warrants a >> documentation change. If so, I'll be >> happy to create a patch. > > Is package-quickstart.el considered "init file" or not? > > And I add Philip to this discussion, as he knows the package.el code > better than I do. I believe the documentation here is just outdated. From NEWS.27: ** Installed packages are now activated *before* loading the init file. As a result of this change, it is no longer necessary to call 'package-initialize' in your init file. Previously, a call to 'package-initialize' was automatically inserted into the init file when Emacs was started. This call can now safely be removed. Otherwise it might also refer to the fact that user option `package-selected-packages' is saved, which by default will be stored in the default Emacs configuration file. -- Philip Kaludercic on peregrine
bug#69097: [PATCH] Add 'kill-region-or-word' command
Stefan Kangas writes: > Eli Zaretskii writes: > >>> From: Philip Kaludercic >>> Cc: Sean Whitton , j...@linkov.net, >>> r...@gnu.org, >>> 69...@debbugs.gnu.org >>> Date: Sun, 01 Sep 2024 20:06:00 + >>> >>> Ping. I am not sure how to proceed on this patch. IIRC the issue was >>> that the notion of a word differs in Emacs and in Bash. I am still in >>> favour of utilising Emacs's definition, as it remains more useful >>> for some given major mode and the fact that it is easier to implement. >> >> Or you could make the defcustom a tristate, and implement both >> behaviors... >> >> As for how to proceed: Stefan and Andrea, do you have an opinion on >> this? > > Binding C-w to backward-kill-word, or some version thereof, is an old > Emacs power user trick that has been recommended in many places over the > years. See, for example: > https://sites.google.com/site/steveyegge2/effective-emacs#h.p_ID_193 > https://emacs-fu.blogspot.com/2009/11/copying-lines-without-selecting-them.html > > So I think this command would be a good addition. Making the word > boundary behaviour into a tristate option sounds like a reasonable way > forward, which should make everyone happy and let people experiment with > what works best for them. How about this suggestion: We add a generic kill-region-or-word command, and a user option for a function (set to either `backward-kill-word' or Sean's `unix-word-rubout'). I can prepare a patch with the simpler version, and then Sean can add his behaviour in a second patch so that the attribution remains correct. Sean Whitton writes: > Hello, > > On Mon 02 Sep 2024 at 11:30am -07, Stefan Kangas wrote: > >> Binding C-w to backward-kill-word, or some version thereof, is an old >> Emacs power user trick that has been recommended in many places over the >> years. See, for example: >> https://sites.google.com/site/steveyegge2/effective-emacs#h.p_ID_193 >> https://emacs-fu.blogspot.com/2009/11/copying-lines-without-selecting-them.html >> >> So I think this command would be a good addition. Making the word >> boundary behaviour into a tristate option sounds like a reasonable way >> forward, which should make everyone happy and let people experiment with >> what works best for them. > > For reference purposes while implementing the tristate, here is my > implementation of the Unix behaviour from my init. > Should be helpful, though there is lots of room for improvement :) > > (defun spw/unix-word-rubout (arg &optional pos neg) > (interactive "p") > ;; Do skip over \n because `backward-kill-word' does. > (unless pos (setq pos "[:space:]\n")) > (unless neg (setq neg "^[:space:]\n")) > (undo-boundary) > (let ((start (point))) > ;; Go only backwards. > (dotimes (_ (abs arg)) > (skip-chars-backward pos) > (skip-chars-backward neg)) > ;; Skip forward over any read-only text (e.g. an Eshell or comint > prompt). > (when-let ((beg (and (get-char-property (point) 'read-only) > (next-single-char-property-change > (point) 'read-only nil start > (goto-char beg)) > (kill-region start (point FWIW I don't have any suggestions on how to improve the function either. I wonder if it would make sense to have a minor mode like subword-mode that would enforce a understanding of words like implemented here. -- Philip Kaludercic on peregrine
bug#69097: [PATCH] Add 'kill-region-or-word' command
Sean Whitton writes: > Hello, > > On Mon 02 Sep 2024 at 08:39pm GMT, Philip Kaludercic wrote: > >> How about this suggestion: We add a generic kill-region-or-word >> command, and a user option for a function (set to either >> `backward-kill-word' or Sean's `unix-word-rubout'). I can prepare a >> patch with the simpler version, and then Sean can add his behaviour in a >> second patch so that the attribution remains correct. > > I think a tristate option is preferable to this. It would still be a user options with three states: - nil (default, don't delete a word) - #'backward-kill-word - #'unix-word-rubout > If the user wants something of their own they can just write their own > command. Sure, but going by that logic we don't need this change at all. -- Philip Kaludercic on peregrine
bug#71374: [PATCH] Simplify 'help-enable-variable-value-editing' using
Philip Kaludercic writes: > Eshel Yaron writes: > >> Philip Kaludercic writes: >> >>> Eshel Yaron writes: >>> >>>> I'm reopening this (hope you don't mind) to keep track of the minor >>>> regressions I mentioned here: >>>> >>>> https://lists.gnu.org/archive/html/emacs-devel/2024-07/msg01202.html >>> >>> Thanks, and my apologies for the late reply. >> >> No problem at all. >> >>> The issue seems to be that (thing-at-point 'sexp) returns nil if inside >>> a s-expression looking at whitespace: >>> >>> (1 2 3 4 5) >>> ^ >>> M-: (thing-at-point 'sexp) ;=> nil >>> >>> One idea is to fall back on a defun at point, if no sexp is found: >>> >>> diff --git a/lisp/help-fns.el b/lisp/help-fns.el >>> index 8ea5b301684..4d55ea8bbff 100644 >>> --- a/lisp/help-fns.el >>> +++ b/lisp/help-fns.el >>> @@ -1507,13 +1507,14 @@ help-fns-edit-variable >>>"Edit the variable under point." >>>(declare (completion ignore)) >>>(interactive) >>> - (let* ((val (thing-at-point 'sexp)) >>> - (var (get-text-property 0 'help-fns--edit-variable val))) >>> + (let ((val (or (thing-at-point 'sexp) >>> + (thing-at-point 'defun >>> (unless val >>> - (error "No variable under point")) >>> -(let ((str (read-string-from-buffer >>> -(format ";; Edit the `%s' variable." (nth 0 var)) >>> -(prin1-to-string (nth 1 var) >>> + (error "No value at point")) >>> +(let* ((var (get-text-property 0 'help-fns--edit-variable val)) >>> + (str (read-string-from-buffer >>> + (format ";; Edit the `%s' variable." (nth 0 var)) >>> + (prin1-to-string (nth 1 var) >>>(set (nth 0 var) (read str) >> >> Maybe I'm missing something, but why are val and the thing-at-point call >> needed at all? Simply grabbing the help-fns--edit-variable property at >> point should be work as well, I think. > > No, I think you are right, we don't have to take the detour over > 'thing-at-point', meaning that if I am not mistaken, the fix should > reduce itself to: > > diff --git a/lisp/help-fns.el b/lisp/help-fns.el > index 8a2ae79736f..97d054ce6db 100644 > --- a/lisp/help-fns.el > +++ b/lisp/help-fns.el > @@ -1507,9 +1507,8 @@ help-fns-edit-variable >"Edit the variable under point." >(declare (completion ignore)) >(interactive) > - (let* ((val (thing-at-point 'sexp)) > - (var (get-text-property 0 'help-fns--edit-variable val))) > -(unless val > + (let ((var (get-text-property (point) 'help-fns--edit-variable))) > +(unless var >(error "No variable under point")) > (let ((str (read-string-from-buffer > (format ";; Edit the `%s' variable." (nth 0 var)) I have pushed this change and am closing the report. >> Eshel -- Philip Kaludercic on peregrine
bug#69097: [PATCH] Add 'kill-region-or-word' command
Sean Whitton writes: > Hello, > > On Mon 02 Sep 2024 at 09:42pm +01, Sean Whitton wrote: > >> Hello, >> >> On Mon 02 Sep 2024 at 08:39pm GMT, Philip Kaludercic wrote: >> >>> How about this suggestion: We add a generic kill-region-or-word >>> command, and a user option for a function (set to either >>> `backward-kill-word' or Sean's `unix-word-rubout'). I can prepare a >>> patch with the simpler version, and then Sean can add his behaviour in a >>> second patch so that the attribution remains correct. >> >> I think a tristate option is preferable to this. >> >> If the user wants something of their own they can just write their own >> command. > > Sorry, I wrote this too quickly, I don't think I actually understand > your new proposal. > > Could you sketch it out? > > Thank you for your patience on this one. I had misremembered the last state of this patch. It is easier to just have a tristate option. Here is the updated proposal: diff --git a/lisp/simple.el b/lisp/simple.el index eedc5768fe2..9ce108089e7 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5817,6 +5817,17 @@ kill-read-only-ok :type 'boolean :group 'killing) +(defcustom kill-word-if-no-region nil + "Behaviour when `kill-region' is invoked without an active region. +If set to nil (default), then an error occurs and nothing is killed. If +set to `emacs-word', then kill a the last word as defined by the current +major mode. If set to `unix-word', then kill the last word in the style +of a shell like Bash, disregarding the major mode." + :type '(choice (const :tag "Kill a word like `backward-kill-word'" emacs-word) + (const :tag "Kill a word like Bash would" unix-word) + (const :tag "Do not kill anything" nil)) + :group 'killing) + (defun kill-region (beg end &optional region) "Kill (\"cut\") text between point and mark. This deletes the text from the buffer and saves it in the kill ring. @@ -5839,25 +5850,47 @@ kill-region the text, but put the text in the kill ring anyway. This means that you can use the killing commands to copy text from a read-only buffer. -Lisp programs should use this function for killing text. - (To delete text, use `delete-region'.) -Supply two arguments, character positions BEG and END indicating the - stretch of text to be killed. If the optional argument REGION is - non-nil, the function ignores BEG and END, and kills the current - region instead. Interactively, REGION is always non-nil, and so - this command always kills the current region." +Lisp programs should use this function for killing text. (To delete +text, use `delete-region'.) Supply two arguments, character positions +BEG and END indicating the stretch of text to be killed. If the +optional argument REGION is non-nil, the function ignores BEG and END, +and kills the current region instead. If REGION has the special value +`kill-word', then it will kill the previous word, as with +`backward-kill-word'. Interactively, REGION is always non-nil, and so +this command always kills the current region." ;; Pass mark first, then point, because the order matters when ;; calling `kill-append'. (interactive (progn (let ((beg (mark)) (end (point))) - (unless (and beg end) - (user-error "The mark is not set now, so there is no region")) - (list beg end 'region + (cond +((and beg end (use-region-p)) + (list beg end 'region)) +(kill-word-if-no-region + (list beg end kill-word-if-no-region)) +((user-error "The mark is not set now, so there is no region")) + (condition-case nil - (let ((string (if region -(funcall region-extract-function 'delete) - (filter-buffer-substring beg end 'delete + (let ((string (cond + ((eq region 'emacs-word) + (let ((end (point))) +(save-excursion + (forward-word -1) + (filter-buffer-substring (point) end 'delete + ((eq region 'unix-word) + (let ((end (point))) +(save-excursion + (skip-chars-backward "[:space:]") + (skip-chars-backward "^[:space:]") + (filter-buffer-substring + (if (get-char-property (point) 'read-only) +
bug#69097: [PATCH] Add 'kill-region-or-word' command
Eli Zaretskii writes: >> From: Philip Kaludercic >> Cc: Eli Zaretskii , Stefan Kangas , >> Andrea Corallo , j...@linkov.net, r...@gnu.org, >> 69...@debbugs.gnu.org >> Date: Mon, 02 Sep 2024 21:12:01 + >> >> I had misremembered the last state of this patch. It is easier to just >> have a tristate option. Here is the updated proposal: > > Thanks. > >> +(defcustom kill-word-if-no-region nil > > I would call this 'kill-region-dwim' instead. Can do. >> + "Behaviour when `kill-region' is invoked without an active region. >> +If set to nil (default), then an error occurs and nothing is killed. If >> +set to `emacs-word', then kill a the last word as defined by the current >> +major mode. If set to `unix-word', then kill the last word in the style >> +of a shell like Bash, disregarding the major mode." >> + :type '(choice (const :tag "Kill a word like `backward-kill-word'" >> emacs-word) >> + (const :tag "Kill a word like Bash would" unix-word) >> + (const :tag "Do not kill anything" nil)) >> + :group 'killing) > > :version tag is missing. Whoops, added it. >> -Lisp programs should use this function for killing text. >> - (To delete text, use `delete-region'.) >> -Supply two arguments, character positions BEG and END indicating the >> - stretch of text to be killed. If the optional argument REGION is >> - non-nil, the function ignores BEG and END, and kills the current >> - region instead. Interactively, REGION is always non-nil, and so >> - this command always kills the current region." >> +Lisp programs should use this function for killing text. (To delete >> +text, use `delete-region'.) Supply two arguments, character positions >> +BEG and END indicating the stretch of text to be killed. If the >> +optional argument REGION is non-nil, the function ignores BEG and END, >> +and kills the current region instead. If REGION has the special value > > Not sure why you decided to reformat this part. Its formatting was > not random. I think this was just an accidental M-q. > This also needs a NEWS entry. I've added the NEWS entry from the last iteration of the patch (now actually as a patch, not just a diff): >From 981331cfe0757b21f529be02d848a3ef7bcc4295 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Tue, 3 Sep 2024 18:29:56 +0200 Subject: [PATCH] Allow 'kill-region' kill the last word when there is no region * etc/NEWS: Document the new user option. * lisp/simple.el (kill-region-dwim): Add new option. (kill-region): Respect 'kill-region-dwim'. (Bug#69097) --- etc/NEWS | 6 ++ lisp/simple.el | 50 ++ 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 1e66f084117..7fadf52a6cf 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -123,6 +123,12 @@ When using 'visual-wrap-prefix-mode' in buffers with variable-pitch fonts, the wrapped text will now be lined up correctly so that it's exactly below the text after the prefix on the first line. +--- +** New user option 'kill-word-if-no-region'. +This option will modify the fall-back behaviour of 'kill-region' if no +region is active, and will kill the last word instead of raising an +error. + * Changes in Specialized Modes and Packages in Emacs 31.1 diff --git a/lisp/simple.el b/lisp/simple.el index eedc5768fe2..3b4453c7a8f 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5817,6 +5817,17 @@ kill-read-only-ok :type 'boolean :group 'killing) +(defcustom kill-region-dwim nil + "Behaviour when `kill-region' is invoked without an active region. +If set to nil (default), then an error occurs and nothing is killed. If +set to `emacs-word', then kill a the last word as defined by the current +major mode. If set to `unix-word', then kill the last word in the style +of a shell like Bash, disregarding the major mode." + :type '(choice (const :tag "Kill a word like `backward-kill-word'" emacs-word) + (const :tag "Kill a word like Bash would" unix-word) + (const :tag "Do not kill anything" nil)) + :group 'killing) + (defun kill-region (beg end &optional region) "Kill (\"cut\") text between point and mark. This deletes the text from the buffer and saves it in the kill ring. @@ -5843,21 +5854,44 @@ kill-region (To delete text, use `delete-region'.) Supply two arguments, character positions BEG and END indicating the stretch of text to be killed. If the optional argument REGION is -
bug#43086: [PATCH] Allow tags backend to not query for TAGS file
Dmitry Gutov writes: > Hi! > > On 28.08.2020 15:50, Philip K. wrote: > >> the xref backend for etags can be annoying at times, especially in >> combination with other backends. This patch should improve the >> situation, by allowing the user to configure how and when the etags >> backend is activated. The new user option etags-query-file would allow >> the backend to never query a TAGS file, or conditionally, depending on >> the existence of a TAGS file (in which case it can also be automatically >> loaded). > > This is a interesting patch, but it calls for some discussion: > > - The possible values all look pretty clever, but there are a lot of > them! Do we expect them all to be in demand? Ideally, I'd only leave > 2-3 of them, to reduce the number of workflows we need to care > about. The rest could probably be set up in individual user > configurations in find-file-hook (like Projectile does). > > - The variable name implies it affects how etags.el works globally, > but the actual effect seems limited to the xref backend function. We > should either rename it to something like etags-xref-query-file, or > consider having it affect tags-completion-at-point-function as > well. Maybe find-tag too. But given that > tags-completion-at-point-function has for a long time behaved in the > "never query" fashion, perhaps the easiest and most > backward-compatible option is the former. > > - One current persistent annoyance is that currently > xref-find-references doesn't work well in many files where the xref > backend is the default one (etags) when ido-mode or icomplete-mode > are enabled because it prompts for the tags file to do identifier > completion. I wonder if the "no query" option will help with this, > too. > >> I could imagine this might be extended to allow an auto-generate option, >> but that feature seems out of scope of this patch, and probably would >> require some interoperation with project.el. > > Indeed. Actually, I have an old, WIP patch for tag file > auto-generation which, yes, uses project.el. I can post it again if > you're curious. Hasn't this issue been resolved by `etags-regen-mode'? -- Philip Kaludercic on peregrine
bug#69097: [PATCH] Add 'kill-region-or-word' command
Sean Whitton writes: > Hello, > > On Tue 03 Sep 2024 at 04:32pm GMT, Philip Kaludercic wrote: > >> >> +(defcustom kill-region-dwim nil >> + "Behaviour when `kill-region' is invoked without an active region. >> +If set to nil (default), then an error occurs and nothing is killed. If >> +set to `emacs-word', then kill a the last word as defined by the current >> +major mode. If set to `unix-word', then kill the last word in the style >> +of a shell like Bash, disregarding the major mode." >> + :type '(choice (const :tag "Kill a word like `backward-kill-word'" >> emacs-word) >> + (const :tag "Kill a word like Bash would" unix-word) >> + (const :tag "Do not kill anything" nil)) >> + :group 'killing) > > I think I'm missing something here. When it's nil and there is no > *active* region, but there is a region, it should kill that, surely? > With or without TMM. > I very regularly kill inactive regions (e.g. after M->). That is not an inherent problem, we can adjust the patch by diff --git a/lisp/simple.el b/lisp/simple.el index 3b4453c7a8f..9d4d5bcd10c 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5865,11 +5865,11 @@ kill-region (let ((beg (mark)) (end (point))) (cond -((and beg end (use-region-p)) - (list beg end 'region)) -(kill-region-dwim +((and kill-region-dwim (not (use-region-p))) (list beg end kill-region-dwim)) -((user-error "The mark is not set now, so there is no region")) +((not (or beg end)) + (user-error "The mark is not set now, so there is no region")) +((list beg end 'region)) (condition-case nil (let ((string (cond to fix that issue. >> + ((eq region 'unix-word) >> + (let ((end (point))) >> +(save-excursion >> + (skip-chars-backward "[:space:]") >> + (skip-chars-backward "^[:space:]") >> + (filter-buffer-substring >> + (if (get-char-property (point) 'read-only) >> + (next-single-char-property-change >> +(point) 'read-only nil end) >> + (point)) >> + end 'delete >> + (region >> + (funcall region-extract-function 'delete)) >> + ((filter-buffer-substring beg end 'delete) > > Shall I rather commit this as an independent unix-word-rubout? > > Improves attribution, and it's independently useful. As a standalone command? Eli Zaretskii writes: >> From: Sean Whitton >> Cc: Eli Zaretskii , stefankan...@gmail.com, >> acora...@gnu.org, j...@linkov.net, r...@gnu.org, 69...@debbugs.gnu.org >> Date: Wed, 04 Sep 2024 15:07:08 +0100 >> >> > +(defcustom kill-region-dwim nil >> > + "Behaviour when `kill-region' is invoked without an active region. >> > +If set to nil (default), then an error occurs and nothing is killed. If >> > +set to `emacs-word', then kill a the last word as defined by the current >> > +major mode. If set to `unix-word', then kill the last word in the style >> > +of a shell like Bash, disregarding the major mode." >> > + :type '(choice (const :tag "Kill a word like `backward-kill-word'" >> > emacs-word) >> > + (const :tag "Kill a word like Bash would" unix-word) >> > + (const :tag "Do not kill anything" nil)) >> > + :group 'killing) >> >> I think I'm missing something here. When it's nil and there is no >> *active* region, but there is a region, it should kill that, surely? >> With or without TMM. > > Yes, you are right. It sounds like we made wrong assumptions about > what happens in that case, and should rethink this. > > C-w signals an error only if there's no mark in the buffer. > > So I guess we need a new command after all. Not necessarily (unless I am mistaken above), but I am not opposed to it either. -- Philip Kaludercic on siskin
bug#73016: Potential inclusion of kbd-mode, part of kmonad, in Non-GNU ELPA
7;window-selection-change-functions > #'kbd-mode--toggle-demo t) >(remove-hook 'focus-in-hook #'kbd-mode--create-kmonad-process t) >(remove-hook 'focus-out-hook #'kbd-mode--kill-demo-process t) > > Interactive Functions > > ;;;###autoload > (defun kbd-mode-start-demo () > "Try the current configuration in a demo buffer. > Use `kbd-mode-stop-demo' to stop the demo. If the configuration > file has errors, the demo will not start and an error buffer will > be shown instead." > (interactive) > (setq kbd-mode-demo-file > (kbd-mode--find-kbd-file (buffer-file-name (current-buffer > (if (not (kbd-mode--valid-config?)) > (kbd-mode--show-error) > (when (shell-command "ps -C kmonad") Shell-command is usually used for interactive stuff. And I don't know what you are trying to test the return value for here. (shell-command "true") ;;=> 0 (shell-command "false") ;;=> 1 (shell-command "foo") ;;=> 127 As the documentation says: In Elisp, you will often be better served by calling ‘call-process’ or ‘start-process’ directly, since they offer more control and do not impose the use of a shell (with its need to quote arguments). > (setq kbd-mode-had-kmonad? t) > (kbd-mode--kill-kmonad)) > (kbd-mode--create-demo-buffer) > (pop-to-buffer "*kmonad-demo*") > (kbd-mode--create-kmonad-process) > (kbd-mode-demo-mode t))) > > (defun kbd-mode-stop-demo () > "Stop the currently running demo." > (interactive) > (with-current-buffer "*kmonad-demo*" > (kbd-mode-demo-mode 0) > (kill-buffer-and-window) > (kbd-mode--kill-demo-process) > (when kbd-mode-had-kmonad? > (kbd-mode--start-kmonad > > (defun kbd-mode-switch () > "Switch between the demo window and the config file." > (interactive) > (select-window (get-buffer-window > (if (and (equal (buffer-name) "*kmonad-demo*") >kbd-mode-demo-mode) > (get-file-buffer kbd-mode-demo-file) > "*kmonad-demo*" > > Helper Functions > > (defun kbd-mode--create-demo-buffer () > "Create the *kmonad-demo* buffer." > (unless (get-buffer "*kmonad-demo*") > (display-buffer (get-buffer-create "*kmonad-demo*") > '(display-buffer-at-bottom > (window-height . 0.15) > > (defun kbd-mode--find-kbd-file (&optional file) > "Find the config file. > If the optional argument FILE is given, use it instead. > Otherwise, prompt the user for a choice." > (if (and file (string= (file-name-extension file) "kbd")) > file > (expand-file-name (read-file-name "Choose configuration file" > > (defun kbd-mode--valid-config? () > "Check if the current configuration is valid." > (let ((command (kbd-mode--get-config-validation-command))) > (eq 0 (shell-command command > > (defun kbd-mode--create-kmonad-process () > "Start the kmonad demo process in a dedicated buffer." > (when (get-buffer-process "*kmonad*") > (kbd-mode--kill-demo-process)) > (start-process "kmonad-emacs" "*kmonad*" "kmonad" kbd-mode-demo-file)) > > (defun kbd-mode--kill-demo-process () > "Kill demo kmonad process, if possible." > (when (get-buffer-process "*kmonad*") > (kill-process "*kmonad*"))) There might be a race condition here. > > (defun kbd-mode--kill-kmonad () > "Kill (or suspend) a running kmonad instance. > The command used to kill kmonad is given by the > `kbd-mode-kill-kmonad' variable." > (if kbd-mode-kill-kmonad > (shell-command kbd-mode-kill-kmonad) > (error "To kill the running kmonad instance, customize the > `kbd-mode-kill-kmonad' variable!"))) > > (defun kbd-mode--start-kmonad () > "Start (or resume) a new kmonad process. > The command used to start kmonad is given by the > `kbd-mode-start-kmonad' variable." > (if kbd-mode-kill-kmonad > (call-process-shell-command >;; Force the command to be executed asynchronously. >(if (eq (aref kbd-mode-start-kmonad If you always know that you are comparing character codes, I'd use = to be more specific and trigger an error if something else occurs. > (1- (length kbd-mode-start-kmonad))) >?&) >kbd-mode-start-kmonad > (concat kbd-mode-start-kmonad "&"))) > (error "To restart kmonad, customize the `kbd-mode-start-kmonad' > variable!"))) > > (defun kbd-mode--toggle-demo (&optional _window) > "Toggle the kmonad demo process. > When the users exits the demo window, kill the demo process and > start a \"normal\" kmonad process instead. When re-entering the > demo window, do the opposite; i.e., kill the running kmonad > instance and spawn a demo process." > (cond ((kbd-mode--was-demo?) > (kbd-mode--kill-demo-process) > (kbd-mode--start-kmonad)) > ((kbd-mode--valid-config?) > (kbd-mode--kill-kmonad) > (kbd-mode--create-kmonad-process)) > (t > (kbd-mode--start-kmonad) > (kbd-mode--show-error > > (defun kbd-mode--was-demo? () > "Was the previous buffer the kmonad demo buffer?" > (equal (window-buffer (previous-window)) eq should be enough here. > (get-buffer "*kmonad-demo*"))) > > (defun kbd-mode--show-error () > "Show configuration errors in a compilation buffer." > (when kbd-mode-demo-mode > (quit-window 'kill "*kmonad-demo*")) > (compile (kbd-mode--get-config-validation-command))) > > (defun kbd-mode--get-config-validation-command () > "Get validation command for `kbd-mode-demo-file'." > (concat "kmonad -d " kbd-mode-demo-file)) > > Integration with `compilation-mode' > > (add-to-list 'compilation-error-regexp-alist 'kbd) > (add-to-list 'compilation-error-regexp-alist-alist > '(kbd "^kmonad: Parse error at \\([0-9]+\\):\\([0-9]+\\)" nil 1 > 2)) > > (provide 'kbd-mode) > > ;;; kbd-mode.el ends here All in all it looks fine, most of my superficial comments are nitpicks. -- Philip Kaludercic on siskin
bug#69097: [PATCH] Add 'kill-region-or-word' command
Eli Zaretskii writes: >> From: Philip Kaludercic >> Cc: Eli Zaretskii , stefankan...@gmail.com, >> acora...@gnu.org, j...@linkov.net, r...@gnu.org, 69...@debbugs.gnu.org >> Date: Thu, 05 Sep 2024 09:39:32 + >> >> >> I think I'm missing something here. When it's nil and there is no >> >> *active* region, but there is a region, it should kill that, surely? >> >> With or without TMM. >> > >> > Yes, you are right. It sounds like we made wrong assumptions about >> > what happens in that case, and should rethink this. >> > >> > C-w signals an error only if there's no mark in the buffer. >> > >> > So I guess we need a new command after all. >> >> Not necessarily (unless I am mistaken above), but I am not opposed to it >> either. > > If we don't introduce a new command, then what will be the modified > behavior of kill-region? Specifically, when will it delete the last > word? If the new user option is non-nil /and/ there is no region. If `kill-region-dwim' is nil (default), then nothing should change. > >In Emacs buffers, it is very rare not to have the mark, so it > sounds like the Bash-like behavior will very rarely if ever available, > no? It will kick-in whenever `use-region-p' returns a non-nil value. I recognise that this isn't useful for people who don't rely on transient mark mode, but in that case we'll need to commands anyway, as I don't want to use the behaviour that Sean describes. -- Philip Kaludercic on siskin
bug#69097: [PATCH] Add 'kill-region-or-word' command
Eli Zaretskii writes: >> From: Philip Kaludercic >> Cc: spwhit...@spwhitton.name, stefankan...@gmail.com, acora...@gnu.org, >> j...@linkov.net, r...@gnu.org, 69...@debbugs.gnu.org >> Date: Thu, 05 Sep 2024 10:02:45 + >> >> Eli Zaretskii writes: >> >> > If we don't introduce a new command, then what will be the modified >> > behavior of kill-region? Specifically, when will it delete the last >> > word? >> >> If the new user option is non-nil /and/ there is no region. If >> `kill-region-dwim' is nil (default), then nothing should change. >> >> > >> >In Emacs buffers, it is very rare not to have the mark, so it >> > sounds like the Bash-like behavior will very rarely if ever available, >> > no? >> >> It will kick-in whenever `use-region-p' returns a non-nil value. > > Non-nil or nil? Above you say "there's no region", which AFAIU means > use-region-p returns nil. Right, my bad. >> I recognise that this isn't useful for people who don't rely on >> transient mark mode, but in that case we'll need to commands anyway, >> as I don't want to use the behaviour that Sean describes. > > Which is why I think we will need a separate command after all. OK, but we can add that independently of this patch. -- Philip Kaludercic on siskin
bug#73004: [PATCH] Make `dired-do-open' work on non GNU/Linux systems
Manuel Giraud writes: > Tags: patch > > Hi, > > Here is a patch to make `dired-do-open' work on some non GNU/Linux > systems. I have tested it on OpenBSD with "xdg-open" installed. > > Thanks, > > In GNU Emacs 31.0.50 (build 19, x86_64-unknown-openbsd7.6) of 2024-09-02 > built on computer > Repository revision: 92ea393a16e5c99a8860dab368c6ca3ca6abc3c5 > Repository branch: master > Windowing system distributor 'The X.Org Foundation', version 11.0.12101013 > System Description: OpenBSD computer 7.6 GENERIC.MP#294 amd64 > > Configured using: > 'configure CC=egcc CPPFLAGS=-I/usr/local/include > LDFLAGS=-L/usr/local/lib MAKEINFO=gmakeinfo --prefix=/home/manuel/emacs > --bindir=/home/manuel/bin --with-x-toolkit=no --without-cairo > --without-compress-install' > >>From ab26a89395b5745c8e3d87a8907344ba774a5ca1 Mon Sep 17 00:00:00 2001 > From: Manuel Giraud > Date: Tue, 3 Sep 2024 15:13:51 +0200 > Subject: [PATCH] Make `dired-do-open' work on non GNU/Linux systems > > * lisp/dired-aux.el (dired-do-open): Permit this function to > work on some non GNU/Linux systems. > --- > lisp/dired-aux.el | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el > index cd948bd7dd9..97b1e28a4ff 100644 > --- a/lisp/dired-aux.el > +++ b/lisp/dired-aux.el > @@ -1472,7 +1472,7 @@ dired-do-open > (when command >(dolist (file files) > (cond > - ((memq system-type '(gnu/linux)) > + ((memq system-type '(gnu/linux berkeley-unix)) Are these the only systems with xdg-open? And is xdg-open reliably available on BSD systems, so that we don't generate an opaque error message if that is not the case? > (call-process command nil 0 nil file)) > ((memq system-type '(ms-dos)) >(shell-command (concat command " " (shell-quote-argument file > -- > 2.46.0 -- Philip Kaludercic on siskin
bug#73004: [PATCH] Make `dired-do-open' work on non GNU/Linux systems
Eli Zaretskii writes: >> Cc: 73...@debbugs.gnu.org >> Date: Thu, 05 Sep 2024 15:48:12 +0200 >> From: Manuel Giraud via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> > And is xdg-open reliably available on BSD systems, so that we don't >> > generate an opaque error message if that is not the case? >> >> I think it would work whether xdg-open is install or not because >> `shell-command-guess-open' is defined by testing the presence of >> xdg-open. So if xdg-open is not installed, `command' in the code above >> will be nil and nothing will happen. > > Then why do we need to condition this by system-type at all? Juri implemented the command, so perhaps he could explain. I don't understand why one doesn't just use `shell-command-guess-open' directly? -- Philip Kaludercic on siskin
bug#69097: [PATCH] Add 'kill-region-or-word' command
Sean Whitton writes: > Hello, > > On Thu 05 Sep 2024 at 09:39am GMT, Philip Kaludercic wrote: > >>>> + ((eq region 'unix-word) >>>> + (let ((end (point))) >>>> +(save-excursion >>>> + (skip-chars-backward "[:space:]") >>>> + (skip-chars-backward "^[:space:]") >>>> + (filter-buffer-substring >>>> + (if (get-char-property (point) 'read-only) >>>> + (next-single-char-property-change >>>> +(point) 'read-only nil end) >>>> + (point)) >>>> + end 'delete >>>> + (region >>>> + (funcall region-extract-function 'delete)) >>>> + ((filter-buffer-substring beg end 'delete) >>> >>> Shall I rather commit this as an independent unix-word-rubout? >>> >>> Improves attribution, and it's independently useful. >> >> As a standalone command? > > I mean, yeah, I have had it on my C-w for years. Probably some other > people have implementations too. In that case, it would be difficult to use it directly in this implementation, as kill-region needs a command that just moves the point. I guess it would be possible to hack something together with atomic change groups, but the cleanest strategy would probably be to have a unix-word-forward command that goes in both directions, and use that both in a standalone unix-word-rubout and this patch. But we can do that after merging this patch -- assuming there are no more blocking issues with the latest version: >From fa7b5158fb1507db32a7b537137418afa024cfad Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Tue, 3 Sep 2024 18:29:56 +0200 Subject: [PATCH] Allow 'kill-region' kill the last word when there is no region * etc/NEWS: Document the new user option. * lisp/simple.el (kill-region-dwim): Add new option. (kill-region): Respect 'kill-region-dwim'. (Bug#69097) --- etc/NEWS | 8 +++- lisp/simple.el | 49 ++--- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 1e66f084117..60efbfb43d8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -123,6 +123,12 @@ When using 'visual-wrap-prefix-mode' in buffers with variable-pitch fonts, the wrapped text will now be lined up correctly so that it's exactly below the text after the prefix on the first line. +--- +** New user option 'kill-word-if-no-region'. +This option will modify the fall-back behaviour of 'kill-region' if no +region is active, and will kill the last word instead of raising an +error. + * Changes in Specialized Modes and Packages in Emacs 31.1 @@ -268,7 +274,7 @@ any. ** Diff --- -*** New command 'diff-kill-ring-save'. +*** New command 'diff-kill-dwim'. This command copies to the 'kill-ring' a region of text modified according to diffs in the current buffer, but without applying the diffs to the original text. If the selected range extends a hunk, the diff --git a/lisp/simple.el b/lisp/simple.el index eedc5768fe2..efa338f0b0d 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5817,6 +5817,18 @@ kill-read-only-ok :type 'boolean :group 'killing) +(defcustom kill-region-dwim nil + "Behaviour when `kill-region' is invoked without an active region. +If set to nil (default), the behaviour of `kill-region' stays the same. +If set to `emacs-word', then kill the last word as defined by the +current major mode. If set to `unix-word', then kill the last word in +the style of a shell like Bash, disregarding the major mode." + :type '(choice (const :tag "Kill a word like `backward-kill-word'" emacs-word) + (const :tag "Kill a word like Bash would" unix-word) + (const :tag "Do not kill anything" nil)) + :group 'killing + :version "31.1") + (defun kill-region (beg end &optional region) "Kill (\"cut\") text between point and mark. This deletes the text from the buffer and saves it in the kill ring. @@ -5843,21 +5855,44 @@ kill-region (To delete text, use `delete-region'.) Supply two arguments, character positions BEG and END indicating the stretch of text to be killed. If the optional argument REGION is - non-nil, the function ignores BEG and END, and kills the current + `region', the function ignores BEG and END, and kills the c
bug#69097: [PATCH] Add 'kill-region-or-word' command
l delim) > + "Move forward ARG unix-words. > +A unix-word is whitespace-delimited. > +Interactively, ARG is the numeric prefix argument, defaulting to 1. > +A negative ARG means go backwards to the beginning of unix-words. > + > +Unix-words differ from Emacs words in that they are always delimited by > +whitespace, regardless of the buffer's syntax table. This command > +emulates how C-w at the Unix terminal or shell identifies words. Should you mention the ^W notation here as well? > + > +When called from Lisp, DELIM specifies what characters are considered > +whitespace. It is a string as might be passed to `skip-chars-forward'. > +The default is \" \\f\\n\\r\\t\\v\". Do not prefix a `^' character." I think it would be worth checking for a ^ and then throwing a user-error. > + (interactive "^p") > + (unless (zerop arg) > +;; We do skip over newlines by default because `backward-word' does. > +(let* ((delim (or delim " \f\n\r\t\v")) ^ I'd use "\s" here (and below). > + (ndelim (format "^%s" delim)) > + (start (point)) > + (fun (if (> arg 0) > +#'skip-chars-forward > + #'skip-chars-backward))) > + (dotimes (_ (abs arg)) > +(funcall fun delim) > +(funcall fun ndelim)) > + (constrain-to-field nil start > + > +(defun unix-word-rubout (arg) > + "Kill ARG unix-words backwards. > +A unix-word is whitespace-delimited. > +Interactively, ARG is the numeric prefix argument, defaulting to 1. > +A negative ARG means to kill forwards. > + > +Unix-words differ from Emacs words in that they are always delimited by > +whitespace, regardless of the buffer's syntax table. Thus, this command > +emulates C-w at the Unix terminal or shell identifies words. > +See also this command's nakesake in Info node > +`(readline)Commands For Killing'." > + (interactive "^p") > + (let ((start (point))) > + (forward-unix-word (- arg)) > +(kill-region start (point Won't there be an error here if the command is invoked with a negative argument? > + > +(defun unix-filename-rubout (arg) > + "Kill ARG unix-words backwards, also treating `/' as whitespace. > +A unix-word is whitespace-delimited. > +Interactively, ARG is the numeric prefix argument, defaulting to 1. > +A negative ARG means to kill forwards. > + > +This is like `unix-word-rubout' (which see), but `/' is also considered > +whitespace. See this command's namesake in Info node > +`(readline)Commands For Killing'." > + (interactive "^p") > + (let ((start (point))) > +(forward-unix-word (- arg) "/ \f\n\r\t\v") > +(kill-region start (point > > (defcustom fill-prefix nil >"String for filling to insert at front of new line, or nil for none." -- Philip Kaludercic on siskin
bug#69097: [PATCH] Add 'kill-region-or-word' command
Eli Zaretskii writes: >> From: Sean Whitton >> Cc: phil...@posteo.net, stefankan...@gmail.com, acora...@gnu.org, >> j...@linkov.net, r...@gnu.org, 69...@debbugs.gnu.org >> Date: Fri, 06 Sep 2024 14:54:58 +0100 >> >> +(defun forward-unix-word (arg &optional delim) >> + "Move forward ARG unix-words. >> +A unix-word is whitespace-delimited. >> +Interactively, ARG is the numeric prefix argument, defaulting to 1. >> +A negative ARG means go backwards to the beginning of unix-words. > > I again ask whether we need this command. It is okay to have a > function (perhaps even an internal one) to move by Unix-words, but > what are the use cases for such a command? I think it is conceivable that some users might prefer to have deterministic word movement that doesn't change depending on the major mode. But as mention earlier, this is functionality that might be worth relegating into a subword-mode-like mode, instead of defining new commands. >> +(defun unix-filename-rubout (arg) >> + "Kill ARG unix-words backwards, also treating `/' as whitespace. >> +A unix-word is whitespace-delimited. >> +Interactively, ARG is the numeric prefix argument, defaulting to 1. >> +A negative ARG means to kill forwards. >> + >> +This is like `unix-word-rubout' (which see), but `/' is also considered >> +whitespace. > > I'd say '/' is treated as word delimiter. "Considered whitespace" > sounds strange to me. > > Should we also treat a backslash as delimiter, for MS-Windows? -- Philip Kaludercic on siskin
bug#73084: [PATCH] Include the variable name in the `setopt` warning
Okamsn writes: > Hello, > > The attached patch adds the variable name to the `setopt` warning. > > I write my Emacs config in an Org file, from which I make the Emacs Lisp > file. Currently, if `setopt` detects that the value I wish to make a > variable hold does not conform to the variable's Custom.el type, then it > reports the type and the problematic value, but not the variable itself, > when I open Emacs. This adds extra steps to editing the code in the Org > file to fix the warning, especially when the value is created > programmatically. It would be faster to search for the variable name > directly in the Org file and to then re-tangle the Org file. I think this is a good idea! What might also be useful would be to generate line warnings, as the backtrace should have the necessary information. > Thank you. > > From 7cc7134b1b751428b7c14a0b54f55193a59363b1 Mon Sep 17 00:00:00 2001 > From: Earl Hyatt > Date: Fri, 6 Sep 2024 20:04:24 -0400 > Subject: [PATCH] Include the variable name in the warning in `setopt--set'. > > Including the variable name makes it easier to find the location of the > error. > > * lisp/cus-edit.el (setopt--set): Include the variable name in the > warning. > --- > lisp/cus-edit.el | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el > index 9f5ac47490c..035499deb71 100644 > --- a/lisp/cus-edit.el > +++ b/lisp/cus-edit.el > @@ -1072,7 +1072,7 @@ setopt--set >;; Check that the type is correct. >(when-let ((type (get variable 'custom-type))) > (unless (widget-apply (widget-convert type) :match value) > - (warn "Value `%S' does not match type %s" value type))) > + (warn "`%s': Value `%S' does not match type %s" variable value type))) >(put variable 'custom-check-value (list value)) >(funcall (or (get variable 'custom-set) #'set-default) variable value)) -- Philip Kaludercic on siskin
bug#69097: [PATCH] Add 'kill-region-or-word' command
Sean Whitton writes: > Hello, > > Thank you both for the feedback. Attached is an updated version. > > A few replies: > > On Fri 06 Sep 2024 at 04:32pm GMT, Philip Kaludercic wrote: > >> Won't there be an error here if the command is invoked with a negative >> argument? > > Do you mean that you think there should be an error? > I don't see any need for that. I had mistakenly assumed that (kill-region start (point)) would throw an error if (> start (point)), and that it would be better to catch that case earlier. But I just checked, and kill-region does the right thing, so forget about it. -- Philip Kaludercic on icterid
bug#73102: 29.4; `package-recompile-all' should skip packages installed by distro package manager
Zhengyi Fu writes: > When I try recompiling all packages installed by package.el with `M-x > package-recompile-all', I got the following error: > > Debugger entered--Lisp error: (permission-denied "Removing old name" > "Permission denied" "/usr/share/emacs/site-lisp/elpa/mu4e-1.10.8/mu4e-a...") > package-recompile(#s(package-desc :name mu4e :version (1 10 8) :summary > "the mu mail user agent" :reqs nil :kind nil :archive nil :dir > "/usr/share/emacs/site-lisp/elpa/mu4e-1.10.8" :extras nil :signed nil)) > package-recompile-all() > funcall-interactively(package-recompile-all) > command-execute(package-recompile-all record) > execute-extended-command(nil "package-recompile-all" "recom all") > funcall-interactively(execute-extended-command nil "package-recompile-all" > "recom all") > command-execute(execute-extended-command) > > This is possibly because the package `mu4e' was installed by the distro > package manager in a path where normal users don't have write access. > > I think `package-recompile-all' should either skip those packages that > are not installed by package.el or ignore such errors and continue to > recompile other packages. We have installed a patch in Bug#68678 on master (the commit is from last February, so you wouldn't see it yet on 29.4) that wraps the `package-recompile' call in a `with-demoted-errors' block. That would still emit a error message, but it wouldn't break the recompilation procedure. Do you think that is enough, or should be explicitly and additionally avoid re-compiling external packages? -- Philip Kaludercic on icterid
bug#69097: [PATCH] Add 'kill-region-or-word' command
Sean Whitton writes: > Hello Eli, > > Any comments on v4? I'd like to commit to unblock Philip. Thanks! Here is my updated patch. If you want to, you can push both at once so that we can close the issue more quickly as soon as Eli has time to take a look: >From 0f19dadb75a01873cb3f40a6addd825e63c266ce Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Tue, 3 Sep 2024 18:29:56 +0200 Subject: [PATCH] Allow 'kill-region' kill the last word when there is no region * etc/NEWS: Document the new user option. * lisp/simple.el (kill-region-dwim): Add new option. (kill-region): Respect 'kill-region-dwim'. (Bug#69097) --- etc/NEWS | 7 +++ lisp/simple.el | 41 ++--- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index add438e8b6a..8cde2c294a9 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -129,6 +129,13 @@ Unix-words are words separated by whitespace regardless of the buffer's syntax table. In a Unix terminal or shell, C-w kills by Unix-word. The new commands 'unix-word-rubout' and 'unix-filename-rubout' allow you to bind keys to operate more similarly to the terminal. + +--- +** New user option 'kill-word-dwim'. +This option will modify the fall-back behaviour of 'kill-region' if no +region is active, and will kill the last word instead of raising an +error. + * Changes in Specialized Modes and Packages in Emacs 31.1 diff --git a/lisp/simple.el b/lisp/simple.el index bbb13c1b471..d1be33ce87d 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5817,6 +5817,19 @@ kill-read-only-ok :type 'boolean :group 'killing) +(defcustom kill-region-dwim nil + "Behaviour when `kill-region' is invoked without an active region. +If set to nil (default), the behaviour of `kill-region' stays the same. +If set to `emacs-word', then kill the last word as defined by the +current major mode. If set to `unix-word', then kill the last word in +the style of a shell like Bash, disregarding the major mode like with +`unix-word-rubout'." + :type '(choice (const :tag "Kill a word like `backward-kill-word'" emacs-word) + (const :tag "Kill a word like Bash would" unix-word) + (const :tag "Do not kill anything" nil)) + :group 'killing + :version "31.1") + (defun kill-region (beg end &optional region) "Kill (\"cut\") text between point and mark. This deletes the text from the buffer and saves it in the kill ring. @@ -5843,21 +5856,35 @@ kill-region (To delete text, use `delete-region'.) Supply two arguments, character positions BEG and END indicating the stretch of text to be killed. If the optional argument REGION is - non-nil, the function ignores BEG and END, and kills the current + `region', the function ignores BEG and END, and kills the current region instead. Interactively, REGION is always non-nil, and so - this command always kills the current region." + this command always kills the current region. It is possible to + override this behaviour by customising the user option + `kill-region-dwim'." ;; Pass mark first, then point, because the order matters when ;; calling `kill-append'. (interactive (progn (let ((beg (mark)) (end (point))) - (unless (and beg end) + (cond +((and kill-region-dwim (not (use-region-p))) + (list beg end kill-region-dwim)) +((not (or beg end)) (user-error "The mark is not set now, so there is no region")) - (list beg end 'region +((list beg end 'region)) + (condition-case nil - (let ((string (if region -(funcall region-extract-function 'delete) - (filter-buffer-substring beg end 'delete + (let ((string (cond + ((memq region '(unix-word emacs-word)) + (let ((end (point))) +(save-excursion + (if (eq region 'emacs-word) + (forward-word -1) +(forward-unix-word -1)) + (filter-buffer-substring (point) end 'delete + (region + (funcall region-extract-function 'delete)) + ((filter-buffer-substring beg end 'delete) (when string ;STRING is nil if BEG = END ;; Add that string to the kill ring, one way or another. (if (eq last-command 'kill-region) -- 2.45.2 -- Philip Kaludercic on siskin
bug#73102: 29.4; `package-recompile-all' should skip packages installed by distro package manager
Zhengyi Fu writes: > Philip Kaludercic writes: > >> Zhengyi Fu writes: >> >>> When I try recompiling all packages installed by package.el with `M-x >>> package-recompile-all', I got the following error: >>> >>> Debugger entered--Lisp error: (permission-denied "Removing old name" >>> "Permission denied" >>> "/usr/share/emacs/site-lisp/elpa/mu4e-1.10.8/mu4e-a...") >>> package-recompile(#s(package-desc :name mu4e :version (1 10 8) >>> :summary "the mu mail user agent" :reqs nil :kind nil :archive nil >>> :dir "/usr/share/emacs/site-lisp/elpa/mu4e-1.10.8" :extras nil >>> :signed nil)) >>> package-recompile-all() >>> funcall-interactively(package-recompile-all) >>> command-execute(package-recompile-all record) >>> execute-extended-command(nil "package-recompile-all" "recom all") >>> funcall-interactively(execute-extended-command nil >>> "package-recompile-all" "recom all") >>> command-execute(execute-extended-command) >>> >>> This is possibly because the package `mu4e' was installed by the distro >>> package manager in a path where normal users don't have write access. >>> >>> I think `package-recompile-all' should either skip those packages that >>> are not installed by package.el or ignore such errors and continue to >>> recompile other packages. >> >> We have installed a patch in Bug#68678 on master (the commit is from >> last February, so you wouldn't see it yet on 29.4) that wraps the >> `package-recompile' call in a `with-demoted-errors' block. That would >> still emit a error message, but it wouldn't break the recompilation >> procedure. Do you think that is enough, or should be explicitly and >> additionally avoid re-compiling external packages? > > Yes. That patch is enough for me. Thanks!! Great, I'll close this report then. If you haven't fixed the issue locally yet: Until you upgrade, a simple fix would be to add some advice around package-recompile that wraps it in a `with-demoted-errors' block. -- Philip Kaludercic on siskin