From e49ad5e584aad989316b7fe88b039e92f8ba183b Mon Sep 17 00:00:00 2001 From: Anders Johansson Date: Fri, 12 Jun 2020 16:02:34 +0200 Subject: [PATCH 1/2] Make it possible to disable ctrlf-mode locally in buffers Do this by defining ctrlf-local-mode as a local minor mode and ctrlf-mode as a global minor mode --- CHANGELOG.md | 2 ++ README.md | 11 +++++++++++ ctrlf.el | 10 ++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56326bd..f1f645f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ The format is based on [Keep a Changelog]. conflict with them. If you remapped the Isearch commands in your configuration, this means you will need to update `ctrlf-mode-bindings`. See [#51]. +* It is now possible to disable `ctrlf-mode` buffer locally by + disabling `ctrlf-local-mode` in mode hooks etc. See [#53]. ### Bugs fixed * CTRLF previously caused an error during Emacs startup unless the diff --git a/README.md b/README.md index 68495c5..b961227 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,17 @@ following steps: `ctrlf-forward` and `ctrlf-backward`, respectively, as subroutines. * Bind these functions in `ctrlf-mode-bindings`. +### Disabling CTRLF locally + +`ctrlf-mode` is a globalized minor mode that enables the buffer-local +minor mode `ctrlf-local-mode`. This makes it possible to disable it +locally in mode-hooks etc. An example where this makes sense is +`pdf-isearch-minor-mode` from +[pdf-tools](https://github.com/politza/pdf-tools): +```elisp +(add-hook 'pdf-isearch-minor-mode-hook (lambda () (ctrlf-local-mode -1))) +``` + ### Miscellaneous The minibuffer history for CTRLF is stored in the variable diff --git a/ctrlf.el b/ctrlf.el index 5d2b95c..f37583d 100644 --- a/ctrlf.el +++ b/ctrlf.el @@ -1226,13 +1226,12 @@ See `ctrlf-mode-bindings'.") ;;;###autoload (progn - (define-minor-mode ctrlf-mode + (define-minor-mode ctrlf-local-mode "Minor mode to use CTRLF in place of Isearch. See `ctrlf-mode-bindings' to customize." - :global t :keymap ctrlf--keymap (require 'map) - (when ctrlf-mode + (when ctrlf-local-mode ;; Hack to clear out keymap. Presumably there's a `clear-keymap' ;; function lying around somewhere...? (setcdr ctrlf--keymap nil) @@ -1243,12 +1242,15 @@ See `ctrlf-mode-bindings' to customize." (define-key ctrlf--keymap key cmd)) ctrlf-mode-bindings)) (with-eval-after-load 'ctrlf - (if ctrlf-mode + (if ctrlf-local-mode (advice-add #'minibuffer-message :around #'ctrlf--minibuffer-message-condense) (advice-remove #'minibuffer-message #'ctrlf--minibuffer-message-condense))))) +;;;###autoload +(define-globalized-minor-mode ctrlf-mode ctrlf-local-mode ctrlf-local-mode) + ;;;; Closing remarks (provide 'ctrlf) From 44155e3d52f99a2d99ded381aa639280ad96879e Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Fri, 26 Jun 2020 07:33:10 -0600 Subject: [PATCH 2/2] Copyediting --- CHANGELOG.md | 6 ++++-- README.md | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1f645f..3a632df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,8 +26,8 @@ The format is based on [Keep a Changelog]. conflict with them. If you remapped the Isearch commands in your configuration, this means you will need to update `ctrlf-mode-bindings`. See [#51]. -* It is now possible to disable `ctrlf-mode` buffer locally by - disabling `ctrlf-local-mode` in mode hooks etc. See [#53]. +* It is now possible to disable `ctrlf-mode` buffer-locally by means + of `ctrlf-local-mode` ([#52], [#53]). ### Bugs fixed * CTRLF previously caused an error during Emacs startup unless the @@ -42,6 +42,8 @@ The format is based on [Keep a Changelog]. [#49]: https://github.com/raxod502/ctrlf/issues/49 [#50]: https://github.com/raxod502/ctrlf/pull/50 [#51]: https://github.com/raxod502/ctrlf/issues/51 +[#52]: https://github.com/raxod502/ctrlf/issues/52 +[#53]: https://github.com/raxod502/ctrlf/pull/53 ## 1.0 (released 2020-03-31) ### Added diff --git a/README.md b/README.md index b961227..76baff1 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ for single-buffer text search in Emacs, replacing packages such as * [Search flow](#search-flow) * [Customization](#customization) * [Search styles](#search-styles) + * [Disabling CTRLF locally](#disabling-ctrlf-locally) * [Miscellaneous](#miscellaneous) - [Why use CTRLF?](#why-use-ctrlf) * [Why not Isearch?](#why-not-isearch) @@ -236,9 +237,9 @@ following steps: `ctrlf-mode` is a globalized minor mode that enables the buffer-local minor mode `ctrlf-local-mode`. This makes it possible to disable it -locally in mode-hooks etc. An example where this makes sense is -`pdf-isearch-minor-mode` from -[pdf-tools](https://github.com/politza/pdf-tools): +when there is a conflict, for example with `pdf-isearch-minor-mode` +from [pdf-tools](https://github.com/politza/pdf-tools): + ```elisp (add-hook 'pdf-isearch-minor-mode-hook (lambda () (ctrlf-local-mode -1))) ```