Skip to content

Latest commit

 

History

History
92 lines (76 loc) · 3.07 KB

freemacs-embark.org

File metadata and controls

92 lines (76 loc) · 3.07 KB

Embark Module


Install Embark

Embark provides the ability to execute commands on completion options found in the minibuffer.

(use-package embark
  :straight t
  :after vertico
  :bind
  (("C-." . embark-act)
   ("C-;" . embark-dwim)
   ("C-h B" . embark-bindings))
  :init
  (setq prefix-help-command #'embark-prefix-help-command)
  :config
  <<embark_config>>
  (define-key embark-file-map (kbd "S") 'sudo-find-file))

Custom Functions for Embark

Below are functions defined to be used with Embark.

Sudo Find File

This function creates a sudo-find-file command that can be used to open files as the super user. This can be really useful when combined with Embark. This function was copied from https://karthinks.com/software/fifteen-ways-to-use-embark/.

(whicher "sudo")
(defun sudo-find-file (file)
  "Open FILE as root."
  (interactive "FOpen file as root: ")
  (when (file-writable-p file)
    (user-error "File is user writeable, aborting sudo"))
  (find-file (if (file-remote-p file)
                 (concat "/" (file-remote-p file 'method) ":"
                         (file-remote-p file 'user) "@" (file-remote-p file 'host)
                         "|sudo:root@"
                         (file-remote-p file 'host) ":" (file-remote-p file 'localname))
               (concat "/sudo:root@localhost:" file))))

Embark Mode Line

Hide the mode line of the Embark live/completions buffers.

(add-to-list 'display-buffer-alist
             '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
               nil
               (window-parameters (mode-line-format . none))))

Embark Integration with Consult

Allow use of Embark commands after issuing a Consult command.

(use-package embark-consult
  :straight t
  :after (embark consult)
  :demand t
  :hook
  (embark-collect-mode . consult-preview-at-point-mode))

End

Tell Emacs what pacakge this file provides.

(provide 'freemacs-embark)

;;; freemacs-embark.el ends here.