Coder Social home page Coder Social logo

Comments (7)

jethrokuan avatar jethrokuan commented on July 25, 2024 1

Just wanted to add that another mode that this interferes with is shell-modes (e.g. in vterm), where Ctrl-r is used to search history.

from ctrlf.

raxod502 avatar raxod502 commented on July 25, 2024

Making the mode per-buffer is a fine solution. I would be fine with adding a denylist of major/minor modes by default to CTRLF. Regarding the Isearch interface functions, is it sufficient for compatibility to call those instead of re-search-forward and re-search-backward? Does the highlighting also need to change?

from ctrlf.

andersjohansson avatar andersjohansson commented on July 25, 2024

I think buffer-local is the easiest thing to do now. I looked a bit more into the code pdf-iseach uses to redefine how searches are done and it also involves things like setting state when starting and quitting, isearch-push-state-function. And there doesn't really seem to be a simple forwardand backwardfunction, maybe the redefined isearch-search-fun-function is supposed to take care of both. It also seems like pdf-iseach-search-functionis very dependent on isearch. I couldn’t find documentation of how this works beyond looking through the code, but it seems it would be too much extra stuff to add to ctrlf for little gain.

from ctrlf.

raxod502 avatar raxod502 commented on July 25, 2024

I see... unfortunately Isearch doesn't run into this problem because it's allowed to stick itself into global-map. I don't think we can get away with that, so perhaps a denylist is the best option.

There is of course also the horrifying hack solution of defining an extended menu item for the CTRLF keybinding which provides a filter function that let-binds ctrlf-mode back to nil and then does a key lookup to see if C-r would resolve to isearch-backward and only substituting with ctrlf-literal-backward in that case. But I do think that is quite a bit too horrifying.

from ctrlf.

raxod502 avatar raxod502 commented on July 25, 2024

I've come up with a more robust keymapping scheme. It's a bit of a hack but should address the conflicting needs of these various bug reports. My new solution should solve #51, #52, #67, and #80 simultaneously while also working with remap bindings. I have tested it a bit and it seems to work, but I don't actually use most of the modes that have been mentioned in these issue reports, so I could use some help to confirm if the bug is resolved for all of them.

from ctrlf.

andersjohansson avatar andersjohansson commented on July 25, 2024

Hi, checking out the changes in ddfbc35, I still think that ctrlf needs to be disabled in pdf-view, since the remapping will remap isearch-forward etc. which is the command that should be invoked, but whose behaviour is changed in pdf-isearch-minor-mode (as discussed above).

This works well though:

(add-hook 'pdf-isearch-minor-mode-hook (lambda () (ctrlf-local-mode -1)))

The question is if a deny-list should be implemented. Something simple like:

(defun ctrlf-disable-local-mode ()
  "Unconditionally disable ‘ctrlf-local-mode’."
  (ctrlf-local-mode -1))

(defcustom ctrlf-deny-mode-hooks
  '(pdf-isearch-minor-mode-hook
    Info-mode-hook)
  "List of mode hooks where ctrlf should be disabled."
  :type '(repeat variable))

;; where should this be done?
(dolist (hook ctrlf-deny-mode-hooks)
  (add-hook hook #'ctrlf-disable-local-mode))

It’s no problem to write to a hook variable that is not defined, so no need to check if the mode is loaded or anything.

from ctrlf.

raxod502 avatar raxod502 commented on July 25, 2024

Gotcha. Yes, that makes sense.

Honestly, thinking about the implications of load order and all that, I'd suggest not having a user option for this, and just putting the add-hook declarations individually into ctrlf.el (perhaps all wrapped in a check on a boolean user option, so that it can be disabled if absolutely necessary for some reason). Then, if you want to override a default, you can either just add-hook yourself, or you can remove-hook one of the existing ones.

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.