Coder Social home page Coder Social logo

Comments (7)

andyleejordan avatar andyleejordan commented on July 25, 2024 1

Heh:

C-w runs the command isearch-yank-word-or-char

Hit this one too. I think it would be ideal if ctrlf were as close as a drop-in upgrade to isearch as possible.

from ctrlf.

raxod502 avatar raxod502 commented on July 25, 2024 1

Yep. Great suggestions, thanks.

from ctrlf.

jnboehm avatar jnboehm commented on July 25, 2024 1

I'm also in full support of this, the lack of C-w tripped me up.

from ctrlf.

publicimageltd avatar publicimageltd commented on July 25, 2024

Thanks a lot for a nice package, I like it very much! I just wanted to add 1 for C-w, which I use often, too. :-)

from ctrlf.

raxod502 avatar raxod502 commented on July 25, 2024

Hmmm... actually, not sure I can totally support C-w as a top-level binding. Maybe we can put it under M-s or something, and we can certainly make the keymap customizable so you could add it yourself, but one of the goals of CTRLF is that the search input behaves normally. So you'd expect C-w to kill the region. I suppose I wouldn't be opposed to installing by default a special command that will delegate to isearch-yank-word-or-char behavior if and only if there is no active region.

from ctrlf.

publicimageltd avatar publicimageltd commented on July 25, 2024

Good idea, making it depend on the active region. I tried a simple conditional which checks for active mark, but simply calling isearch-yank-word-or-char caused an error. I couldn't find out what caused it. There's some implicit dependence in the code I couldn't figure out. I also tried to explicitly set the text buffer current before calling isearch...., no luck. So I came up with this solution, which is at least a first workaround:

  (defun ctrlf-c-w (begin end)
    "Kill region if active, else yank symbol at point."
    (interactive "r")
    (if mark-active
	(kill-region begin end)
      (ctrlf-forward-symbol-at-point)))

This works. If you have any ideas how to delegate it to isearch, I'd add this. But as I said, simply calling isearch-yank-word-or-char, either with the text buffer explicitly set as current buffer or not, does not work.

from ctrlf.

raxod502 avatar raxod502 commented on July 25, 2024

Well, looking at the source for isearch-yank-internal, I'd say the problem is Isearch keeps point in the actual buffer being searched, while CTRLF keeps it in the minibuffer. Thus buffer-substring-no-properties has entirely the wrong effect. Furthermore, isearch-yank-word-or-char operates by setting a bunch of Isearch variables and calling some Isearch functions, not by just inserting text into the minibuffer. The whole thing would need to be redone for CTRLF.

Protip: there is a function use-region-p you can use instead of checking the mark-active variable.

from ctrlf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.