4

I like this Emacs package called Emacs Centered Point link. I must highlight that it is not listed on MELPA/ELPA.

Until now, I have just appended the snippet to my init file with the following and it works:

(define-minor-mode centered-point-mode
  "Alaways center the cursor in the middle of the screen."
  :lighter "..."
  (cond (centered-point-mode (add-hook 'post-command-hook 'pmd/line-change))
    (t (remove-hook 'post-command-hook 'pmd/line-change))))

(defun pmd/line-change ()
  (when (eq (get-buffer-window)
            (selected-window))
    (recenter)))

(provide 'centeredpoint)
(centered-point-mode t) ;;enable it globally

But, I have been completely re-writing my init file to be as declarative as possible with use-package.

And now I am unsure about how to handle this package since it is not on MELPA/ELPA.

Ceteris paribus (other things equal), is it possible to wrap this with use-package? If possible, how to do so?

Would it be even more verbose than keeping things as they are?

Pedro Delfino
  • 1,369
  • 3
  • 13

1 Answers1

4

Yes, it is possible to use use-package, and it will be less verbose than including the entire snippet.

You will need to basically add the centeredpoint.el file to Emacs load-path. One option is to download centeredpoint.el at some place, and then use the :load-path keyword.

(use-package centeredpoint
  :load-path "path-to-centeredpoint.el" ; relative path will work
  :hook (after-init-hook. centered-point-mode))

The following snippet uses straight.el as the package manager.

(use-package centeredpoint
  :straight (centered-point-mode :type git :host github 
                                 :repo "jmercouris/emacs-centered-point")
  :hook (after-init-hook. centered-point-mode))

It is possible to use quelpa with use-package along with Emacs' default package manager to install packages automatically that are not on MELPA/ELPA. The other alternative is to write your own function with package-install.

Swarnendu Biswas
  • 1,378
  • 1
  • 11
  • 24