0

When I first installed wrap-region, I used to install things via the classic M-x and package-install. Then, I inserted the following configuration:

;; Emacs minor mode to wrap region with tag or punctuations
(wrap-region-mode 1)
(wrap-region-add-wrapper "*" "*")
(wrap-region-add-wrapper "/" "/")
(wrap-region-add-wrapper "=" "=")

This used to work out. Now, I have moved to a new machine and I have not used classic installation yet (M-x and package-install).

I want to do everything via use-package.

I am especially unsure about how to make the mode globally enabled.

This is my first attempt:

(use-package wrap-region
  :ensure t
  :config
    (wrap-region-mode 1)
    (wrap-region-add-wrapper "*" "*")
    (wrap-region-add-wrapper "/" "/")
    (wrap-region-add-wrapper "=" "="))

The wrapper expressions (function call with wrap-region-add-wrapper) are working as expected.

However, the mode is not being globally enabled when Emacs starts.

How would you convert the declaration previously mentioned to a complete use-package declarative installation?

11
  • 1
    I am especially unsure about how to handle the expressions creating the "pattern-matching" - what pattern matching are you talking about? Not clear to me (but I know close to nothing about use-package OR wrap-region - so it's not clear to me whether it refers to use-package or wrap-region -or neither - or both).
    – NickD
    Commented Aug 1, 2022 at 16:15
  • 1
    As for expecting it to be globally enabled, why would it? Isn't that what wrap-region-global-mode is for?
    – NickD
    Commented Aug 1, 2022 at 16:20
  • 1
    (wrap-region-global-mode 1) should do the global enablement. Do C-h f wrap-region-mode and C-h f wrap-region-global-mode for more details. See Defining minor modes for additional insight: do C-h i g(elisp) RET m defining minor modes to get there.
    – NickD
    Commented Aug 1, 2022 at 17:06
  • 1
    I think "pattern-matching" is a bad term for that.
    – NickD
    Commented Aug 1, 2022 at 17:07
  • 1
    AFAICT, it's a wrap-region thing and they call it a wrapper, so why not call it that?
    – NickD
    Commented Aug 1, 2022 at 17:43

1 Answer 1

0

After @NickD's help, I realized there was a missing word of global on wrap-region-mode.

The correct is:

(wrap-region-global-mode 1)

And the final expression:

(use-package wrap-region
  :ensure t
  :config
    (wrap-region-global-mode 1)
    (wrap-region-add-wrapper "*" "*")
    (wrap-region-add-wrapper "/" "/")
    (wrap-region-add-wrapper "=" "="))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.