diff --git a/README-MacOS.org b/README-MacOS.org index 335443d..261eaa3 100644 --- a/README-MacOS.org +++ b/README-MacOS.org @@ -43,6 +43,7 @@ Best success comes from using the [[https://github.com/d12frosted/homebrew-emacs I find that I need to … at least, on my work computer, install two different versions of Emacs that I use to distinguish one for “work” and the other for other activities, like IRC and [[file:ha-feed-reader.org][elfeed]]. To that end, I run the following command to install Emacs: #+begin_src sh + brew reinstall $(brew deps emacs-plus@30) brew install emacs-plus@30 --with-native-comp --with-mailutils --with-imagemagick --with-savchenkovaleriy-big-sur-icon --with-no-frame-refocus --debug #+end_src And if it fails, choose =shell= and type: diff --git a/elisp/beep.el b/elisp/beep.el index 86bd601..b02dd21 100644 --- a/elisp/beep.el +++ b/elisp/beep.el @@ -19,7 +19,7 @@ "A WAV or AU file used at the completion of a function.") ;; My replacement in case we can't play internal sounds: -(defun beep--beep () +(defun beep-beep () "Play a default notification sound file. Customize the variable, `beep-alert-sound-file' to adjust the sound." (if (fboundp 'play-sound-internal) @@ -29,12 +29,12 @@ Customize the variable, `beep-alert-sound-file' to adjust the sound." (defvar beep-speech-executable "say %s" "An OS-dependent shell string to speak. Replaces `%s' with a phrase.") -(defun beep--speak (phrase) +(defun beep-speak (phrase) "Call a program to speak the string, PHRASE. Customize the variable, `beep-speech-executable'." (let ((command (format beep-speech-executable phrase))) - (save-window-excursion - (async-shell-command command)))) + (ignore-errors + (call-process-shell-command command)))) (defun beep-when-finished (phrase &optional to-speak) "Notify us with string, PHRASE, to grab our attention. @@ -42,8 +42,8 @@ Useful after a long process has completed, but use sparingly, as this can be pretty distracting." (when (functionp 'alert) (alert phrase :title "Completed")) - (beep--beep) - (beep--speak (or to-speak phrase)) + (beep-beep) + (beep-speak (or to-speak phrase)) (message phrase)) (defun compile-and-notify () @@ -57,31 +57,12 @@ See `beep-when-finished' for details." (defvar beep-func-too-long-time 5 "The number of seconds a function runs before it is considered taking too much time, and needing to be alerted when it has finished.") -(defun beep--after-function (func) - "Call the function, FUNC, interactively, and notify us when completed." - (let ((start-time (current-time)) - duration) - (call-interactively func) - (setq duration (thread-first - (current-time) - (time-subtract start-time) - decode-time - first)) - (when (> duration beep-func-too-long-time) - (beep-when-finished (format "The function, %s, has finished." func))))) - -(defun recompile-and-notify () - "Call `recompile' and notify us when finished. -See `beep-when-finished' for details." - (interactive) - (beep--after-function 'recompile)) - (global-set-key (kbd "C-c c") 'recompile-and-notify) (global-set-key (kbd "C-c C") 'compile-and-notify) (defun beep-when-runs-too-long (orig-function &rest args) "Notifies us about the completion of ORIG-FUNCTION. - Useful as after advice to long-running functions, for instance: +Useful as after advice to long-running functions, for instance: (advice-add 'org-publish :around #'beep-when-runs-too-long)" (let ((start-time (current-time)) diff --git a/ha-config.org b/ha-config.org index 3947620..0ded62b 100644 --- a/ha-config.org +++ b/ha-config.org @@ -29,6 +29,10 @@ A literate programming file for configuring Emacs. ;; loading sequence. ;; ;;; Code: + + ;; Used functions defined elsewhere: + (defun font-icons (collection label &rest args) + (or (plist-get args :title) label)) #+end_src * Basic Configuration I begin configuration of Emacs that isn’t /package-specific/. @@ -779,43 +783,43 @@ Magnar Sveen's [[https://github.com/magnars/expand-region.el][expand-region]] pr The built-in =isearch= is fantastically simple and useful, bound to ~C-s~, but why not bind searching for the current symbol? #+BEGIN_SRC emacs-lisp - (global-set-key (kbd "m-s m-s") 'isearch-forward-thing-at-point) + (global-set-key (kbd "M-s M-s") 'isearch-forward-thing-at-point) #+END_SRC I like Charles Choi’s [[https://github.com/kickingvegas/casual][Casual Suite]], and his original [[https://github.com/kickingvegas/cc-isearch-menu][cc-isearch-menu]] was great at seeing the /buried/ features. I’ve duplicated the features using [[https://github.com/jerrypnz/major-mode-hydra.el][pretty-hydra]]. In the middle of a search, type ~⌘-s~ (Command-s), and menu of options I don’t remember appear. #+begin_src emacs-lisp :tangle no - (defvar ha-isearch--title (font-icons 'faicon "magnifying_glass" - :title "Search Options")) + (defvar ha-isearch--title (font-icons 'faicon "magnifying_glass" + :title "Search Options")) - (pretty-hydra-define isearch-mode - (:color amaranth :quit-key "C-s" :title ha-isearch--title) - ("Movement" - (("n" isearch-repeat-forward "Forward") - ("p" isearch-repeat-backward "Backward") - ("j" avy-isearch "Jump" :color blue)) - "Expand" - ((">" isearch-yank-symbol-or-char "Full symbol") - ("z" isearch-yank-until-char "Until char") - ("$" isearch-yank-line "Full line")) - "Replace" - (("R" isearch-query-replace "Literal") - ("Q" isearch-query-replace-regexp "Regexp") - ("" isearch-exit "Stay" :color blue)) - "Toggles" - (("w" isearch-toggle-word "Word only" :toggle t) - ("s" isearch-toggle-symbol "Full symbol" :toggle t) - ("r" isearch-toggle-regexp "Regexp" :toggle t) - ("c" isearch-toggle-case-fold "Case Sensitive" :toggle t)) - "Highlight" - (("H" isearch-highlight-regexp "Matches" :color blue) - ("L" isearch-highlight-lines-matching-regexp "Lines" :color blue)) - "Other" - (("e" isearch-edit-string "Edit") - ("o" isearch-occur "Occur" :color blue) - ("C-g" isearch-abort "Abort" :color blue)))) + (pretty-hydra-define isearch-mode + (:color amaranth :quit-key "C-s" :title ha-isearch--title) + ("Movement" + (("n" isearch-repeat-forward "Forward") + ("p" isearch-repeat-backward "Backward") + ("j" avy-isearch "Jump" :color blue)) + "Expand" + ((">" isearch-yank-symbol-or-char "Full symbol") + ("z" isearch-yank-until-char "Until char") + ("$" isearch-yank-line "Full line")) + "Replace" + (("R" isearch-query-replace "Literal") + ("Q" isearch-query-replace-regexp "Regexp") + ("" isearch-exit "Stay" :color blue)) + "Toggles" + (("w" isearch-toggle-word "Word only" :toggle t) + ("s" isearch-toggle-symbol "Full symbol" :toggle t) + ("r" isearch-toggle-regexp "Regexp" :toggle t) + ("c" isearch-toggle-case-fold "Case Sensitive" :toggle t)) + "Highlight" + (("H" isearch-highlight-regexp "Matches" :color blue) + ("L" isearch-highlight-lines-matching-regexp "Lines" :color blue)) + "Other" + (("e" isearch-edit-string "Edit") + ("o" isearch-occur "Occur" :color blue) + ("C-g" isearch-abort "Abort" :color blue)))) - (define-key isearch-mode-map (kbd "s-s") 'isearch-mode/body) + (define-key isearch-mode-map (kbd "s-s") 'isearch-mode/body) #+end_src Pressing ~C-g~ aborts, and ~Return~ exits leaving the point in place. Typing ~C-s~ in the menu stops the menu to continue searching. diff --git a/ha-display.org b/ha-display.org index 8608497..87a9436 100644 --- a/ha-display.org +++ b/ha-display.org @@ -381,8 +381,7 @@ This project replaces [[https://github.com/domtronn/all-the-icons.el][all-the-ic #+BEGIN_SRC emacs-lisp (use-package nerd-icons - :straight (nerd-icons :type git :host github :repo "rainstormstudio/nerd-icons.el" - :files (:defaults "data")) + :straight (nerd-icons :type git :host github :repo "rainstormstudio/nerd-icons.el") :custom ;; The Nerd Font you want to use in GUI defaults to fixed-font: (nerd-icons-font-family ha-fixed-font)) @@ -392,39 +391,39 @@ The way we access the /font icons/ has always been … odd; needing to specify t #+BEGIN_SRC emacs-lisp (defun font-icons (collection label &rest args) - "Abstraction over `nerd-icons' project. - LABEL is a short icon description merged with COLLECTION to - identify an icon to use. For instance, 'faicon or 'octicon. + "Abstraction over `nerd-icons' project. + LABEL is a short icon description merged with COLLECTION to identify an + icon to use. For instance, 'faicon or 'octicon. - ARGS, a plist, contain the title, sizing and other information. + ARGS, a plist, contain the title, sizing and other information. - For instance: + For instance: (font-icons 'faicon \"file\" :title \"File Management\") - The goal is to take: + The goal is to take: (all-the-icons-octicon \"git-branch\") - And reformat to: + And reformat to: (font-icons 'octicon \"git-branch\")" - (let* ((func (intern (format "nerd-icons-%s" collection))) - (short (cl-case collection - ('octicon "oct") - ('faicon "fa") - ('mdicon "md") - ('codicon "cod") - ('sucicon "custom") - ('devicon "dev") - (t collection))) - (title (plist-get args :title)) - (space (plist-get args :space)) - (icon (format "nf-%s-%s" short - (string-replace "-" "_" label)))) + (let* ((func (intern (format "nerd-icons-%s" collection))) + (short (cl-case collection + ('octicon "oct") + ('faicon "fa") + ('mdicon "md") + ('codicon "cod") + ('sucicon "custom") + ('devicon "dev") + (t collection))) + (title (plist-get args :title)) + (space (plist-get args :space)) + (icon (format "nf-%s-%s" short + (string-replace "-" "_" label)))) - ;; With the appropriate nerd-icons function name, - ;; an expanded icon name, we get the icon string: - (concat (apply func (cons icon args)) - (cond - ((and title space) (concat (s-repeat space " ") title)) - (title (concat " " title)))))) + ;; With the appropriate nerd-icons function name, + ;; an expanded icon name, we get the icon string: + (concat (apply func (cons icon args)) + (cond + ((and title space) (concat (s-repeat space " ") title)) + (title (concat " " title)))))) #+END_SRC This replaces the /title generator/ for [[file:ha-config.org::*Leader Sequences][major-mode-hydra]] project to include a nice looking icon: