unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
To: emacs-devel@gnu.org
Cc: "João Távora" <joaotavora@gmail.com>
Subject: icomplete-fido-backward-updir litters kill-ring
Date: Fri, 12 Jun 2020 21:20:54 -0700	[thread overview]
Message-ID: <E71CAF0F-3CF7-4DAA-ABA1-B6ADE0866640@schwartzmeyer.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1753 bytes --]

Hello,

Please tell me if this should be redirected to the bug report mailing list. It’s less a bug and more an undesired behavior. While using fido-mode, I noticed my kill-ring just getting littered with…stuff. Turns out that icomplete-fido-backward-updir uses zap-up-to-char, which kills instead of deletes:

(defun icomplete-fido-backward-updir ()
  "Delete char before or go up directory, like `ido-mode'."
  (interactive)
  (if (and (eq (char-before) ?/)
           (eq (icomplete--category) 'file))
      (zap-up-to-char -1 ?/)
    (call-interactively 'backward-delete-char)))

(defun zap-up-to-char (arg char)
  "Kill up to, but not including ARGth occurrence of CHAR.
Case is ignored if `case-fold-search' is non-nil in the current buffer.
Goes backward if ARG is negative; error if CHAR not found.
Ignores CHAR at point."
  (interactive "p\ncZap up to char: ")
  (let ((direction (if (>= arg 0) 1 -1)))
    (kill-region (point)
		 (progn
		   (forward-char direction)
		   (unwind-protect
		       (search-forward (char-to-string char) nil nil arg)
		     (backward-char direction))
		   (point)))))

Since the function zap-up-to-char does a kill, if you’ve typed out a path /foo/bar/baz/, then decide to look elsewhere and hit DEL DEL DEL, they all get killed (not just deleted).

We could an optional arg to zap-up-to-char so that it can call delete-region instead of kill-region, or duplicate the code in it, or something else entirely.

João, what do you think? Perhaps this was intended behavior, but it doesn’t seem like it.

Thanks,

Andy

P.S. With Emacs 28 I’m super happy with how much 3rdparty stuff I’m getting to replace with GNU code, either built-in or in ELPA. Like fido-mode :)

[-- Attachment #2: Type: text/html, Size: 3897 bytes --]

             reply	other threads:[~2020-06-13  4:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-13  4:20 Andrew Schwartzmeyer [this message]
2020-06-13 17:51 ` icomplete-fido-backward-updir litters kill-ring João Távora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E71CAF0F-3CF7-4DAA-ABA1-B6ADE0866640@schwartzmeyer.com \
    --to=andrew@schwartzmeyer.com \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).