diff options
| -rw-r--r-- | custom/jao-custom-blog.el | 6 | ||||
| -rw-r--r-- | custom/jao-custom-browse.el | 251 | ||||
| -rw-r--r-- | custom/jao-custom-chats.el | 344 | ||||
| -rw-r--r-- | custom/jao-custom-multimedia.el | 291 | ||||
| -rw-r--r-- | custom/jao-custom-org.el | 9 | ||||
| -rw-r--r-- | custom/jao-custom-pdf.el | 144 | ||||
| -rw-r--r-- | custom/jao-custom-programming.el | 508 | ||||
| -rw-r--r-- | custom/jao-custom-shells.el | 6 | ||||
| -rw-r--r-- | custom/jao-custom-window-system.el | 198 | ||||
| -rw-r--r-- | init.el | 2280 | ||||
| -rw-r--r-- | lib/doc/jao-org-notes.el | 9 | 
11 files changed, 2059 insertions, 1987 deletions
| diff --git a/custom/jao-custom-blog.el b/custom/jao-custom-blog.el index a11c5c0..8d193bd 100644 --- a/custom/jao-custom-blog.el +++ b/custom/jao-custom-blog.el @@ -1,9 +1,9 @@  ;; -*- lexical-binding: t -*-  ;;; Vars and setup -(jao-load-path "org-static-blog") -(when (> emacs-major-version 26) (use-package htmlize :ensure t)) -(defvar jao-blog-base-dir "~/doc/jao.io") +(use-package htmlize :ensure t) + +(defvar jao-blog-base-dir (expand-file-name "jao.io" jao-doc-dir))  (defun jao-blog-dir (p) (expand-file-name p jao-blog-base-dir))  (setq jao-org-blog-tag-files diff --git a/custom/jao-custom-browse.el b/custom/jao-custom-browse.el new file mode 100644 index 0000000..5b956e7 --- /dev/null +++ b/custom/jao-custom-browse.el @@ -0,0 +1,251 @@ +;; -*- lexical-binding: t -*- + +;;; Browsing +;;;; variables +(defvar jao-browse-doc-use-emacs-p (jao-is-linux)) +(defvar jao-browse-url-function nil) +(defvar jao-browse-url-external-function nil) + +;;;; url around point +(defun jao-url-around-point (&optional current-url) +  (or (and (fboundp 'w3m-anchor) (w3m-anchor)) +      (shr-url-at-point nil) +      (ffap-url-at-point) +      (thing-at-point 'url) +      (when current-url +        (or (and (fboundp 'w3m-anchor) (w3m-anchor)) +            (and (derived-mode-p 'eww-mode) (plist-get eww-data :url)))))) + +(defun jao--url-prompt (&optional prefix) +  (let* ((def (jao-url-around-point t)) +         (prompt (concat prefix "URL" (if def (format " (%s): " def) ": ")))) +    (read-string prompt nil nil def))) + +;;;; downloads using wget +(defun jao-wget--get-title (filename) +  (or (and (derived-mode-p 'w3m-mode) (w3m-current-title)) +      (plist-get eww-data :title) +      (and (not (string-blank-p (or filename ""))) +           (subst-char-in-string ?- ? +                                 (capitalize (file-name-base filename)))))) + +(defun jao-wget (url &optional user pwd) +  "Download URL using wget and kill a link for an org note." +  (let* ((def (file-name-nondirectory url)) +         (pmt (format "Save %s to: " url)) +         (read-file-name-function nil) +         (dest (expand-file-name +                (read-file-name pmt jao-sink-dir nil nil def))) +         (title (jao-wget--get-title dest)) +         (src-url (or (jao-url-around-point t) (file-name-directory url))) +         (auth (when (and user pwd) +                 `(,(format "--http-user=%s" user) +                   ,(format "--http-password=%s" pwd)))) +         (lnk (concat "doc:" (file-name-nondirectory dest)))) +    (switch-to-buffer-other-window (get-buffer-create "*downloads*")) +    (erase-buffer) +    (kill-new (format "%s (from %s)" +                      (org-link-make-string lnk title) +                      (org-link-make-string src-url "here"))) +    (apply 'make-term `("downloads" "wget" nil ,@auth "-O" ,dest ,url)))) + +(defun jao-download (url &optional pws) +  "Download URL using wget" +  (interactive (list (jao--url-prompt))) +  (when url +    (let ((usr (and pws (read-string "Login name: "))) +          (pwd (and pws (read-passwd "Password: ")))) +      (jao-wget url usr pwd)))) + +(with-eval-after-load "embark" +  (define-key embark-url-map (kbd "d") #'jao-download)) + +;;;; video +(defvar jao-video--url-rx +  (format "^https?://\\(?:www\\.\\)?%s/.+" +          (regexp-opt '("youtu.be" +                        "youtube.com" +                        "blip.tv" +                        "vimeo.com" +                        "infoq.com") +                      t))) + +(defvar jao-video--ext-rx +  (format "^https?://.+/.+\\.%s" (regexp-opt '("mp3" "webm" "mp4")))) + +(defun jao-video--url-p (url) +  (or (string-match-p jao-video--url-rx url) +      (string-match-p jao-video--ext-rx url))) + +(defun jao--remote-run (url prg) +  (let ((args (format "%s %s" prg (shell-quote-argument url)))) +    (start-process-shell-command prg nil args))) + +(defun jao--mpv (url &rest _args) (jao--remote-run url "mpv")) +(defun jao--vlc (url &rest _args) (jao--remote-run url "vlc")) + +(defvar jao--video-player 'jao--mpv) + +(defun jao-view-video (url) +  "Tries to stream a video from the current or given URL" +  (interactive (list (jao--url-prompt "Video "))) +  (when url (funcall jao--video-player url))) + +(defun jao-maybe-view-video (url &rest _ignored) +  (interactive) +  (let ((w (read-char "View video (v) or web page (w)? "))) +    (cond ((eq w ?v) (jao-view-video url)) +          ((eq w ?w) (funcall jao-browse-url-function url)) +          (t (message "Aborted"))))) + +;;;; web browsers +(defun jao-www--buffer-p (b) +  (with-current-buffer b +    (or (derived-mode-p 'w3m-mode 'eww-mode) +        (and (boundp 'exwm-class-name) +             (member exwm-class-name '("vlc" "mpv")))))) + +;;;; browse-url +(require 'browse-url) + +(setq browse-url-generic-program "~/bin/firehog") + +(defun jao-browse-with-external-browser (&rest url) +  "Browse with external hogging" +  (interactive "s") +  (let ((url (or (car url) (jao-url-around-point)))) +    (if (not url) +        (message "No URL at point") +      (cond ((and (jao-exwm-enabled-p) (fboundp 'jao-exwm-firefox)) +             (jao-exwm-firefox)) +            (jao-river-enabled (jao-river-to-ws 2)) +            (jao-sway-enabled (jao-sway-firefox))) +      (browse-url-generic url)))) +(setq jao-browse-url-external-function 'jao-browse-with-external-browser) + +(defun jao--fln (url) +  (shell-quote-argument +   (if (string-match "^[^:]*:/*?\\(/?[^/].*\\)" url) +       (match-string-no-properties 1 url) +     url))) + +(defun jao--browse-doc (url &rest _ignored) +  (let* ((url (substring-no-properties url)) +         (file (jao--fln url))) +    (when file +      (unless (file-exists-p file) +        (error "File %s does not exist" file)) +      (jao-open-doc file)))) + +(defun jao--make-file-rx (exts) +  (format "file:/?/?.+\\.%s$" (regexp-opt exts))) + +(defvar jao--see-exts (jao--make-file-rx '("jpg" "jpeg" "png"))) + +(defvar jao--doc-exts +  (jao--make-file-rx '("ps" "ps.gz" "pdf" "dvi" "djvu" "chm"))) + +(defvar jao-browse-url-wget-exts +  '("ps" "pdf" "dvi" "djvu" "zip" "gz" "tgz")) + +(defvar jao-browse-external-domains +  '("github.com" "gitlab.com" "slack.com" "spotify.com" "drive.google.com" +    "meet.google.com" "docs.google.com" "x.com" "twitter.com" +    "t.com" "linkedin.com" "bigml.com" "slack.com" "zoom.us")) + +(defvar jao-browse--external-regexp +  (format "https?://.*%s\\(/.*\\)?" +          (regexp-opt jao-browse-external-domains))) + +(defun jao-wget--regexp () +  (concat "^http[s]?://.+\\(\\." +          (mapconcat 'identity jao-browse-url-wget-exts "\\|\\.") +          "\\)\\'")) + +(defun jao--see (url &rest _r) +  (start-process-shell-command "see" nil (format "see %s" (jao--fln url)))) + +(defun jao--find-file-other-window (url &rest _) +  (find-file-other-window (jao--fln url))) + +(defvar jao-browse--sound-rx +  (format "^https?://.*/.*\\.%s" (regexp-opt '("mp3" "flv")))) + +(defun jao-browse-play-sound-url (url &rest _) +  (jao-mpc-add-or-play-url url)) + +(defun jao-browse-url-browse (&rest args) +  (apply jao-browse-url-function args)) + +(setq browse-url-handlers +      `((jao-video--url-p . jao-maybe-view-video) +        (,jao--doc-exts . jao--browse-doc) +        (,jao--see-exts . jao--see) +        ("^file://?.+\\.html?$" . ,jao-browse-url-function) +        ("^file://?" . jao--find-file-other-window) +        (,jao-browse--external-regexp . ,jao-browse-url-external-function) +        ("^https?://.*\\.gotomeeting\\.com\\.*" . browse-url-chrome) +        (,jao-browse--sound-rx . jao-browse-play-sound-url) +        (,(jao-wget--regexp) . jao-download) +        ("." . jao-browse-url-browse))) + +(when (< emacs-major-version 28) +  (setf (alist-get 'jao-video--url-p browse-url-handlers nil t) nil) +  (setq browse-url-browser-function browse-url-handlers)) + +;;;; subscribe to rss using r2e +(autoload 'View-quit "view") + +(defun jao-rss--find-url () +  (save-excursion +    (when (derived-mode-p 'w3m-mode 'eww-mode) +      (if (fboundp 'w3m-view-source) (w3m-view-source) (eww-view-source))) +    (goto-char (point-min)) +    (when (re-search-forward +           "type=\"application/\\(?:atom\\|rss\\)\\+xml\" +" nil t) +      (let ((url (save-excursion +                   (when (re-search-forward +                          "href=\"\\([^\n\"]+\\)\"" nil t) +                     (match-string-no-properties 1)))) +            (title (when (re-search-forward +                          "\\(?:title=\"\\([^\n\"]+\\)\" +\\)" nil t) +                     (match-string-no-properties 1)))) +        (cond ((derived-mode-p 'w3m-view-mode) (w3m-view-source)) +              ((string-match-p ".*\\*eww-source\\b.*" (buffer-name)) +               (View-quit))) +        (when url (cons url (or title ""))))))) + +(defun jao-rss2e-append (name url mbox) +  (with-current-buffer (find-file-noselect "~/.config/rss2email.cfg") +    (goto-char (point-max)) +    (insert "[feed." name "]\nurl = " url) +    (insert "\nto = " mbox "+" name "@localhost") +    (insert "\nmaildir-mailbox = " mbox "\n\n") +    (save-buffer))) + +(defun jao-rss--feeds-dirs () +  (mapcar (lambda (d) (cadr (split-string d "\\."))) +          (directory-files "~/.emacs.d/gnus/Mail/" nil "^feeds"))) + +(defun jao-rss-subscribe (url) +  "Subscribe to a given RSS URL.  If URL not given, look for it." +  (interactive (list (or (jao-url-around-point) +                         (jao-rss--find-url) +                         (read-string "Feed URL: ")))) +  (let* ((url+title (ensure-list url)) +         (url (car url+title)) +         (title (cdr url+title))) +    (unless url (error "No feeds found")) +    (let ((url (if (string-match "^feed:" url) (substring url 5) url))) +      (when (y-or-n-p (format "Subscribe to <%s>? " url)) +        (let* ((name (read-string "Feed name: " title)) +               (cats (cons "prog" (jao-notmuch--subtags "feeds"))) +               (cat (completing-read "Category: " cats nil t)) +               (subs (format "r2e add %s '%s' feeds.%s@localhost" +                             name url cat))) +          ;; (jao-rss2e-append name url cat) +          (shell-command-to-string subs) +          (shell-command (format "r2e run %s" name))))))) + +(provide 'jao-custom-org) +;;; jao-custom-org.el ends here diff --git a/custom/jao-custom-chats.el b/custom/jao-custom-chats.el new file mode 100644 index 0000000..7f5bfe4 --- /dev/null +++ b/custom/jao-custom-chats.el @@ -0,0 +1,344 @@ +;; -*- lexical-binding: t -*- + + +;;;; circe +(defvar jao-libera-channels ()) +(defvar jao-oftc-channels ()) +(defvar jao-bitlbee-channels ()) +(defvar jao-slack-channels ()) + +(use-package circe +  :ensure t +  :bind (:map circe-channel-mode-map +              (("C-c C-a" . lui-track-jump-to-indicator))) +  :init +  (setq circe-chat-buffer-name "{target} - {network}" +        circe-default-realname "https://jao.io" +        circe-default-part-message "" +        circe-default-quit-message "" +        circe-ignore-list nil +        circe-server-coding-system '(undecided . undecided) +        circe-server-killed-confirmation 'ask-and-kill-all +        circe-server-auto-join-default-type :after-auth +        circe-server-buffer-name "{network} - {host}:{port}" +        circe-format-say "({nick}) {body}" +        circe-format-self-say "(jao) {body}" +        circe-new-buffer-behavior 'ignore +        circe-new-buffer-behavior-ignore-auto-joins t +        circe-nickserv-ghost-style 'after-auth +        circe-prompt-string ": " +        circe-completion-suffix ", " +        circe-reduce-lurker-spam t + +        circe-lagmon-mode-line-format-string "" ;;  "%.0f " +        circe-lagmon-mode-line-unknown-lag-string "" ;; "? " +        circe-lagmon-timer-tick 120 +        circe-lagmon-reconnect-interval 180 + +        lui-max-buffer-size 30000 +        lui-fill-column 80 +        lui-time-stamp-position 'right +        lui-time-stamp-format "%H:%M" +        lui-flyspell-p nil + +        lui-track-indicator (if window-system 'fringe 'bar) +        lui-track-behavior 'before-tracking-next-buffer) +  :config + +  (defsubst jao-circe-nick-no () +    (if (derived-mode-p 'circe-query-mode) +        2 +      (length (circe-channel-nicks)))) + +  (defsubst jao-circe-netowrk () +    (or (plist-get lui-logging-format-arguments :network) "")) + +  (define-minor-mode jao-circe-user-number-mode "" +    :lighter (:eval (format " [%s]" (jao-circe-nick-no)))) + +  (defun jao-circe-channel-hook () +    (when jao-mode-line-in-minibuffer +      (setq header-line-format +            '(" %b" (:eval (format "@%s - %s nicks" +                                   (jao-circe-netowrk) +                                   (jao-circe-nick-no)))))) +    (jao-circe-user-number-mode 1)) + +  (add-hook 'circe-channel-mode-hook #'jao-circe-channel-hook) +  (add-hook 'circe-query-mode-hook #'jao-circe-channel-hook) + +  (defun circe-command-RECOVER (&rest _ignore) +    "Recover nick" +    (jao-with-auth "freenode" u p +      (circe-command-MSG "nickserv" (format "IDENTIFY %s %s" u p)) +      (circe-command-MSG "nickserv" (format "GHOST %s" u)) +      (circe-command-MSG "nickserv" (format "RELEASE %s" u)) +      (circe-command-NICK u))) + +  (defun circe-command-NNICKS (&rest _) +    "Echo number of nicks" +    (circe-display-server-message +     (format "%d nicks in this channel" (jao-circe-nick-no)))) + +  (defun circe-command-SENDFILE (line) +    "/sendfile for localslackirc" +    (circe-command-QUOTE (format "sendfile %s" line))) + +  (advice-add 'circe-command-NAMES :after #'circe-command-NNICKS) + +  (defun jao-circe-reconnect-unmonitored () +    (interactive) +    (dolist (b (buffer-list)) +      (with-current-buffer b +        (when (and (derived-mode-p 'circe-server-mode) +                   circe-lagmon-disabled) +          (circe-reconnect))))) + +  (add-to-list 'jao-sleep-awake-functions #'jao-circe-reconnect-unmonitored) + +  (setq circe-network-options +        (list (jao-with-auth "libera" u p +                (list "Libera Chat" :nick u :channels jao-libera-channels +                      :tls t :sasl-username u :sasl-password p)) +              (jao-with-auth "oftc" u p +                (list "OFTC" +                      :nick u :channels jao-oftc-channels :nickserv-password p +                      :tls t :sasl-username u :sasl-password p)) +              (jao-with-auth "bitlbee" u p +                (list "Bitlbee" :host "127.0.0.1" :nick u +                      :channels jao-bitlbee-channels :lagmon-disabled t +                      :nickserv-password u :user p)))) + +  (jao-shorten-modes 'circe-channel-mode +                     'circe-server-mode +                     'circe-query-mode) + +  (enable-circe-display-images) +  (enable-lui-track) +  (circe-lagmon-mode)) + +;;;; telegram +(use-package telega +  :ensure t +  :custom +  (telega-use-tracking-for '(unmuted) ;; '(or unmuted mention) +                           telega-rainbow-color-custom-for nil +                           telega-msg-rainbow-title nil +                           telega-sticker-set-download t +                           telega-symbol-checkmark "·" +                           telega-symbol-heavy-checkmark "×" +                           telega-symbol-verified "*") +  :config +  (define-key global-map (kbd "C-c C-t") telega-prefix-map) +  (setq telega-chat-show-avatars nil +        telega-chat-prompt-insexp '(telega-ins "> ") +        telega-completing-read-function #'completing-read +        telega-root-show-avatars nil +        telega-emoji-use-images nil +        telega-temp-dir "/tmp/telega" +        telega-symbol-horizontal-bar +        (propertize "-" 'face 'jao-themes-f00) +        telega-symbol-vertical-bar +        (propertize "| " 'face 'jao-themes-dimm) +        telega-mode-line-string-format +        '(:eval (telega-mode-line-unread-unmuted)) +        telega-use-images (display-graphic-p) +        telega-open-file-function #'jao--see +        telega-open-message-as-file +        (unless (display-graphic-p) '(photo video animation))) +  (with-eval-after-load "tracking" +    (jao-shorten-modes 'telega-chat-mode) +    (jao-tracking-faces 'telega-tracking)) +  (telega-mode-line-mode 1)) + +(defun jao-telega () +  (interactive) +  (jao-tracking-go-to-chats) +  (if (get-buffer telega-root-buffer-name) +      (pop-to-buffer telega-root-buffer-name) +    (telega))) + +;;;; ement +(use-package ement +  :disabled t +  :ensure t +  :init (setq ement-save-sessions t +              ement-sessions-file (locate-user-emacs-file "cache/ement.el") +              ement-room-avatars nil +              ement-notify-dbus-p nil +              ement-room-left-margin-width 0 +              ement-room-right-margin-width 11 +              ement-room-timestamp-format "%H:%M" +              ement-room-timestamp-header-format "--------") + +  :custom ((ement-room-message-format-spec "(%S) %B%r%R %t")) + +  :config +  (defun jao-ement-track (event room session) +    (when (ement-notify--room-unread-p event room session) +      (when-let ((n (ement-room--buffer-name room)) +                 (b (get-buffer n))) +        (tracking-add-buffer b)))) + +  (add-hook 'ement-event-hook #'jao-ement-track) +  (jao-shorten-modes 'ement-room-mode) +  (jao-tracking-cleaner "^\\*Ement Room: \\(.+\\)\\*" "@\\1")) + +;;;; mastodon +(use-package mastodon +  :ensure t +  :init +  (setq mastodon-instance-url "https://fosstodon.org" +        mastodon-active-user "jao@gnu.org" +        mastodon-group-notifications t +        mastodon-images-in-notifs t +        mastodon-tl-position-after-update nil +        mastodon-toot-display-orig-in-reply-buffer t +        mastodon-media--hide-sensitive-media nil) +  :config +  ;; (defun jao-mastodon--setup () +  ;;   (setq-local scroll-margin 12)) + +  ;; (add-hook 'mastodon-mode-hook #'jao-mastodon--setup) +  (with-eval-after-load "ewww" +    (define-key eww-mode-map (kbd "T") #'jao-mastodon-toot-url))) + +(defun jao-mastodon-toot-url () +  (interactive) +  (when-let (url (jao-url-around-point t)) +    (jao-tracking-go-to-chats) +    (mastodon-toot--compose-buffer nil nil nil url))) + +(defun jao-mastodon () +  (interactive) +  (jao-afio-goto-chats) +  (mastodon)) + +;; https://0x0.st/XJ14.txt +(jao-transient-major-mode mastodon +  ["Timelines" +   ("H" "home"            mastodon-tl--get-home-timeline) +   ("L" "local"           mastodon-tl--get-local-timeline) +   ("F" "federated"       mastodon-tl--get-federated-timeline) +   ("K" "bookmarks"       mastodon-profile--view-bookmarks) +   ("V" "favorites"       mastodon-profile--view-favourites) +   ("'" "followed tags"   mastodon-tl--followed-tags-timeline) +   ("@" "mentions"        mastodon-notifications--get-mentions) +   ("N" "notifications"   mastodon-notifications-get) +   ("\\" "of remote host" mastodon-tl--get-remote-local-timeline)] + +  ;; u                    mastodon-tl--update + +  ["Search" +   ("s" "search"          mastodon-search--query) +   ("#" "tagged"          mastodon-tl--get-tag-timeline) +   ("\"" "followed tags"  mastodon-tl--list-followed-tags) +   ("I" "filter"          mastodon-views--view-filters) +   ("X" "lists"           mastodon-views--view-lists)] + +  ["Toots" +   ("n" "next"            mastodon-tl--goto-next-item :transient t) +   ("p" "prev"            mastodon-tl--goto-prev-item :transient t) +   ("c" "spoiler"         mastodon-tl--toggle-spoiler-text-in-toot :transient t) +   ("T" "thread"          mastodon-tl--thread) +   ("b" "(un)boost"       mastodon-toot--toggle-boost :transient t) +   ("f" "(un)fav"         mastodon-toot--toggle-favourite :transient t) +   ("i" "(un)pin"         mastodon-toot--pin-toot-toggle :transient t) +   ("k" "(un)bookmark"    mastodon-toot--toggle-bookmark :transient t) +   ("v" "vote"            mastodon-tl--poll-vote)] + +  ;; Z                    mastodon-tl--report-to-mods +  ;; o                    mastodon-toot--open-toot-url + +  ["Own Toots" +   ("r" "replay"          mastodon-toot--reply) +   ("t" "write"           mastodon-toot) +   ("e" "edit"            mastodon-toot--edit-toot-at-point) +   ("d" "delete"          mastodon-toot--delete-toot) +   ("D" "del & redraft"   mastodon-toot--delete-and-redraft-toot) +   ("E" "show edits"      mastodon-toot--view-toot-edits)] + +  ;; S                    mastodon-views--view-scheduled-toots + +  ["Users" +   ("W" "follow"          mastodon-tl--follow-user) +   ("R" "follow req"      mastodon-views--view-follow-requests) +   ("G" "suggestions"     mastodon-views--view-follow-suggestions) +   ("M" "mute user"       mastodon-tl--mute-user) +   ("B" "block user"      mastodon-tl--block-user) +   ("m" "message user"    mastodon-tl--dm-user) +   ;; "" +   ;; ("," "favouriters"     mastodon-toot--list-toot-favouriters) +   ;; ("." "boosters"        mastodon-toot--list-toot-boosters) +   ] + +  ;; S-RET                mastodon-tl--unmute-user +  ;; C-S-b                mastodon-tl--unblock-user + +  ["Profiles" +   ("A" "author"          mastodon-profile--get-toot-author) +   ("P" "any user"        mastodon-profile--show-user) +   ("O" "own"             mastodon-profile--my-profile) +   ("U" "update own"      mastodon-profile--update-user-profile-note)] + +  ["Misc" +   ("C" "copy URL"        mastodon-toot--copy-toot-url) +   ("?" "help"            describe-mode) +   ("q" "quit"            transient-quit-one)]) + +;;;; startup +(defun jao-chats (&optional p) +  (interactive "P") +  (when (or p (y-or-n-p "Connect to telegram? ")) +    (telega)) +  (when (and (fboundp 'ement-connect) (or p (y-or-n-p "Connect to matrix? "))) +    (unless (get-buffer "*Ement Rooms*") +      (jao-with-auth "matrix.org" u p (ement-connect :user-id u :password p)))) +  ;; (when (and (fboundp 'mastodon) (or p (y-or-n-p "Connect to mastodon? "))) +  ;;   (mastodon)) +  (dolist (c '(("Libera Chat" . "irc.libera.chat:6697"))) +    (unless (get-buffer (cdr c)) +      (when (or p (y-or-n-p (format "Connect to %s? " (car c)))) +        (circe (car c)))))) + +(defun jao-all-chats () +  (interactive) +  (when jao-tracking-use-scratch +    (jao-afio-goto-chats) +    (delete-other-windows)) +  (jao-chats t)) + +(defun jao-chats-telega () +  (interactive) +  (jao-buffer-same-mode '(telega-root-mode telega-chat-mode))) + +(defun jao-chats-slack () +  (interactive) +  (jao-buffer-same-mode 'slack-message-buffer-mode)) + +(defun jao-chats-irc () +  (interactive) +  (jao-buffer-same-mode '(circe-channel-mode circe-query-mode erc-mode))) + +;;;; consult narrowing +(defvar jao-chat-buffer-source +  (list :name "chats" +        :category 'buffer +        :action (lambda (b) (jao-afio-pop-to-buffer 0 b)) +        :hidden t +        :narrow (cons ?c "chats") +        :items (jao-consult--mode-buffers 'erc-mode +                                          'circe-channel-mode +                                          'circe-query-mode +                                          'signel-chat-mode +                                          'slack-message-buffer-mode +                                          'slack-thread-message-buffer-mode +                                          'telega-root-mode +                                          'telega-chat-mode +                                          'ement-room-mode +                                          'ement-room-list-mode))) +(with-eval-after-load "consult" +  (jao-consult-add-buffer-source 'jao-chat-buffer-source)) + + +(provide 'jao-custom-chats) diff --git a/custom/jao-custom-multimedia.el b/custom/jao-custom-multimedia.el new file mode 100644 index 0000000..a550a47 --- /dev/null +++ b/custom/jao-custom-multimedia.el @@ -0,0 +1,291 @@ +;; -*- lexical-binding: t -*- + +;;; utilities + +(defun jao-mixer-get-level (&optional dev nomsg) +  (interactive) +  (let* ((dev (or dev "Master")) +         (s (shell-command-to-string (format "amixer sget %s" dev))) +         (s (car (last (split-string s "\n" t))))) +    (when (string-match ".*Front .*\\[\\([0-9]+\\)%\\] .*" s) +      (let ((level (match-string 1 s))) +        (unless nomsg (message "%s level: %s%%" dev level)) +        (string-to-number level))))) + +(defun jao-mixer-set (dev v) +  (jao-shell-exec* t "amixer" "sset" dev v) +  (jao-mixer-get-level dev)) + +(defun jao-mixer-master-toggle () +  (interactive) +  (jao-mixer-set "Master" "toggle")) + +(defun jao-mixer-master-up () +  (interactive) +  (jao-mixer-set "Master" "10%+")) + +(defun jao-mixer-master-down () +  (interactive) +  (jao-mixer-set "Master" "10%-")) + +(defun jao-mixer-capture-up () +  (interactive) +  (jao-mixer-set "Capture" "10%+")) + +(defun jao-mixer-capture-down () +  (interactive) +  (jao-mixer-set "Capture" "10%-")) + +(jao-shell-def-exec jao-audio-applet "pasystray") + +(defun jao-toggle-audio-applet () +  (interactive) +  (or (jao-shell-kill-p "paystray") (jao-audio-applet))) + +(global-set-key (kbd "<f4>") #'jao-toggle-audio-applet) + +;;; streaming aliases +(defalias 'jao-streaming-list #'ignore) +(defalias 'jao-streaming-like #'ignore) +(defalias 'jao-streaming-dislike #'ignore) +(defalias 'jao-streaming-toggle-shuffle #'ignore) +(defalias 'jao-streaming-lyrics #'ignore) +(defalias 'jao-streaming-toggle #'ignore) +(defalias 'jao-streaming-next #'ignore) +(defalias 'jao-streaming-prev #'ignore) +(defalias 'jao-streaming-current #'ignore) +(defalias 'jao-streaming-seek #'ignore) +(defalias 'jao-streaming-seek-back #'ignore) +(defalias 'jao-streaming-volume #'ignore) +(defalias 'jao-streaming-volume-down #'ignore) + +;;; mpris +(defun jao-mpris-lyrics (&optional force) +  (interactive "P") +  (jao-show-lyrics force #'jao-mpris-artist-title)) + +(defun jao-mpris-mopidy-p () (string= "mopidy "jao-mpris-player)) + +(defun jao-mpc-mopidy-playlist () +  (interactive) +  (jao-mpc-show-playlist jao-mopidy-port)) + +(use-package jao-mpris :demand t) + +(defun jao-mpris-setup-aliases () +  (setq espotify-play-uri-function #'espotify-play-uri-with-dbus) +  ;; (setq jao-mpris-player "mopidy") +  (defalias 'jao-streaming-list #'jao-mpc-mopidy-playlist) +  (defalias 'jao-streaming-lyrics #'jao-mpris-lyrics) +  (defalias 'jao-streaming-toggle #'jao-mpris-play-pause) +  (defalias 'jao-streaming-next #'jao-mpris-next) +  (defalias 'jao-streaming-prev #'jao-mpris-previous) +  (defalias 'jao-streaming-current #'jao-mpris-show-osd) +  (defalias 'jao-streaming-seek #'jao-mpris-seek) +  (defalias 'jao-streaming-seek-back #'jao-mpris-seek-back) +  (defalias 'jao-streaming-volume #'jao-mpris-vol) +  (defalias 'jao-streaming-volume-down #'jao-mpris-vol-down)) + +(jao-mpris-register "playerctld" :session 70) +;; (jao-mpris-register "mopidy" :session 70) + +;;; mpc +(use-package jao-mpc +  :demand t +  :commands jao-mpc-setup) + +(defvar jao-mopidy-port 6669) +(defvar jao-mpc-last-port jao-mpc-port) + +(defun jao-mpc-toggle-port () +  (interactive) +  (setq jao-mpc-port +        (if (equal jao-mpc-port jao-mopidy-port) 6600 jao-mopidy-port) +        jao-mpc-last-port jao-mpc-port)) + +(defsubst jao-mpc-mopidy-p () (equal jao-mpc-last-port jao-mopidy-port)) + +(jao-mpc-setup jao-mopidy-port 70) + +(defun jao-mpc-pport (&optional mop) +  (cond ((or mop (jao-mpc-playing-p jao-mopidy-port)) jao-mopidy-port) +        ((jao-mpc-playing-p) 6600) +        (t jao-mpc-last-port))) + +(defmacro jao-defun-play (name &optional mpc-name) +  (let ((arg (gensym))) +    `(defun ,(intern (format "jao-player-%s" name)) (&optional ,arg) +       (interactive "P") +       (,(intern (format "jao-mpc-%s" (or mpc-name name))) +        (setq jao-mpc-last-port (jao-mpc-pport ,arg)))))) + +(jao-defun-play toggle) +(jao-defun-play next) +(jao-defun-play previous) +(jao-defun-play stop) +(jao-defun-play echo echo-current-times) +(jao-defun-play list show-playlist) +(jao-defun-play info lyrics-track-data) +(jao-defun-play browse show-albums) +(jao-defun-play select-album) + +(defun jao-player-seek (delta) (jao-mpc-seek delta (jao-mpc-pport))) + +(defalias 'jao-player-connect 'jao-mpc-connect) +(defalias 'jao-player-play 'jao-mpc-play) + +;;; spotify +(jao-load-path "espotify") + +(use-package espotify +  :demand t +  :init (setq espotify-service-name "mopidy")) + +(use-package consult-spotify :demand t) + +(defalias 'jao-streaming-album #'consult-spotify-album) +(defalias 'jao-streaming-track #'consult-spotify-track) +(defalias 'jao-streaming-artist #'consult-spotify-artist) +(defalias 'jao-streaming-playlist #'consult-spotify-playlist) + +(jao-def-exec-in-term "ncmpcpp" "ncmpcpp" (jao-afio-goto-scratch)) + +;;; spt +(use-package jao-spt +  :demand t +  :config +  (defun jao-spt-setup-aliases () +    (setq espotify-play-uri-function #'jao-spt-play-uri) +    (defalias 'jao-streaming-list #'jao-term-spt) +    (defalias 'jao-streaming-lyrics #'jao-spt-show-lyrics) +    (defalias 'jao-streaming-toggle #'jao-spt-toggle) +    (defalias 'jao-streaming-next #'jao-spt-next) +    (defalias 'jao-streaming-prev #'jao-spt-previous) +    (defalias 'jao-streaming-current #'jao-spt-echo-current) +    (defalias 'jao-streaming-seek #'jao-spt-seek) +    (defalias 'jao-streaming-seek-back #'jao-spt-seek-back) +    (defalias 'jao-streaming-volume #'jao-spt-vol) +    (defalias 'jao-streaming-volume-down #'jao-spt-vol-down) +    (defalias 'jao-streaming-like #'jao-spt-like) +    (defalias 'jao-streaming-dislike #'jao-spt-dislike) +    (defalias 'jao-streaming-toggle-shuffle #'jao-spt-toggle-shuffle))) + +(jao-def-exec-in-term "spt" "spt" (jao-afio-goto-scratch)) + +(defvar jao-spt-on t) + +(defun jao-streaming-toggle-player () +  (interactive) +  (if jao-spt-on +      (progn (setq jao-mpris-player "playerctld") +             (require 'jao-mpris) +             (jao-mpris-setup-aliases)) +    (jao-spt-setup-aliases) +    (setq jao-mpris-player "spt")) +  (setq jao-spt-on (not jao-spt-on)) +  (message "%s activated " jao-mpris-player)) + +(jao-streaming-toggle-player) + +;;; music transients +(require 'jao-lyrics) +(setq jao-lyrics-info-function #'jao-player-info) + +(defun jao-player-seek-10 () (interactive) (jao-player-seek 10)) +(defun jao-player-seek--10 () (interactive) (jao-player-seek -10)) + +(defun jao-streaming-clear () (interactive) (jao-mpc-clear jao-mopidy-port)) + +(defun jao-streaming-echo-current () +  (interactive) +  (jao-mpc-echo-current jao-mopidy-port)) + +(defun jao-streaming-show-playlist () +  (interactive) +  (jao-mpc-show-playlist jao-mopidy-port)) + +(use-package jao-random-album +  :demand t +  :config +  (defun jao--notify-album (album) +    (unless jao-minibuffer-mode +      (jao-notify album "Next album" jao-notify-audio-icon)) +    (jao-minibuffer-refresh)) +  (setq jao-random-album-notify #'jao--notify-album)) + +(defun jao-toggle-pasystray-applet () +  (interactive) +  (or (jao-shell-kill-p "pasystray") (jao-shell-exec "pasystray"))) + +(transient-define-prefix jao-transient-streaming () +  [:description +   (lambda () (format "Streaming using %s" jao-mpris-player)) +   ["Search" :if jao-mpris-mopidy-p +    ("a" "album" jao-streaming-album) +    ("A" "artist" jao-streaming-artist) +    ("t" "track" jao-streaming-track) +    ("P" "playlist" jao-streaming-playlist)] +   ["Play" +    ("s" "toggle" jao-streaming-toggle) +    ("n" "next" jao-streaming-next) +    ("p" "previous" jao-streaming-prev) +    ("T" "toggle player" jao-streaming-toggle-player)] +   ["Seek & shout" +    ("f" "seek fwd" jao-streaming-seek :transient t) +    ("F" "seek bwd" jao-streaming-seek-back :transient t) +    ("u" "up" jao-streaming-volume :transient t) +    ("d" "down" jao-streaming-volume-down :transient t)] +   ["Browse" +    ("l" "playing list" jao-streaming-list :if jao-mpris-mopidy-p) +    ("L" "lyrics" jao-streaming-lyrics) +    ("w" "currently playing" jao-streaming-current)] +   ["Act"  :if jao-mpris-mopidy-p +    ("k" "like" jao-streaming-like) +    ("K" "dislike" jao-streaming-dislike) +    ("S" "toggle shuffle" jao-streaming-toggle-shuffle)]]) + +(transient-define-prefix jao-transient-media () +  [["Play" +    ("m" "toggle" jao-player-toggle) +    ("n" "next" jao-player-next) +    ("p" "previous" jao-player-previous) +    ("s" "select album" jao-player-select-album)] +   ["Seek and search" +    ("f" "seek fwd" jao-player-seek-10 :transient t) +    ("F" "seek bwd" jao-player-seek--10 :transient t) +    ("a" "search album" jao-mpc-select-album) +    ("S" "play stream" jao-mpc-play-stream)] +   ["Browse" +    ("b" "browse" jao-player-browse) +    ("l" "show play list" jao-player-list) +    ("L" "show lyrics" jao-show-lyrics) +    ("w" "now playing" jao-player-echo)] +   [:description +    (lambda () +      (message "%s %s" +               (if (jao-mpc-mopidy-p) "mopidy" "mpd") +               (if (jao-mpc-playing-p) +                   (jao-mpc--current-timestr t) +                 (jao-mpc--current-str))) +      (format "Master %s%%" (jao-mixer-get-level nil t))) +    ("d" "down" jao-mixer-master-down :transient t) +    ("u" "up" jao-mixer-master-up :transient t) +    ("M" "toggle" jao-mixer-master-toggle)] +   [:description +    (lambda () (format "Capture %s%%" (jao-mixer-get-level "Capture" t))) +    ("D" "down" jao-mixer-capture-down :transient t) +    ("U" "up" jao-mixer-capture-up :transient t)] +   ["Utilities" +    ("c" "reconnect to mpd" jao-player-connect) +    ("N" "next random album" jao-random-album-next) +    ("r" (lambda () +           (concat (if jao-random-album-active "dis" "en") "able random album")) +     jao-random-album-toggle) +    ;; ("P" (lambda () (concat "Toggle to " (if (jao-mpc-mopidy-p) "mpd" "mopidy"))) +    ;;  jao-mpc-toggle-port) +    ("P" "pasystray" jao-toggle-pasystray-applet)]]) + +(global-set-key (kbd "s-m") #'jao-transient-media) + +;;; - provide +(provide 'jao-custom-multimedia) diff --git a/custom/jao-custom-org.el b/custom/jao-custom-org.el index 1792e2c..546c9af 100644 --- a/custom/jao-custom-org.el +++ b/custom/jao-custom-org.el @@ -1,7 +1,7 @@  ;; -*- lexical-binding: t -*-  ;;; General configuration -(defvar jao-org-dir (expand-file-name "~/doc/org")) +(defvar jao-org-dir (expand-file-name "org" jao-doc-dir))  (use-package org    :ensure t @@ -140,10 +140,9 @@  (use-package org-fragtog    :after org    :ensure t +  :demand t    :hook ((org-mode . org-fragtog-mode))) -(require 'org-fragtog) -  (setq org-format-latex-options        `(:foreground default                      :background @@ -170,10 +169,6 @@        '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"          "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")) -;; (use-package ox-pandoc -;;   :after org -;;   :ensure t) -  ;;; Babel and literate programming  (setq org-src-window-setup 'other-window) ;; current-window  (require 'org-tempo nil t) ;; <s TAB for 9.2 and later diff --git a/custom/jao-custom-pdf.el b/custom/jao-custom-pdf.el new file mode 100644 index 0000000..4ebd7f1 --- /dev/null +++ b/custom/jao-custom-pdf.el @@ -0,0 +1,144 @@ +;; -*- lexical-binding: t -*- + +;;;; open pdfs +(jao-when-linux + (use-package saveplace-pdf-view +  :ensure t +  :demand t +  :after doc-view)) + +(use-package jao-pdf :demand t) + +(setq jao-open-doc-fun 'jao-find-or-open) +(setq jao-org-open-pdf-fun 'jao-find-or-open) + +(defun jao-zathura-open (file page) +  (let ((id (jao-x11-search-window (jao-pdf-zathura-title-rx file)))) +    (if (string-blank-p id) +        (progn +          (when jao-xmonad-enabled (jao-x11-goto-ws 2)) +          (jao-shell-exec (jao-pdf-zathura-open-cmd file page))) +      (let* ((page (if page (format " && xdotool type %dg" page) "")) +             (cmd (format "xdotool windowactivate %s%s" id page))) +        (jao-shell-exec cmd t))))) + +(defun jao-x11-zathura-goto-org (&optional title no-ask) +  (let ((title (or title (jao-shell-string "xdotool" +                                           "getactivewindow" +                                           "getwindowname")))) +    (jao-org-open-from-zathura title no-ask))) + +(defun jao-find-or-open (file &optional page height) +  (cond ((and jao-browse-doc-use-emacs-p window-system) +         (let* ((buffs (buffer-list)) +                (b (catch 'done +                     (while buffs +                       (when (string-equal (buffer-file-name (car buffs)) file) +                         (throw 'done (car buffs))) +                       (setq buffs (cdr buffs)))))) +           (jao-afio-goto-docs) +           (if b (pop-to-buffer b) (find-file file)) +           (when page (jao-doc-view-goto-page page height)))) +        (jao-river-enabled (jao-river-open-with-zathura file page)) +        (jao-sway-enabled (jao-sway-open-with-zathura file page)) +        (t (jao-zathura-open file page)))) + +(defun jao-open-doc (&optional file page height) +  (interactive) +  (when-let (file (or file +                      (read-file-name "Document: " +                                      (concat jao-org-dir "/doc/")))) +    (funcall jao-open-doc-fun file page height))) + +(defun jao-select-pdf () +  (interactive) +  (jao-buffer-same-mode '(pdf-view-mode doc-view-mode) +                        #'jao-afio-goto-docs)) + +(defun jao-open-with-zathura () +  (interactive) +  (when-let (f buffer-file-name) +    (let ((p (jao-doc-view-current-page))) +      (cond (jao-river-enabled (jao-river-open-with-zathura f p)) +            (jao-sway-enabled (jao-sway-open-with-zathura f p)) +            (t (jao-zathura-open f p)))))) + +;; doc:// links for browse-url +(defun jao-open-doc-url (url &rest _) +  (when (string-match "doc://\\([^?]+\\)\\(\\?.*\\)?" url) +    (let ((file (match-string 1 url)) +          (page (when-let* ((qs (match-string 2 url)) +                            (long (> (length qs) 1)) +                            (ps (url-parse-query-string (substring qs 1))) +                            (pn (cadr (assoc "page" ps)))) +                  (string-to-number pn)))) +      (jao-open-doc (expand-file-name (concat "doc/" file) jao-org-dir) page)))) + +(add-to-list 'browse-url-handlers (cons "^doc://.+" 'jao-open-doc-url)) + +;;;; doc-view +(use-package doc-view +  :init +  (setq doc-view-cache-directory "~/.emacs.d/cache/docview" +        doc-view-resolution 110 +        doc-view-continuous t +        doc-view-conversion-refresh-interval 1 +        doc-view-mupdf-use-svg t) +  :hook ((doc-view-mode . jao-doc-session-mark)) +  :bind (:map doc-view-mode-map +              ("j" . doc-view-next-line-or-next-page) +              ("J" . doc-view-search-next-match) +              ("k" . doc-view-previous-line-or-previous-page) +              ("K" . doc-view-search-previous-match) +              ("z" . jao-open-with-zathura))) + +(use-package jao-doc-session :demand t) + +(use-package jao-doc-view +  :demand t +  :bind (:map doc-view-mode-map +              ("b" . jao-doc-view-back) +              ("B" . jao-doc-view-forward) +              ("S" . jao-doc-session-save) +              ("u" . jao-doc-view-visit-url))) + +;;;; transient +(defun jao-org-pdf-goto-org-linking () +  (interactive) +  (jao-org-pdf-goto-org 4)) + +(jao-transient-major-mode doc-view +  ["Notes" +   ("o" "notes file" jao-org-pdf-goto-org) +   ("O" "notes file, linking" jao-org-pdf-goto-org-linking)] +  ["Navigation" +   ("b" "back jump" jao-doc-view-back) +   ("B" "forward jump" jao-doc-view-back) +   ("u" "visit URL" jao-doc-view-visit-url)] +  ["Slices" +   ("cb" "bounding box" doc-view-set-slice-from-bounding-box) +   ("cm" "using mouse" doc-view-set-slice-using-mouse)] +  ["Session" +   ("s" "load session" jao-afio-open-pdf-session) +   ("S" "save session" jao-doc-session-save) +   ("d" "visit cache directory" doc-view-dired-cache)] +  ["External viewers" +   ("z" "open with zathura" jao-open-with-zathura)]) + +(with-eval-after-load "pdf-view" +  (jao-transient-major-mode pdf-view +    ["Notes" +     ("o" "notes file" jao-org-pdf-goto-org) +     ("O" "notes file, linking" jao-org-pdf-goto-org-linking)] +    ["Navigation" +     ("b" "back jump" pdf-history-backward) +     ("f" "forward jump" pdf-history-forward)] +    ["Session" +     ("s" "load session" jao-afio-open-pdf-session) +     ("S" "save session" jao-doc-session-save)] +    ["External viewers" +     ("z" "open with zathura" jao-open-with-zathura)])) + +;; (transient-get-suffix 'jao-transient-pdf-view '(0 -1)) + +(provide 'jao-custom-pdf) diff --git a/custom/jao-custom-programming.el b/custom/jao-custom-programming.el new file mode 100644 index 0000000..4028f3d --- /dev/null +++ b/custom/jao-custom-programming.el @@ -0,0 +1,508 @@ +;; -*- lexical-binding: t -*- + +;;; Programming +;;;; automatic modes +(add-to-list 'auto-mode-alist '("\\.mix\\'" . hexl-mode)) +(add-to-list 'auto-mode-alist '("\\.m4\\'" . m4-mode)) +(add-to-list 'auto-mode-alist '("\\.am\\'" . makefile-mode)) +(add-to-list 'auto-mode-alist '("\\.pl\\'\\|\\.pm\\'" . cperl-mode)) + +;;;; symbol overlay +(use-package symbol-overlay +  :ensure t +  :config +  (defun jao-symbol-reveal (&rest _) +    (when outline-minor-mode (outline-show-entry))) +  (advice-add 'symbol-overlay-basic-jump :after 'jao-symbol-reveal) + +  (defun jao-symbol-put-and-next () +    (interactive) +    (symbol-overlay-put) +    (symbol-overlay-jump-next)) + +  (defun jao-symbol-put-and-prev () +    (interactive) +    (symbol-overlay-put) +    (symbol-overlay-jump-prev)) + +  :bind (:map prog-mode-map (("M-i" . symbol-overlay-put) +                             ("M-n" . jao-symbol-put-and-next) +                             ("M-p" . jao-symbol-put-and-prev))) +  :hook (prog-mode . symbol-overlay-mode) +  :diminish " ^") + +;;;; eglot +(use-package eglot +  :bind (:map eglot-mode-map (("C-h ." . jao-eldoc-toggle)))) + +;;;; paredit and parens +(require 'paren) +(show-paren-mode t) +(setq show-paren-context-when-offscreen t +      show-paren-when-point-inside-paren nil) + +(use-package paredit +  :ensure t +  :commands paredit-mode +  :hook ((pie-mode . paredit-mode) +         (scheme-mode . paredit-mode) +         (clojure-mode . paredit-mode) +         (emacs-lisp-mode . paredit-mode) +         ;; (eval-expression-minibuffer-setup . paredit-mode) +         (lisp-interaction-mode . disable-paredit-mode)) +  :diminish ((paredit-mode . " þ"))) + +;;;; diff/ediff +(setq ediff-split-window-function 'split-window-horizontally) +(setq ediff-make-buffers-readonly-at-startup nil) +(setq ediff-window-setup-function 'ediff-setup-windows-plain) +(setq ediff-keep-variants nil) + +;;;; compilation +;;;;; compilation mode options +(require 'compile) +(setq compilation-scroll-output t) +(setq compilation-error-regexp-alist +      (remove 'omake compilation-error-regexp-alist)) +;; (add-hook 'compilation-mode-hook #'visual-line-mode) + +;;;;; mode line (no "Compiling"!) +(require 'compile) +(diminish 'compilation-minor-mode " ‡") +(when (< emacs-major-version 27) +  (setcdr (assq 'compilation-in-progress minor-mode-alist) '(" ‡"))) +(when (> emacs-major-version 26) +  (setcdr (assq 'compilation-in-progress mode-line-modes) '("‡ "))) + +;;;;; colorizing compilation buffer +(setq compilation-message-face 'default) +(require 'ansi-color) +(defun endless/colorize-compilation () +  "Colorize from `compilation-filter-start' to `point'." +  (let ((inhibit-read-only t)) +    (ansi-color-apply-on-region +     compilation-filter-start (point)))) + +(add-hook 'compilation-filter-hook #'endless/colorize-compilation) + +;;;;; compilation commands +(use-package jao-compilation +  :commands jao-compilation-setup +  :bind (("C-c C" . compile) +         ("C-c c" . jao-compile))) +(jao-compilation-setup) + +;;;;; next error +(setq next-error-find-buffer-function +      #'next-error-buffer-on-selected-frame +      next-error-verbose t) + +;;;; flymake +(use-package flymake +  :ensure t +  :custom ((flymake-mode-line-format '(" " flymake-mode-line-counters))) +  :config +  (jao-define-attached-buffer "^\\*Flymake diagnostics .*\\*\\'") + +  (transient-define-prefix jao-transient-flymake () +    ["Flymake" +     ("d" "show diagnostics" flymake-show-buffer-diagnostics) +     ("i" "show diagnostic" flymake-show-diagnostic) +     ("n" "next error" flymake-goto-next-error) +     ("p" "previous error" flymake-goto-prev-error) +     ("c" "consult flymake" consult-flymake)]) + +  :bind (:map flymake-mode-map (("M-m" . jao-transient-flymake)))) + +;;;; workarounds +(setq c-type-finder-time-slot nil) + +;;;; outline minor mode +(use-package outline +  :init (setq outline-minor-mode-use-buttons nil +              outline-minor-mode-use-margins nil +              outline-minor-mode-cycle t)) + +(defvar-local jao-outline-folded nil) +(dolist (v '(4 5 outline-show-only-headings)) +  (add-to-list 'safe-local-variable-values `(outline-default-state . ,v))) + +(defun jao-outline-minor-mode-hide-all (&optional arg) +  (interactive "P") +  (outline-hide-sublevels (if arg 5 4))) + +(defun jao-outline-minor-expand-all () +  (when jao-outline-minor-mode (outline-show-all))) + +(defun jao-outline-minor-mode-toogle-fold (&optional arg) +  (interactive "P") +  (if (setq jao-outline-folded (not jao-outline-folded)) +      (jao-outline-minor-mode-hide-all arg) +    (jao-outline-minor-expand-all))) + +(use-package outline-minor-faces +  :ensure t +  :after outline) + +(define-minor-mode jao-outline-minor-mode +  "Minor outline mode for programming languages" +  :lighter "" +  :keymap `((,(kbd "C-c C-n") . outline-next-visible-heading) +            (,(kbd "C-c C-p") . outline-previous-visible-heading) +            (,(kbd "C-c o") . consult-outline) +            (,(kbd "<f3>") . jao-outline-minor-mode-toogle-fold)) +  (if jao-outline-minor-mode +      (progn (setq-local outline-level #'outline-level +                         outline-regexp (format "[%s]\\{3,\\} " comment-start)) +             (outline-minor-mode 1) +             (outline-minor-faces-mode 1)) +    (outline-minor-mode -1) +    (outline-minor-faces-mode -1))) + +(add-hook 'find-function-after-hook #'jao-outline-minor-expand-all) + +;;; Programming languages +;;;; Elisp +(add-hook 'emacs-lisp-mode-hook #'jao-outline-minor-mode) + +(use-package edit-list :ensure t) +;; (use-package package-lint :ensure t) +;; (use-package tree-inspector :ensure t) + +(defun elisp-disassemble (function) +  (interactive (list (function-called-at-point))) +  (disassemble function)) + +(defun elisp-pp (sexp) +  (with-output-to-temp-buffer "*Pp Eval Output*" +    (pp sexp) +    (with-current-buffer standard-output +      (emacs-lisp-mode)))) + +(defun elisp-macroexpand (form) +  (interactive (list (form-at-point 'sexp))) +  (elisp-pp (macroexpand form))) + +(defun elisp-macroexpand-all (form) +  (interactive (list (form-at-point 'sexp))) +  (elisp-pp (macroexpand-all form))) + +(defun elisp-find-definition (name) +  (interactive (list (thing-at-point 'symbol))) +  (cond (name +         (let ((symbol (intern-soft name)) +               (search (lambda (fun sym) +                         (let* ((r (save-excursion (funcall fun sym))) +                                (buffer (car r)) +                                (point (cdr r))) +                           (cond ((not point) +                                  (error "Found no definition for %s in %s" +                                         name buffer)) +                                 (t +                                  (switch-to-buffer buffer) +                                  (goto-char point) +                                  (recenter 1))))))) +           (cond ((fboundp symbol) +                  (xref-push-marker-stack) +                  (funcall search 'find-function-noselect symbol)) +                 ((boundp symbol) +                  (xref-push-marker-stack) +                  (funcall search 'find-variable-noselect symbol)) +                 (t +                  (message "Symbol not bound: %S" symbol))))) +        (t (message "No symbol at point")))) + + +(defun elisp-bytecompile-and-load () +  (interactive) +  (or buffer-file-name +      (error "The buffer must be saved in a file first")) +  (require 'bytecomp) +  ;; Recompile if file or buffer has changed since last compilation. +  (when  (and (buffer-modified-p) +              (y-or-n-p (format "save buffer %s first? " (buffer-name)))) +    (save-buffer)) +  (let ((filename (expand-file-name buffer-file-name))) +    (with-temp-buffer +      (byte-compile-file filename)))) + +(use-package elisp-mode +  :bind (:map emacs-lisp-mode-map +              (("C-c C-M" . emacs-lisp-macroexpand) +               ("C-c C-m" . elisp-macroexpand-all) +               ("C-c C-k" . elisp-bytecompile-and-load) +               ;; ("C-c C-p" . pp-eval-last-sexp) +               ("M-." . elisp-find-definition) +               ("M-," . pop-tag-mark) +               ("C-c <" . lc-show-package-summary)))) + +;;;; Clojure +(use-package clojure-mode +  :ensure t +  :config +  (defun jao-clojure--fix-things () +    (setq-local completion-styles '(basic partial-completion emacs22)) +    (eldoc-mode 1) +    (setq mode-name "λ")) +  :hook (clojure-mode . jao-clojure--fix-things)) + +(defun jao-cider-test-ns (ns) +  (let ((parts (string-split ns "\\."))) +    (if (string= "test" (cadr parts)) +        ns +      (mapconcat #'identity (cons (car parts) (cons "test" (cdr parts))) ".")))) + +(defun jao-kaocha-file-name () +  (let* ((filename (match-string 2)) +         (path (replace-regexp-in-string "\\." "/" (match-string 1)))) +    (substring-no-properties (concat "test/" path filename)))) + +(defconst jao-kaocha-compilation-error +  '(kaocha-error "^FAIL in \\(.+\\.\\)[^ ]+ (\\([^:]+\\.clj[cs]?\\):\\([0-9]+\\))" +                 jao-kaocha-file-name 3)) + +(use-package compile +  :config +  (add-to-list 'compilation-error-regexp-alist-alist +               jao-kaocha-compilation-error)) + +(use-package cider +  :ensure t +  :commands cider-mode +  :init (setq cider-annotate-completion-candidates t +              cider-auto-select-error-buffer nil +              cider-auto-select-test-report-buffer nil +              cider-eldoc-display-for-symbol-at-point t +              cider-eldoc-ns-function #'identity ;; #'cider-last-ns-segment +              cider-enrich-classpath nil +              cider-lein-parameters "repl :headless :host localhost" +              cider-mode-line  " ÷" +              cider-prompt-for-symbol nil +              cider-repl-history-file +              (expand-file-name "~/.emacs.d/cache/cider.history") +              cider-repl-pop-to-buffer-on-connect nil +              cider-repl-use-pretty-printing t +              cider-show-error-buffer 'except-in-repl +              cider-test-show-report-on-success nil +              cider-test-infer-test-ns #'jao-cider-test-ns +              cider-use-fringe-indicators nil +              cider-use-overlays nil +              clojure-docstring-fill-column 72 +              nrepl-prompt-to-kill-server-buffer-on-quit nil) +  :bind (("<f3>" . cider-selector))) + +(with-eval-after-load "cider-test" +  (advice-add 'cider-scale-background-color :override +              (lambda () (frame-parameter nil 'background-color))) +  (setq cider-test-items-background-color +        (frame-parameter nil 'background-color))) + +(use-package cider-macroexpansion +  :after cider +  :diminish " µ") + +;;;; Geiser +(defun jao-org--set-geiser-impl () (setq-local geiser-repl--impl 'guile)) +(add-hook 'org-mode-hook #'jao-org--set-geiser-impl) + +(jao-load-path "geiser") +;; (package-vc-install-from-checkout ...) +(use-package geiser +  :demand t +  :init +  (setq geiser-repl-history-filename "~/.emacs.d/cache/geiser-history" +        geiser-repl-startup-time 20000 +        geiser-debug-auto-display-images t +        geiser-log-verbose t) +  :config +  (dolist (m '(geiser-repl-mode geiser-doc-mode geiser-debug-mode)) +    (jao-define-attached-buffer `(major-mode . ,m) 0.4))) + +(jao-load-path "geiser-guile") +(use-package geiser-guile) + +(jao-load-path "geiser-chez") +(use-package geiser-chez) + +;; (jao-load-path "geiser/mit") +;; (use-package geiser-mit) + +;; (jao-load-path "geiser/chicken") +;; (use-package geiser-chicken) + +;; (jao-load-path "geiser/chibi") +;; (use-package geiser-chibi) + +;; (jao-load-path "geiser/gambit") +;; (use-package geiser-gambit) + +;; (jao-load-path "geiser/gauche") +;; (use-package geiser-gauche) + +;;;; Haskell +;;;;; packages +;; (jao-load-path "haskell-mode") + +(use-package haskell-mode +  :ensure t +  :custom +  ((inferior-haskell-find-project-root t) +   (haskell-check-remember-last-command-p nil) +   (haskell-completing-read-function 'completing-read) +   (haskell-font-lock-symbols nil) +   (haskell-hoogle-command "hoogle") +   (haskell-interactive-popup-errors t) +   (haskell-process-auto-import-loaded-modules t) +   (haskell-process-log t) +   (haskell-process-suggest-remove-import-lines t) +   (haskell-process-suggest-hoogle-imports t) +   (haskell-process-type 'cabal-repl) +   (haskell-process-use-presentation-mode t) +   (haskell-stylish-on-save nil) +   (haskell-tags-on-save t)) + +  :init +  ;; For use with M-x align +  (require 'align) +  (add-to-list 'align-rules-list +               '(haskell-types +                 (regexp . "\\(\\s-+\\)\\(::\\|∷\\)\\s-+") +                 (modes quote (haskell-mode haskell-literate-mode)))) +  (add-to-list 'align-rules-list +               '(haskell-assignment +                 (regexp . "\\(\\s-+\\)=\\s-+") +                 (modes quote (haskell-mode haskell-literate-mode)))) +  (add-to-list 'align-rules-list +               '(haskell-arrows +                 (regexp . "\\(\\s-+\\)\\(->\\|→\\)\\s-+") +                 (modes quote (haskell-mode haskell-literate-mode)))) +  (add-to-list 'align-rules-list +               '(haskell-left-arrows +                 (regexp . "\\(\\s-+\\)\\(<-\\|←\\)\\s-+") +                 (modes quote (haskell-mode haskell-literate-mode)))) + +  :config +  (defun jao-haskell-hoogle (no-info) +    (interactive "P") +    (haskell-hoogle (format "%s" (haskell-ident-at-point)) (not no-info))) + +  (put 'haskell-process-args-cabal-repl +       'safe-local-variable +       (apply-partially #'seq-every-p #'stringp)) + +  (defun jao-haskell-eldoc (cb) +    (let ((msg (or (haskell-doc-current-info--interaction t) +                   (haskell-doc-sym-doc (haskell-ident-at-point)) +                   ""))) +      (funcall cb (replace-regexp-in-string "[\n ]+" " " msg)))) + +  (setq tags-revert-without-query t) + +  (defun jao-haskell-mode () +    (require 'haskell-doc) +    (setq-local eldoc-documentation-function 'eldoc-documentation-default +                eldoc-documentation-functions '(jao-haskell-eldoc)) +    (eldoc-mode)) + +  (dolist (h '(jao-haskell-mode +               haskell-decl-scan-mode +               haskell-indentation-mode +               interactive-haskell-mode)) +    (add-hook 'haskell-mode-hook h)) + +  (add-hook 'haskell-presentation-mode-hook (lambda () (whitespace-mode -1))) + +  :bind (:map haskell-mode-map +              (("C-c C-d" . jao-haskell-hoogle) +               ("C-c C-s" . haskell-session-change-target) +               ("C-c h" . haskell-hoogle) +               ("C-c t" . haskell-doc-show-type) +               ("C-c C-e" . haskell-command-insert-language-pragma) +               ("C-M-n" . flymake-goto-next-error) +               ("C-M-p" . flymake-goto-prev-error) +               ("<f3>" . haskell-session-kill)))) + +(jao-when-linux + (use-package hlint-refactor +   :ensure t +   :after haskell-mode +   :hook ((haskell-mode . hlint-refactor-mode)) +   :bind (:map haskell-mode-map (("C-M-h" . 'hlint-refactor-refactor-at-point) +                                 ("C-M-S-h" . 'hlint-refactor-refactor-buffer))) +   :diminish) + + (use-package flymake-hlint +   :ensure t +   :after haskell-mode +   :hook ((haskell-mode . flymake-hlint-load)))) + +(use-package consult-hoogle +  :ensure t) + +(require 'haskell) + +(diminish 'interactive-haskell-mode " λ") +(diminish 'haskell-doc-mode) +(diminish 'haskell-decl-scan-mode) + +(jao-define-attached-buffer "\\*hoogle\\*.*") +(jao-define-attached-buffer '(major-mode . haskell-interactive-mode) 0.33) +(jao-define-attached-buffer '(major-mode . haskell-presentation-mode) 0.25) + +;;;;; transient +(jao-transient-major-mode haskell +  ["Imports" +   ("in" "Navigate imports" haskell-navigate-imports) +   ("if" "Format imports" haskell-mode-format-imports) +   ("is" "Sort imports" haskell-sort-imports) +   ("ia" "Align imports" haskell-align-imports)] +  ["Session" +   ("s" "Change the session's target" haskell-session-change-target)] +  ["Code" +   ("e" "insert language pragma" haskell-command-insert-language-pragma) +   ("v" "visit cabal file" haskell-cabal-visit-file) +   ("h" "hoogle" jao-haskell-hoogle) +   ("t" "show type" haskell-doc-show-type)] +  ["Flymake" +   ("n" "next error" flymake-goto-next-error) +   ("p" "previous error" flymake-goto-prev-error)]) + +;;;; Pie +;; (jao-load-path "pie") +;; (use-package pie +;;   :commands (pie-mode)) + +;;;; Prolog +;; (use-package ediprolog :ensure t) + +(use-package prolog +  :disabled t +  :ensure t +  :commands (run-prolog prolog-mode mercury-mode) +  :init (progn +          (setq prolog-system 'swi) +          (add-to-list 'auto-mode-alist '("\\.pl$" . prolog-mode)) +          (setq prolog-consult-string '((t "[%f]."))) +          (setq prolog-program-name +                '(((getenv "EPROLOG") (eval (getenv "EPROLOG"))) +                  (eclipse "eclipse") +                  (mercury nil) +                  (sicstus "sicstus") +                  (swi "swipl") +                  (t "prolog"))))) + +;;;; Python +;; (use-package virtualenvwrapper +;;   :ensure t +;;   :config +;;   (venv-initialize-eshell) +;;   (jao-compilation-env "VIRTUAL_ENV")) + +;;;; Javascript + +(use-package typescript-mode +  :ensure t +  :custom ((typescript-indent-level 2))) + +;;; - +(provide 'jao-custom-programming) diff --git a/custom/jao-custom-shells.el b/custom/jao-custom-shells.el new file mode 100644 index 0000000..eaae13c --- /dev/null +++ b/custom/jao-custom-shells.el @@ -0,0 +1,6 @@ +;; -*- lexical-binding: t -*- + + + + +(provide 'jao-custom-shells) diff --git a/custom/jao-custom-window-system.el b/custom/jao-custom-window-system.el new file mode 100644 index 0000000..32b3578 --- /dev/null +++ b/custom/jao-custom-window-system.el @@ -0,0 +1,198 @@ +;; -*- lexical-binding: t -*- + +;;; x11 utils +(defun jao-xdotool (arg-or-wait &rest args) +  (apply 'jao-shell-exec* +         (if (stringp arg-or-wait) "xdotool" arg-or-wait) +         (if (stringp arg-or-wait) arg-or-wait "xdotool") +         args)) + +(defsubst jao-xdotool-string (&rest args) +  (apply 'jao-shell-string "xdotool" args)) + +(defsubst jao-x11-focused-id () (jao-xdotool-string "getwindowfocus")) + +(defsubst jao-x11-window-name (&optional wid) +  (jao-xdotool-string "getwindowname" (or wid (jao-x11-focused-id)))) + +(defsubst jao-x11-search-window (title) +  (jao-xdotool-string "search" "--name" title)) + +(defsubst jao-x11-goto-ws (n) (jao-xdotool t "set_desktop" (format "%s" n))) + +;;; exwm +(defvar jao-exwm-enabled nil) +(defun jao-exwm-enabled-p () jao-exwm-enabled) + +(defun jao-exwm-enable () +  (require 'jao-custom-exwm) +  (setq jao-exwm-enabled t) +  (display-time-mode -1) +  (jao-ednc-setup 95) +  (x-change-window-property "_XMONAD_TRAYPAD" "" nil nil nil nil 0) +  (jao-mode-line-add-to-minibuffer-left 90) +  (jao-xmobar-restart) +  (jao-trisect t)) + +;;; xmonad +(defvar jao-xmonad-enabled (string= "xmonad" (or (getenv "wm") ""))) +(defun jao-xmonad-enabled-p () jao-xmonad-enabled) + +(defun jao-xmonad-enable () +  (setq jao-browse-doc-use-emacs-p (display-graphic-p)) +  (setq jao-mode-line-in-minibuffer nil) +  (display-battery-mode -1) +  (jao-trisect) +  (message "Welcome to xmonad")) + +(when jao-xmonad-enabled +  (add-hook 'after-init-hook #'jao-xmonad-enable)) + +;;; wayland + +(use-package jao-wayland :demand t) + +(defun jao-wayland-enable () +  (interactive) +  (defalias 'x-change-window-property #'ignore) +  (jao-trisect) +  (message "Welcome to wayland")) + +(defun jao-river-enable () +  (jao-wayland-enable) +  (when (jao-shell-running-p "i3bar-river") +    (jao-tracking-set-log "")) +  (message "Welcome to river")) + +(when jao-river-enabled +  (add-hook 'after-init-hook #'jao-river-enable t)) + +(when jao-sway-enabled +  (add-hook 'after-init-hook #'jao-wayland-enable t)) + +;;; wallpaper +(defvar jao-wallpaper-dir "~/.wallpapers/") + +(defvar jao-wallpaper-random-candidates +  '("wallpaper.jpg" "wallpaper2.jpg")) + +(defvar jao-wallpaper-random-candidates-light +  '("wallpaper.jpg" "wallpaper2.jpg")) + +(defvar jao-wallpaper-random-wake t +  "Set to t for getting a new wallpaper on awaking from sleep") + +(defun jao-set-wallpaper (&optional path) +  (interactive) +  (let ((current (format "~/.wallpaper.%s" (jao-colors-scheme)))) +    (when-let ((f (or (and path (expand-file-name path)) +                      (read-file-name "Image: " +                                      jao-wallpaper-dir +                                      (file-symlink-p current) +                                      t)))) +      (make-symbolic-link f current t) +      (cond (jao-river-enabled (jao-river-set-wallpaper f)) +            (jao-sway-enabled (jao-sway-set-wallpaper f)) +            (t (shell-command-to-string (format "xwallpaper --zoom %s" f))))))) + +(defun jao-set-random-wallpaper () +  (interactive) +  (when (or (called-interactively-p 'interactive) +            jao-wallpaper-random-wake) +    (let* ((ws (if (jao-colors-scheme-dark-p) +                   jao-wallpaper-random-candidates +                 jao-wallpaper-random-candidates-light)) +           (f (seq-random-elt ws))) +      (jao-set-wallpaper (expand-file-name f jao-wallpaper-dir)) +      (message "%s" f)))) + +(add-to-list 'jao-sleep-awake-functions #'jao-set-random-wallpaper) + +;;; screensaver and lock +(defun jao-screensaver-enabled () +  (string= (jao-shell-string "xdg-screensaver status") "enabled")) + +(defvar jao-screensaver--wid nil) +(defun jao-screensaver-toggle () +  (interactive) +  (if (jao-screensaver-enabled) +      (let ((wid (jao-x11-focused-id))) +        (setq jao-screensaver--wid wid) +        (jao-shell-exec* t "xdg-screensaver" "suspend" wid)) +    (jao-shell-exec* t "xdg-screensaver" "resume" jao-screensaver--wid) +    (setq jao-screensaver--wid nil)) +  (jao-notify (format "Screensaver %s" +                      (jao-shell-string "xdg-screensaver status")))) + +(jao-shell-def-exec jao-xlock-screen "xdg-screensaver" "activate") +(jao-shell-def-exec jao-suspend "sudo" "systemctl" "suspend") +(jao-shell-def-exec jao-poweroff "sudo" "systemctl" "poweroff") + +(defun jao-lock-screen () +  (interactive) +  (if jao-wayland-enabled +      (shell-command "swaylock -i ~/.lockimage") +    (jao-xlock-screen))) + +(transient-define-prefix jao-transient-sleep () +  ["Sleep" +   ("l" "lock screen" jao-lock-screen) +   ("z" "sleep" jao-suspend) +   ("u" (lambda () +          (if (jao-screensaver-enabled) "suspend screensaver" "resume screensaver")) +    jao-screensaver-toggle) +   ("poof" "power-off" jao-poweroff)]) + +;;; X clipboard +(setq select-enable-clipboard t +      select-enable-primary t +      selection-timeout 100 +      xterm-select-active-regions t) + +(use-package xclip +  :ensure t +  :init (setq xclip-method (if jao-wayland-enabled 'wl-copy 'xclip))) + +(unless (display-graphic-p) (xclip-mode 1)) + +;;; pop-up frames +(defun jao-open-in-x-frame (&optional width height) +  (interactive) +  (make-frame `((window-system . x) +                (name . "emacs popup") +                (width . ,(or width (window-width))) +                (height . ,(or height (window-height))))) +  (define-key (current-local-map) "q" #'delete-frame)) + +;;; xmobar +(defun jao-xmobar-kill () +  (interactive) +  (shell-command "killall xmobar-single")) + +(defun jao-xmobar-restart () +  (interactive) +  (jao-xmobar-kill) +  (start-process "" nil "xmobar-single" "-d")) + +(use-package tab-bar +  :init (setq tab-bar-close-button-show nil +              tab-bar-show (> emacs-major-version 28) +              tab-bar-format ())) + +(use-package xmobar +  :init (setq  xmobar-tab-bar t +               xmobar-tab-split "*" +               xmobar-tab-bar-format +               (if window-system +                   '(xmobar-left-string +                     tab-bar-format-align-right +                     xmobar-right-string) +                 '(xmobar-left-string +                   xmobar-elastic-space +                   xmobar-right-string)) +               xmobar-command +               (if window-system '("xmobar-emacs" "-TAnsi") "xmobar-emacs"))) + + +;;; - provide +(provide 'jao-custom-window-system) @@ -1,8 +1,26 @@  ;; -*- lexical-binding: t; -*- +;;; Portability macros +(defmacro jao-syscase (clauses) +  (let ((cls (assoc system-type clauses))) +    (when cls `(progn ,@(cdr cls))))) + +(defmacro jao-d-l (darw linux) +  `(jao-syscase ((darwin ,darw) (gnu/linux ,linux)))) + +(defmacro jao-when-darwin (&rest body) +  `(jao-syscase ((darwin ,@body)))) + +(defmacro jao-when-linux (&rest body) +  `(jao-syscase ((gnu/linux ,@body)))) + +(defun jao-is-linux () (jao-when-linux t)) +(defun jao-is-darwin () (jao-when-darwin t)) +  ;;; Initialisation  ;;;; Bootstrap and use package -(defvar jao-emacs-dir (expand-file-name "~/etc/emacs")) +(defvar jao-emacs-dir +  (expand-file-name (jao-d-l "~/.emacs.d/config" "~/etc/emacs")))  (setq package-user-dir        (expand-file-name (format "~/.emacs.d/elpa.%s" emacs-major-version)) @@ -33,7 +51,7 @@        warning-suppress-types '((comp)))  ;;; Paths -(defvar jao-local-lisp-dir "~/lib/elisp" +(defvar jao-local-lisp-dir (jao-d-l "~/Library/elisp" "~/lib/elisp")    "Directory for external elisp libraries and repos")  (defvar jao-data-dir (expand-file-name "data" jao-emacs-dir) @@ -41,10 +59,12 @@  (defun jao-data-file (file) (expand-file-name file jao-data-dir)) -(setq jao-org-dir (expand-file-name "~/doc/org")) +(defvar jao-doc-dir (expand-file-name (jao-d-l "~/Documents/doc" "~/doc"))) + +(setq jao-org-dir (expand-file-name "org" jao-doc-dir))  (defvar jao-sink-dir -  (file-name-as-directory (expand-file-name "~/doc/sink")) +  (file-name-as-directory (expand-file-name "sink" jao-doc-dir))    "Directory used for downloads and such.")  (defvar jao-site-dir (expand-file-name "site" jao-emacs-dir)) @@ -78,7 +98,7 @@    (dolist (f (directory-files libd t "^[^.]+$"))      (when (file-directory-p f) (add-to-list 'load-path f)))) -(defvar jao-info-dir (expand-file-name "~/doc/info")) +(defvar jao-info-dir (expand-file-name "info" jao-doc-dir))  (require 'info)  (add-to-list 'Info-directory-list jao-info-dir) @@ -95,7 +115,8 @@  ;;; System Utilities  ;;;; persist -(require 'persist) +(use-package persist +  :ensure t)  ;;;; (no) backups  (setq vc-make-backup-files nil @@ -146,67 +167,76 @@  (inhibit-remote-files)  ;;;; sleep/awake -(use-package jao-sleep) -(jao-sleep-dbus-register) +(use-package jao-sleep +  :if (jao-is-linux) +  :demand t +  :config (jao-sleep-dbus-register))  ;;;; process runners  (use-package jao-shell    :demand t -  :config (jao-shell-def-exec jao-trayer "trayer.sh")    :bind (("s-r" . jao-shell-exec)))  ;;;; app launcher -(jao-load-path "app-launcher") -(use-package app-launcher -  :bind (("s-R" . app-launcher-run-app))) +(jao-when-linux + (jao-load-path "app-launcher") + (use-package app-launcher +   :bind (("s-R" . app-launcher-run-app))))  ;;;; brightness control -(jao-shell-def-exec jao-bright-set-up "brightnessctl" "-q" "s" "5%+") -(jao-shell-def-exec jao-bright-set-down "brightnessctl" "-q" "s" "5%-") +(jao-when-linux + (jao-shell-def-exec jao-bright-set-up "brightnessctl" "-q" "s" "5%+") + (jao-shell-def-exec jao-bright-set-down "brightnessctl" "-q" "s" "5%-") -(defun jao-brightness () -  (string-trim (or (cadr (jao-shell-cmd-lines "brightnessctl")) "(Unknown)"))) + (defun jao-brightness () +   (string-trim (or (cadr (jao-shell-cmd-lines "brightnessctl")) "(Unknown)"))) -(defun jao-bright-show () -  (interactive) -  (message "%s" (jao-brightness))) + (defun jao-bright-show () +   (interactive) +   (message "%s" (jao-brightness))) -(defun jao-bright-up () -  (interactive) -  (jao-shell-exec "brightnessctl -q s 5%%+" t) -  (jao-bright-show)) + (defun jao-bright-up () +   (interactive) +   (jao-shell-exec "brightnessctl -q s 5%%+" t) +   (jao-bright-show)) -(defun jao-bright-down () -  (interactive) -  (jao-shell-exec "brightnessctl -q s 5%%-" t) -  (jao-bright-show)) + (defun jao-bright-down () +   (interactive) +   (jao-shell-exec "brightnessctl -q s 5%%-" t) +   (jao-bright-show)))  ;;;; keyboard -(when (> emacs-major-version 27) -  (use-package repeat -    :config (setq repeat-echo-function 'repeat-echo-mode-line -                  repeat-exit-key "SHIFT" -                  repeat-exit-timeout 2)) +(jao-when-darwin + (setq mac-command-modifier 'meta) + (setq mac-option-modifier 'super)) + +(use-package repeat +  :demand t +  :config +  (setq repeat-echo-function 'repeat-echo-mode-line +                repeat-exit-key "SHIFT" +                repeat-exit-timeout 2)    (repeat-mode)) -(defun jao-kb-toggle (&optional lyt) -  (interactive) -  (shell-command-to-string (or lyt -                               (if (jao-kb-toggled-p) -                                   "setxkbmap us" -                                 "setxkbmap us -variant intl")))) +(jao-when-linux + (defun jao-kb-toggle (&optional lyt) +   (interactive) +   (shell-command-to-string (or lyt +				(if (jao-kb-toggled-p) +                                    "setxkbmap us" +                                  "setxkbmap us -variant intl")))) -(defun jao-set-uk-kb (&optional lyt) -  (interactive) -  (jao-kb-toggle "setxkbmap gb")) + (defun jao-set-uk-kb (&optional lyt) +   (interactive) +   (jao-kb-toggle "setxkbmap gb")) -(defun jao-kb-disable-laptop () -  (interactive) -  (jao-shell-exec "xinput float 13")) + (defun jao-kb-disable-laptop () +   (interactive) +   (jao-shell-exec "xinput float 13")) -(defun jao-kb-toggled-p () -  (not (string-empty-p -        (shell-command-to-string "setxkbmap -query|grep variant")))) + (defun jao-kb-toggled-p () +   (not (string-empty-p +         (shell-command-to-string "setxkbmap -query|grep variant")))))  (customize-set-variable 'default-input-method "catalan-prefix")  ;; http://mbork.pl/2022-03-07_Transient_input_method @@ -217,7 +247,7 @@  ;;;; transient  (use-package transient -  :init (setq transient-show-popup t) ;; 2.0 +  :init (setq transient-show-popup t)    :demand t    :config    (transient-bind-q-to-quit)) @@ -248,9 +278,12 @@  ;;;; disk monitoring  (use-package jao-dirmon +  :if (jao-is-linux)    :commands jao-dirmon-report) +  ;;;; mailcap  (use-package mailcap +  :if (jao-is-linux)    :config    (add-to-list 'mailcap-mime-extensions '(".JPEG" . "image/jpeg"))    (add-to-list 'mailcap-mime-extensions '(".JPG" . "image/jpeg")) @@ -282,7 +315,10 @@  (use-package tmr    :ensure t    :init -  (setq tmr-sound-file "/usr/share/sounds/freedesktop/stereo/message.oga")) +  (jao-when-linux +   (setq tmr-sound-file +	 "/usr/share/sounds/freedesktop/stereo/message.oga"))) +  ;;; Crypto  ;;;; PGP, EPG, passwords  (setq auth-source-debug nil) @@ -292,11 +328,11 @@  (setq auth-sources '("~/.emacs.d/authinfo.gpg" "~/.netrc"))  (use-package epa-file +  :demand t    :init (setq epa-file-cache-passphrase-for-symmetric-encryption t                epa-file-encrypt-to "A247C4780736A6156BC8DA748C081D34D321D881"                plstore-encrypt-to epa-file-encrypt-to)    :config (epa-file-enable)) -(require 'epa-file)  (defun jao--get-user/password (h)    (let ((item (car (auth-source-search :type 'netrc :host h :max 1)))) @@ -339,7 +375,7 @@                            (make-glyph-code ?│)))  ;;;; transparency -(defvar jao-transparent-only-bg (> emacs-major-version 28)) +(defvar jao-transparent-only-bg (jao-is-linux))  (defvar jao-frames-default-alpha    (cond ((eq window-system 'pgtk) 85) @@ -367,7 +403,7 @@    (let ((level (if jao-transparent-frame 100 jao-frames-default-alpha)))      (jao-set-transparency level all))) -(jao-set-transparency) +(jao-when-linux (jao-set-transparency))  ;;;; themes  (defun jao-colors-scheme-dark-p () @@ -397,7 +433,29 @@      (load-theme theme t)      (modify-all-frames-parameters `((font . ,jao-themes-default-face))))) -(jao-themes-setup) +(use-package doric-themes +  :if (jao-is-darwin) +  :ensure t +  :demand t +  :config +  ;; These are the default values. +  (setq doric-themes-to-toggle '(doric-light doric-marble)) +  (setq doric-themes-to-rotate doric-themes-collection) + +  (doric-themes-select 'doric-marble) + +  (set-face-attribute 'default nil :family "Menlo" :height 120) +  ;; (set-face-attribute 'variable-pitch nil :family "Aporetic Sans" :height 1.0) +  ;; (set-face-attribute 'fixed-pitch nil :family "Aporetic Sans Mono" :height 1.0) + +  :bind +  (("<f5>" . doric-themes-toggle) +   ("C-<f5>" . doric-themes-select) +   ("M-<f5>" . doric-themes-rotate))) + +(jao-when-linux (jao-themes-setup)) + +  ;;; Help system  ;;;; help buffers @@ -458,7 +516,7 @@  (setq minibuffer-default-prompt-format " (default %s)")  (minibuffer-electric-default-mode 1) -(jao-minibuffer-mode 1) +(jao-minibuffer-mode (jao-d-l -1 1))  ;;; Mode line  ;;;; config @@ -473,7 +531,7 @@  (column-number-mode -1)  ;;;; jao-mode-line -(defvar jao-mode-line-in-minibuffer t) +(defvar jao-mode-line-in-minibuffer (jao-is-linux))  (use-package jao-mode-line    :commands (jao-mode-line-add-to-minibuffer-left @@ -552,6 +610,7 @@  ;;;; tracking  (use-package tracking +  :ensure t    :demand t    :init (setq tracking-position 'before-modes                tracking-frame-behavior nil @@ -559,21 +618,23 @@                tracking-max-mode-line-entries 10                tracking-sort-faces-first t                tracking-shorten-modes '()) -  :config -  (setq erc-track-enable-keybindings nil)) +  :config  (setq erc-track-enable-keybindings nil))  (use-package jao-tracking    :demand t -  :init (setq jao-tracking-bkg (if (jao-colors-scheme-dark-p) "grey20" "grey93")) +  :init +  (setq jao-tracking-bkg (if (jao-colors-scheme-dark-p) "grey20" "grey93"))    :config (jao-tracking-setup t))  ;;;; ednc -(use-package ednc -  :ensure t -  :diminish nil) +(jao-when-linux + (use-package ednc +   :ensure t +   :diminish nil))  (use-package jao-ednc +  :if (jao-is-linux)    :demand t    :init (setq jao-ednc-use-tracking nil)    :commands (jao-ednc-setup) @@ -654,29 +715,6 @@    (add-hook 'diary-fancy-display-mode-hook #'jao-diary--select)) -;;;; winttr -(defun jao-weather (&optional wide) -  (interactive "P") -  (if (not wide) -      (message "%s" -               (jao-shell-string "curl -s" -                                 "https://wttr.in/?format=%l++%m++%C+%c+%t+%w++%p")) -    (jao-afio-goto-scratch) -    (if-let ((b (get-buffer "*wttr*"))) -        (progn (pop-to-buffer b) -               (term-send-string (get-buffer-process nil) "clear;curl wttr.in\n")) -      (jao-exec-in-term "curl wttr.in" "*wttr*")))) -(global-set-key (kbd "<f5>") #'jao-weather) - -;;; Files, dired and scratch buffer -;;;; so-long -(setq large-file-warning-threshold (* 200 1024 1024)) - -;; (use-package so-long -;;   :ensure t -;;   :diminish) -;; (global-so-long-mode 1) -  ;;;; persistent scratch  (use-package persistent-scratch    :ensure t @@ -692,14 +730,18 @@          dired-dwim-target t          dired-kill-when-opening-new-dired-buffer t          dired-mouse-drag-files t -        wdired-create-parent-directories t -        dired-guess-shell-alist-user +        wdired-create-parent-directories t) + +  (jao-when-linux +   (setq dired-guess-shell-alist-user          '(;; ("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open")            ("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open") -          (".*" "xdg-open"))) +          (".*" "xdg-open"))))    (put 'dired-find-alternate-file 'disabled nil) +    :hook (dired-mode . turn-on-gnus-dired-mode) +    :bind (:map dired-mode-map                ("C-c C-r" . wdired-change-to-wdired-mode)                ("C-M-m" . gnus-dired-attach))) @@ -719,7 +761,6 @@  ;;;; wgrep  (use-package wgrep :ensure t) -(require 'wgrep)  ;;;; executable scripts  (add-hook 'after-save-hook @@ -798,56 +839,62 @@  (require 'jao-custom-completion)  ;;;; recoll -(jao-load-path "consult-recoll") - -(defun jao-recoll-format (title url _mtype) -  (let* ((u (replace-regexp-in-string "file://" "" url)) -         (u (replace-regexp-in-string "/home/jao/" "" u)) -         (u (replace-regexp-in-string -             "\\(doc\\|org/doc\\|.emacs.d/gnus/Mail\\|var/mail\\)/" "" u))) -    (format "%s (%s)" ;; "%s (%s, %s)" -            title -            (propertize u 'face 'jao-themes-f01) -            ;; (propertize mtype 'face 'jao-themes-f01) -            ))) - -(defun jao-recoll-open-html (file &optional _page) -  (if (string-match-p "\.epub\\'" file) -      (find-file file) -    (jao-afio-goto-www) -    (if jao-afio-use-w3m (w3m-find-file file) (eww-open-file file)))) - -(defun jao-recoll-open-pdf (file &optional page) -  (if (string-match-p "/gnus/Mail/" file) -      (funcall (or (cdr (assoc-string "message/rfc822" consult-recoll-open-fns)) -                   'find-file) -               file -               page) -    (jao-open-doc file page))) - -(defun jao-recoll-consult-messages () -  (interactive) -  (consult-recoll "mime:message ")) - -(defun jao-recoll-consult-docs () -  (interactive) -  (consult-recoll (format "dir:%s/doc " jao-org-dir))) - -(defun jao-recoll-consult-notes () -  "Use consult-recoll to search notes." -  (interactive) -  (consult-recoll (format "dir:%s " jao-org-notes-dir))) +(jao-when-linux (jao-load-path "consult-recoll"))  (use-package consult-recoll +  :if (jao-is-linux)    :commands (consult-recoll consult-recoll-embark-setup) -  :init (setq consult-recoll-open-fns -              '(("application/pdf" . jao-recoll-open-pdf) -                ("text/html" . jao-recoll-open-html)) -              consult-recoll-search-flags 'query -              consult-recoll-inline-snippets t -              consult-recoll-format-candidate #'jao-recoll-format) +  :init +  (defun jao-recoll-format (title url _mtype) +    (let* ((u (replace-regexp-in-string "file://" "" url)) +           (u (replace-regexp-in-string "/home/jao/" "" u)) +           (u (replace-regexp-in-string +               "\\(doc\\|org/doc\\|.emacs.d/gnus/Mail\\|var/mail\\)/" "" u))) +      (format "%s (%s)" ;; "%s (%s, %s)" +              title +              (propertize u 'face 'jao-themes-f01) +              ;; (propertize mtype 'face 'jao-themes-f01) +              ))) + +  (defun jao-recoll-open-html (file &optional _page) +    (if (string-match-p "\.epub\\'" file) +        (find-file file) +      (jao-afio-goto-www) +      (if jao-afio-use-w3m (w3m-find-file file) (eww-open-file file)))) + +  (defun jao-recoll-open-pdf (file &optional page) +    (if (string-match-p "/gnus/Mail/" file) +        (funcall +         (or (cdr (assoc-string "message/rfc822" consult-recoll-open-fns)) +             'find-file) +         file +         page) +      (jao-open-doc file page))) + +  (defun jao-recoll-consult-messages () +    (interactive) +    (consult-recoll "mime:message ")) + +  (defun jao-recoll-consult-docs () +    (interactive) +    (consult-recoll (format "dir:%s/doc " jao-org-dir))) + +  (defun jao-recoll-consult-notes () +    "Use consult-recoll to search notes." +    (interactive) +    (consult-recoll (format "dir:%s " jao-org-notes-dir))) + +  (setq consult-recoll-open-fns +        '(("application/pdf" . jao-recoll-open-pdf) +          ("text/html" . jao-recoll-open-html)) +        consult-recoll-search-flags 'query +        consult-recoll-inline-snippets t +        consult-recoll-format-candidate #'jao-recoll-format) +    :config +    (consult-customize consult-recoll :preview-key 'any) +  (with-eval-after-load "embark" (consult-recoll-embark-setup))    (transient-define-prefix jao-transient-recoll ()      ["Consult recoll queries" @@ -858,8 +905,6 @@    :bind (("s-r" . #'jao-transient-recoll))) -(with-eval-after-load "embark" (consult-recoll-embark-setup)) -  ;;; Buffers  ;;;; cursor and mark  (transient-mark-mode -1) @@ -929,14 +974,12 @@  (global-set-key (kbd "C-c C-b") #'jao-buffer-same-mode-cmd)  ;;;; projects -(use-package project :demand t) -(global-set-key "\C-xp" 'jao-prev-window) -(use-package list-projects :ensure t) +;; (use-package project :demand t) +;; (use-package list-projects :ensure t)  ;;;; buffer quit function (the triple ESC)  (setq buffer-quit-function (lambda () t)) -  ;;;; redisplay escape hatch  ;; (setq max-redisplay-ticks 2250000)  ;;;; scrolling @@ -953,8 +996,7 @@          redisplay-skip-fontification-on-input nil))  (use-package ultra-scroll -  ;:load-path "~/code/emacs/ultra-scroll" ; if you git clone'd instead of using vc -  :vc (:url "https://github.com/jdtsmith/ultra-scroll") ; For Emacs>=30 +  :ensure t    :init    (setq scroll-conservatively 3 ; or whatever value you prefer, since v0.4          scroll-margin 0)        ; important: scroll-margin>0 not yet supported @@ -1049,6 +1091,8 @@          (global-set-key (format "\C-c%s" (1+ n)) (jao-nth-window n)))        '(0 1 2 3 4 5 6 7 8)) +(global-set-key "\C-xp" 'jao-prev-window) +  ;; transposing windows  (defun transpose-windows (arg)    "Transpose the buffers shown in two windows." @@ -1081,10 +1125,10 @@  (use-package fringe)  (fringe-mode) -(menu-bar-mode -1) +(jao-when-linux (menu-bar-mode -1))  ;; (setting it to nil avoids mouse wrapping after other-frame) -(setq focus-follows-mouse (and window-system t)) +(setq focus-follows-mouse (and (jao-is-linux) window-system t))  (use-package scroll-bar)  (set-scroll-bar-mode nil) @@ -1101,8 +1145,23 @@  ;;;; afio  (use-package jao-afio +  :if (jao-is-linux)    :demand t -  :config (jao-afio-setup (not window-system)) +  :config +  (jao-afio-setup (not window-system)) +  (add-hook 'jao-afio-switch-hook 'jao-minibuffer-refresh t) + +  (defun jao-current--frame-id () +    (propertize (cond ((and (fboundp 'jao-exwm-enabled) +                            (jao-exwm-enabled-p) +                            (not (bound-and-true-p jao-exwm--use-afio)) +                            (boundp 'exwm-workspace-current-index)) +                       (format "F%s" exwm-workspace-current-index)) +                      (t jao-afio-use-frames (or (jao-afio-frame-name) "")) +                      (t (format "%s" (or (jao-afio-frame-no) "")))) +                'face 'font-lock-warning-face)) +  (jao-minibuffer-add-variable '(jao-current--frame-id) 100) +    :bind (("C-c f" . 'jao-afio-goto-main)           ("C-c g" . 'jao-afio-goto-mail)           ("C-c w" . 'jao-afio-goto-www) @@ -1110,19 +1169,6 @@           ("C-c t" . 'jao-afio-goto-chats)           ("C-c 0" . 'jao-afio-goto-scratch)           ("M-o" . 'jao-afio-toggle))) -(add-hook 'jao-afio-switch-hook 'jao-minibuffer-refresh t) - -(defun jao-current--frame-id () -  (propertize (cond ((and (fboundp 'jao-exwm-enabled) -                          (jao-exwm-enabled-p) -                          (not (bound-and-true-p jao-exwm--use-afio)) -                          (boundp 'exwm-workspace-current-index)) -                     (format "F%s" exwm-workspace-current-index)) -                    (t jao-afio-use-frames (or (jao-afio-frame-name) "")) -                    (t (format "%s" (or (jao-afio-frame-no) "")))) -              'face 'font-lock-warning-face)) - -(jao-minibuffer-add-variable '(jao-current--frame-id) 100)  ;;; Writing and writing modes  ;;;; copyright notices @@ -1252,359 +1298,20 @@    (setq LaTeX-biblatex-use-Biber t)    (setq bibtex-dialect 'biblatex)    :config -  (add-hook 'TeX-after-compilation-finished-functions 'TeX-revert-document-buffer) +  (add-hook 'TeX-after-compilation-finished-functions +            'TeX-revert-document-buffer)    (add-hook 'LaTeX-mode-hook 'turn-on-reftex))  ;;; Browsing -;;;; variables -(defvar jao-browse-doc-use-emacs-p t) -(defvar jao-browse-url-function nil) -(defvar jao-browse-url-external-function nil) - -;;;; url around point -(defun jao-url-around-point (&optional current-url) -  (or (and (fboundp 'w3m-anchor) (w3m-anchor)) -      (shr-url-at-point nil) -      (ffap-url-at-point) -      (thing-at-point 'url) -      (when current-url -        (or (and (fboundp 'w3m-anchor) (w3m-anchor)) -            (and (derived-mode-p 'eww-mode) (plist-get eww-data :url)))))) - -(defun jao--url-prompt (&optional prefix) -  (let* ((def (jao-url-around-point t)) -         (prompt (concat prefix "URL" (if def (format " (%s): " def) ": ")))) -    (read-string prompt nil nil def))) - -;;;; downloads using wget -(defun jao-wget--get-title (filename) -  (or (and (derived-mode-p 'w3m-mode) (w3m-current-title)) -      (plist-get eww-data :title) -      (and (not (string-blank-p (or filename ""))) -           (subst-char-in-string ?- ?  (capitalize (file-name-base filename)))))) - -(defun jao-wget (url &optional user pwd) -  "Download URL using wget and kill a link for an org note." -  (let* ((def (file-name-nondirectory url)) -         (pmt (format "Save %s to: " url)) -         (read-file-name-function nil) -         (dest (expand-file-name -                (read-file-name pmt jao-sink-dir nil nil def))) -         (title (jao-wget--get-title dest)) -         (src-url (or (jao-url-around-point t) (file-name-directory url))) -         (auth (when (and user pwd) -                 `(,(format "--http-user=%s" user) -                   ,(format "--http-password=%s" pwd)))) -         (lnk (concat "doc:" (file-name-nondirectory dest)))) -    (switch-to-buffer-other-window (get-buffer-create "*downloads*")) -    (erase-buffer) -    (kill-new (format "%s (from %s)" -                      (org-link-make-string lnk title) -                      (org-link-make-string src-url "here"))) -    (apply 'make-term `("downloads" "wget" nil ,@auth "-O" ,dest ,url)))) - -(defun jao-download (url &optional pws) -  "Download URL using wget" -  (interactive (list (jao--url-prompt))) -  (when url -    (let ((usr (and pws (read-string "Login name: "))) -          (pwd (and pws (read-passwd "Password: ")))) -      (jao-wget url usr pwd)))) - -(with-eval-after-load "embark" -  (define-key embark-url-map (kbd "d") #'jao-download)) - -;;;; video -(defvar jao-video--url-rx -  (format "^https?://\\(?:www\\.\\)?%s/.+" -          (regexp-opt '("youtu.be" -                        "youtube.com" -                        "blip.tv" -                        "vimeo.com" -                        "infoq.com") -                      t))) - -(defvar jao-video--ext-rx -  (format "^https?://.+/.+\\.%s" (regexp-opt '("mp3" "webm" "mp4")))) - -(defun jao-video--url-p (url) -  (or (string-match-p jao-video--url-rx url) -      (string-match-p jao-video--ext-rx url))) - -(defun jao--remote-run (url prg) -  (let ((args (format "%s %s" prg (shell-quote-argument url)))) -    (start-process-shell-command prg nil args))) - -(defun jao--mpv (url &rest _args) (jao--remote-run url "mpv")) -(defun jao--vlc (url &rest _args) (jao--remote-run url "vlc")) - -(defvar jao--video-player 'jao--mpv) - -(defun jao-view-video (url) -  "Tries to stream a video from the current or given URL" -  (interactive (list (jao--url-prompt "Video "))) -  (when url (funcall jao--video-player url))) - -(defun jao-maybe-view-video (url &rest _ignored) -  (interactive) -  (let ((w (read-char "View video (v) or web page (w)? "))) -    (cond ((eq w ?v) (jao-view-video url)) -          ((eq w ?w) (funcall jao-browse-url-function url)) -          (t (message "Aborted"))))) - -;;;; web browsers -(defun jao-www--buffer-p (b) -  (with-current-buffer b -    (or (derived-mode-p 'w3m-mode 'eww-mode) -        (and (boundp 'exwm-class-name) -             (member exwm-class-name '("vlc" "mpv")))))) - -(require 'jao-custom-eww) -;; (require 'jao-custom-w3m) - -;;;; browse-url -(require 'browse-url) - -(setq browse-url-generic-program "~/bin/firehog") - -(defun jao-browse-with-external-browser (&rest url) -  "Browse with external hogging" -  (interactive "s") -  (let ((url (or (car url) (jao-url-around-point)))) -    (if (not url) -        (message "No URL at point") -      (cond ((and (jao-exwm-enabled-p) (fboundp 'jao-exwm-firefox)) -             (jao-exwm-firefox)) -            (jao-river-enabled (jao-river-to-ws 2)) -            (jao-sway-enabled (jao-sway-firefox))) -      (browse-url-generic url)))) -(setq jao-browse-url-external-function 'jao-browse-with-external-browser) - -(defun jao--fln (url) -  (shell-quote-argument -   (if (string-match "^[^:]*:/*?\\(/?[^/].*\\)" url) -       (match-string-no-properties 1 url) -     url))) - -(defun jao--browse-doc (url &rest _ignored) -  (let* ((url (substring-no-properties url)) -         (file (jao--fln url))) -    (when file -      (unless (file-exists-p file) -        (error "File %s does not exist" file)) -      (jao-open-doc file)))) - -(defun jao--make-file-rx (exts) -  (format "file:/?/?.+\\.%s$" (regexp-opt exts))) - -(defvar jao--see-exts (jao--make-file-rx '("jpg" "jpeg" "png"))) - -(defvar jao--doc-exts -  (jao--make-file-rx '("ps" "ps.gz" "pdf" "dvi" "djvu" "chm"))) - -(defvar jao-browse-url-wget-exts -  '("ps" "pdf" "dvi" "djvu" "zip" "gz" "tgz")) - -(defvar jao-browse-external-domains -  '("github.com" "gitlab.com" "slack.com" "spotify.com" "drive.google.com" -    "meet.google.com" "docs.google.com" "x.com" "twitter.com" -    "t.com" "linkedin.com" "bigml.com" "slack.com" "zoom.us")) - -(defvar jao-browse--external-regexp -  (format "https?://.*%s\\(/.*\\)?" -          (regexp-opt jao-browse-external-domains))) - -(defun jao-wget--regexp () -  (concat "^http[s]?://.+\\(\\." -    (mapconcat 'identity jao-browse-url-wget-exts "\\|\\.") -    "\\)\\'")) - -(defun jao--see (url &rest _r) -  (start-process-shell-command "see" nil (format "see %s" (jao--fln url)))) - -(defun jao--find-file-other-window (url &rest _) -  (find-file-other-window (jao--fln url))) - -(defvar jao-browse--sound-rx -  (format "^https?://.*/.*\\.%s" (regexp-opt '("mp3" "flv")))) - -(defun jao-browse-play-sound-url (url &rest _) -  (jao-mpc-add-or-play-url url)) - -(defun jao-browse-url-browse (&rest args) -  (apply jao-browse-url-function args)) - -(setq browse-url-handlers -      `((jao-video--url-p . jao-maybe-view-video) -        (,jao--doc-exts . jao--browse-doc) -        (,jao--see-exts . jao--see) -        ("^file://?.+\\.html?$" . ,jao-browse-url-function) -        ("^file://?" . jao--find-file-other-window) -        (,jao-browse--external-regexp . ,jao-browse-url-external-function) -        ("^https?://.*\\.gotomeeting\\.com\\.*" . browse-url-chrome) -        (,jao-browse--sound-rx . jao-browse-play-sound-url) -        (,(jao-wget--regexp) . jao-download) -        ("." . jao-browse-url-browse))) - -(when (< emacs-major-version 28) -  (setf (alist-get 'jao-video--url-p browse-url-handlers nil t) nil) -  (setq browse-url-browser-function browse-url-handlers)) - -;;;; subscribe to rss using r2e -(autoload 'View-quit "view") - -(defun jao-rss--find-url () -  (save-excursion -    (when (derived-mode-p 'w3m-mode 'eww-mode) -      (if (fboundp 'w3m-view-source) (w3m-view-source) (eww-view-source))) -    (goto-char (point-min)) -    (when (re-search-forward -           "type=\"application/\\(?:atom\\|rss\\)\\+xml\" +" nil t) -      (let ((url (save-excursion -                   (when (re-search-forward -                          "href=\"\\([^\n\"]+\\)\"" nil t) -                     (match-string-no-properties 1)))) -            (title (when (re-search-forward -                          "\\(?:title=\"\\([^\n\"]+\\)\" +\\)" nil t) -                     (match-string-no-properties 1)))) -        (cond ((derived-mode-p 'w3m-view-mode) (w3m-view-source)) -              ((string-match-p ".*\\*eww-source\\b.*" (buffer-name)) -               (View-quit))) -        (when url (cons url (or title ""))))))) - -(defun jao-rss2e-append (name url mbox) -  (with-current-buffer (find-file-noselect "~/.config/rss2email.cfg") -    (goto-char (point-max)) -    (insert "[feed." name "]\nurl = " url) -    (insert "\nto = " mbox "+" name "@localhost") -    (insert "\nmaildir-mailbox = " mbox "\n\n") -    (save-buffer))) - -(defun jao-rss--feeds-dirs () -  (mapcar (lambda (d) (cadr (split-string d "\\."))) -          (directory-files "~/.emacs.d/gnus/Mail/" nil "^feeds"))) - -(defun jao-rss-subscribe (url) -  "Subscribe to a given RSS URL.  If URL not given, look for it." -  (interactive (list (or (jao-url-around-point) -                         (jao-rss--find-url) -                         (read-string "Feed URL: ")))) -  (let* ((url+title (ensure-list url)) -         (url (car url+title)) -         (title (cdr url+title))) -    (unless url (error "No feeds found")) -    (let ((url (if (string-match "^feed:" url) (substring url 5) url))) -      (when (y-or-n-p (format "Subscribe to <%s>? " url)) -        (let* ((name (read-string "Feed name: " title)) -               (cats (cons "prog" (jao-notmuch--subtags "feeds"))) -               (cat (completing-read "Category: " cats nil t)) -               (subs (format "r2e add %s '%s' feeds.%s@localhost" -                             name url cat))) -          ;; (jao-rss2e-append name url cat) -          (shell-command-to-string subs) -          (shell-command (format "r2e run %s" name))))))) +(jao-when-linux + (require 'jao-custom-browse) + (require 'jao-custom-eww))  ;;; PDFs and other docs -;;;; open pdfs -(use-package jao-pdf :demand t) -(use-package saveplace-pdf-view -  :ensure t -  :demand t -  :after doc-view) - -(setq jao-open-doc-fun 'jao-find-or-open) -(setq jao-org-open-pdf-fun 'jao-find-or-open) - -(defun jao-zathura-open (file page) -  (let ((id (jao-x11-search-window (jao-pdf-zathura-title-rx file)))) -    (if (string-blank-p id) -        (progn -          (when jao-xmonad-enabled (jao-x11-goto-ws 2)) -          (jao-shell-exec (jao-pdf-zathura-open-cmd file page))) -      (let* ((page (if page (format " && xdotool type %dg" page) "")) -             (cmd (format "xdotool windowactivate %s%s" id page))) -        (jao-shell-exec cmd t))))) - -(defun jao-x11-zathura-goto-org (&optional title no-ask) -  (let ((title (or title (jao-shell-string "xdotool" -                                           "getactivewindow" -                                           "getwindowname")))) -    (jao-org-open-from-zathura title no-ask))) - -(defun jao-find-or-open (file &optional page height) -  (cond ((and jao-browse-doc-use-emacs-p window-system) -         (let* ((buffs (buffer-list)) -                (b (catch 'done -                     (while buffs -                       (when (string-equal (buffer-file-name (car buffs)) file) -                         (throw 'done (car buffs))) -                       (setq buffs (cdr buffs)))))) -           (jao-afio-goto-docs) -           (if b (pop-to-buffer b) (find-file file)) -           (when page (jao-doc-view-goto-page page height)))) -        (jao-river-enabled (jao-river-open-with-zathura file page)) -        (jao-sway-enabled (jao-sway-open-with-zathura file page)) -        (t (jao-zathura-open file page)))) - -(defun jao-open-doc (&optional file page height) -  (interactive) -  (when-let (file (or file -                      (read-file-name "Document: " -                                      (concat jao-org-dir "/doc/")))) -    (funcall jao-open-doc-fun file page height))) +;;;; doc view &co. -(defun jao-select-pdf () -  (interactive) -  (jao-buffer-same-mode '(pdf-view-mode doc-view-mode) -                        #'jao-afio-goto-docs)) - -(defun jao-open-with-zathura () -  (interactive) -  (when-let (f buffer-file-name) -    (let ((p (jao-doc-view-current-page))) -      (cond (jao-river-enabled (jao-river-open-with-zathura f p)) -            (jao-sway-enabled (jao-sway-open-with-zathura f p)) -            (t (jao-zathura-open f p)))))) - -;; doc:// links for browse-url -(defun jao-open-doc-url (url &rest _) -  (when (string-match "doc://\\([^?]+\\)\\(\\?.*\\)?" url) -    (let ((file (match-string 1 url)) -          (page (when-let* ((qs (match-string 2 url)) -                            (long (> (length qs) 1)) -                            (ps (url-parse-query-string (substring qs 1))) -                            (pn (cadr (assoc "page" ps)))) -                  (string-to-number pn)))) -      (jao-open-doc (expand-file-name (concat "doc/" file) jao-org-dir) page)))) - -(add-to-list 'browse-url-handlers (cons "^doc://.+" 'jao-open-doc-url)) - -;;;; doc-view -(use-package doc-view -  :init -  (setq doc-view-cache-directory "~/.emacs.d/cache/docview" -        doc-view-resolution 110 -        doc-view-continuous t -        doc-view-conversion-refresh-interval 1 -        doc-view-mupdf-use-svg t) -  :hook ((doc-view-mode . jao-doc-session-mark)) -  :bind (:map doc-view-mode-map -              ("j" . doc-view-next-line-or-next-page) -              ("J" . doc-view-search-next-match) -              ("k" . doc-view-previous-line-or-previous-page) -              ("K" . doc-view-search-previous-match) -              ("z" . jao-open-with-zathura))) - -(use-package jao-doc-session :demand t) - -(use-package jao-doc-view -  :demand t -  :bind (:map doc-view-mode-map -              ("b" . jao-doc-view-back) -              ("B" . jao-doc-view-forward) -              ("S" . jao-doc-session-save) -              ("u" . jao-doc-view-visit-url))) +(jao-when-linux (require 'jao-custom-pdf))  ;;;; epub  (use-package nov @@ -1618,47 +1325,8 @@      (jao-doc-session-mark nov-file-name))    (add-hook 'nov-mode-hook #'jao-nov-register-session)) -;;;; transient -(defun jao-org-pdf-goto-org-linking () -  (interactive) -  (jao-org-pdf-goto-org 4)) - -(jao-transient-major-mode doc-view -  ["Notes" -   ("o" "notes file" jao-org-pdf-goto-org) -   ("O" "notes file, linking" jao-org-pdf-goto-org-linking)] -  ["Navigation" -   ("b" "back jump" jao-doc-view-back) -   ("B" "forward jump" jao-doc-view-back) -   ("u" "visit URL" jao-doc-view-visit-url)] -  ["Slices" -   ("cb" "bounding box" doc-view-set-slice-from-bounding-box) -   ("cm" "using mouse" doc-view-set-slice-using-mouse)] -  ["Session" -   ("s" "load session" jao-afio-open-pdf-session) -   ("S" "save session" jao-doc-session-save) -   ("d" "visit cache directory" doc-view-dired-cache)] -  ["External viewers" -   ("z" "open with zathura" jao-open-with-zathura)]) - -(with-eval-after-load "pdf-view" -  (jao-transient-major-mode pdf-view -    ["Notes" -     ("o" "notes file" jao-org-pdf-goto-org) -     ("O" "notes file, linking" jao-org-pdf-goto-org-linking)] -    ["Navigation" -     ("b" "back jump" pdf-history-backward) -     ("f" "forward jump" pdf-history-forward)] -    ["Session" -     ("s" "load session" jao-afio-open-pdf-session) -     ("S" "save session" jao-doc-session-save)] -    ["External viewers" -     ("z" "open with zathura" jao-open-with-zathura)])) - -;; (transient-get-suffix 'jao-transient-pdf-view '(0 -1)) -  ;;; Email -(require 'jao-custom-email) +(jao-when-linux (require 'jao-custom-email))  ;;; Shells and terms  ;;;; shell modes @@ -1820,12 +1488,6 @@  (use-package eshell-autojump :ensure t)  ;;;;; completion -(defun jao-eshell-completion-capf () -  (let* ((b (save-excursion (eshell-bol) (point))) -         (c (bash-completion-dynamic-complete-nocomint b (point) t))) -    (when (and c (listp c)) -      (append c '(:exclusive no))))) -  (defun jao-eshell--set-up-completion ()    (setq-local completion-styles '(basic partial-completion)) @@ -1846,11 +1508,11 @@  ;;;;; workarounds  ;; at some point, bash completion started insertig the TAB  ;; after the commands ends -(defun jao-eshell--clean-prompt () -  (eshell-bol) -  (ignore-errors (kill-line))) +;; (defun jao-eshell--clean-prompt () +;;   (eshell-bol) +;;   (ignore-errors (kill-line))) -(add-hook 'eshell-after-prompt-hook 'jao-eshell--clean-prompt) +;; (add-hook 'eshell-after-prompt-hook 'jao-eshell--clean-prompt)  ;;;;; keybindings  (defun jao-eshell--kbds () @@ -1889,6 +1551,13 @@    :ensure t    :commands magit-status    :init +  (setq magit-repository-directories +        (jao-d-l +         '(("/Users/jao/Projects" 3)) +         '(("/home/jao/usr/bigml" . 2) +           ("/home/jao/usr/jao" . 3) +           ("/usr/local/src" . 1)))) +    (setq magit-status-initial-section nil          magit-define-global-key-bindings nil          magit-completing-read-function 'magit-builtin-completing-read @@ -1900,10 +1569,6 @@          magit-omit-untracked-dir-contents t          magit-process-connection-type nil          magit-push-always-verify nil -        magit-repository-directories -        '(("/home/jao/usr/bigml" . 2) -          ("/home/jao/usr/jao" . 3) -          ("/usr/local/src" . 1))          magit-save-repository-buffers 'dontask          magit-section-visibility-indicator '("…" . t)          magit-status-buffer-switch-function 'switch-to-buffer @@ -1920,15 +1585,6 @@    (use-package embark-vc :ensure t)    :bind ((:map forge-topic-mode-map ("M-w" . copy-region-as-kill)))) - -;;;; code reviews -(use-package code-review -  :disabled t -  :ensure t -  :after forge -  :bind (:map magit-status-mode-map -              ("C-c C-r" . code-review-forge-pr-at-point))) -  ;;;; other git packages  (use-package git-timemachine :ensure t) @@ -1941,541 +1597,9 @@  (use-package git-link :ensure t)  (use-package git-modes :ensure t) -;;;; jenkins -(use-package jenkins -  :ensure t -  :init -  ;; one also needs jenkins-api-token, jenkins-username and jenkins-url -  ;; optionally: jenkins-colwidth-id, jenkins-colwidth-last-status -  (setq jenkins-colwidth-name 35) -  :config -  (defun jao-jenkins-first-job (&rest _) -    (interactive) -    (goto-char (point-min)) -    (when (re-search-forward "^- Job" nil t) -      (goto-char (match-beginning 0)))) -  (add-hook 'jenkins-job-view-mode-hook #'jao-jenkins-first-job) -  (advice-add 'jenkins-job-render :after #'jao-jenkins-first-job) - -  (defun jenkins-refresh-console-output () -    (interactive) -    (let ((n (buffer-name))) -      (when (string-match "\\*jenkins-console-\\([^-]+\\)-\\(.+\\)\\*$" n) -        (jenkins-get-console-output (match-string 1 n) (match-string 2 n)) -        (goto-char (point-max))))) - -  :bind (:map jenkins-job-view-mode-map -              (("n" . next-line) -               ("p" . previous-line) -               ("f" . jao-jenkins-first-job) -               ("RET" . jenkins--show-console-output-from-job-screen)) -              :map jenkins-console-output-mode-map -              (("n" . next-line) -               ("p" . previous-line) -               ("g" . jenkins-refresh-console-output)))) -  ;;; Programming -;;;; automatic modes -(add-to-list 'auto-mode-alist '("\\.mix\\'" . hexl-mode)) -(add-to-list 'auto-mode-alist '("\\.m4\\'" . m4-mode)) -(add-to-list 'auto-mode-alist '("\\.am\\'" . makefile-mode)) -(add-to-list 'auto-mode-alist '("\\.pl\\'\\|\\.pm\\'" . cperl-mode)) - -;;;; symbol overlay -(use-package symbol-overlay -  :ensure t -  :config -  (defun jao-symbol-reveal (&rest _) -    (when outline-minor-mode (outline-show-entry))) -  (advice-add 'symbol-overlay-basic-jump :after 'jao-symbol-reveal) - -  (defun jao-symbol-put-and-next () -    (interactive) -    (symbol-overlay-put) -    (symbol-overlay-jump-next)) - -  (defun jao-symbol-put-and-prev () -    (interactive) -    (symbol-overlay-put) -    (symbol-overlay-jump-prev)) - -  :bind (:map prog-mode-map (("M-i" . symbol-overlay-put) -                             ("M-n" . jao-symbol-put-and-next) -                             ("M-p" . jao-symbol-put-and-prev))) -  :hook (prog-mode . symbol-overlay-mode) -  :diminish " ^") - -;;;; eglot -(use-package eglot -  :bind (:map eglot-mode-map (("C-h ." . jao-eldoc-toggle)))) - -;;;; paredit and parens -(require 'paren) -(show-paren-mode t) -(setq show-paren-context-when-offscreen t -      show-paren-when-point-inside-paren nil) - -(use-package paredit -  :ensure t -  :commands paredit-mode -  :hook ((pie-mode . paredit-mode) -         (scheme-mode . paredit-mode) -         (clojure-mode . paredit-mode) -         (emacs-lisp-mode . paredit-mode) -         ;; (eval-expression-minibuffer-setup . paredit-mode) -         (lisp-interaction-mode . disable-paredit-mode)) -  :diminish ((paredit-mode . " þ"))) - -;;;; diff/ediff -(setq ediff-split-window-function 'split-window-horizontally) -(setq ediff-make-buffers-readonly-at-startup nil) -(setq ediff-window-setup-function 'ediff-setup-windows-plain) -(setq ediff-keep-variants nil) - -;;;; compilation -;;;;; compilation mode options -(require 'compile) -(setq compilation-scroll-output t) -(setq compilation-error-regexp-alist -      (remove 'omake compilation-error-regexp-alist)) -;; (add-hook 'compilation-mode-hook #'visual-line-mode) - -;;;;; mode line (no "Compiling"!) -(require 'compile) -(diminish 'compilation-minor-mode " ‡") -(when (< emacs-major-version 27) -  (setcdr (assq 'compilation-in-progress minor-mode-alist) '(" ‡"))) -(when (> emacs-major-version 26) -  (setcdr (assq 'compilation-in-progress mode-line-modes) '("‡ "))) - -;;;;; colorizing compilation buffer -(setq compilation-message-face 'default) -(require 'ansi-color) -(defun endless/colorize-compilation () -  "Colorize from `compilation-filter-start' to `point'." -  (let ((inhibit-read-only t)) -    (ansi-color-apply-on-region -     compilation-filter-start (point)))) - -(add-hook 'compilation-filter-hook #'endless/colorize-compilation) - -;;;;; compilation commands -(use-package jao-compilation -  :commands jao-compilation-setup -  :bind (("C-c C" . compile) -         ("C-c c" . jao-compile))) -(jao-compilation-setup) - -;;;;; next error -(setq next-error-find-buffer-function -      #'next-error-buffer-on-selected-frame -      next-error-verbose t) - -;;;; flymake -(use-package flymake -  :ensure t -  :custom ((flymake-mode-line-format '(" " flymake-mode-line-counters))) -  :config -  (jao-define-attached-buffer "^\\*Flymake diagnostics .*\\*\\'") - -  (transient-define-prefix jao-transient-flymake () -    ["Flymake" -     ("d" "show diagnostics" flymake-show-buffer-diagnostics) -     ("i" "show diagnostic" flymake-show-diagnostic) -     ("n" "next error" flymake-goto-next-error) -     ("p" "previous error" flymake-goto-prev-error) -     ("c" "consult flymake" consult-flymake)]) - -  :bind (:map flymake-mode-map (("M-m" . jao-transient-flymake)))) - -;;;; workarounds -(setq c-type-finder-time-slot nil) - -;;;; outline minor mode -(use-package outline -  :init (setq outline-minor-mode-use-buttons nil -              outline-minor-mode-use-margins nil -              outline-minor-mode-cycle t)) -(defvar-local jao-outline-folded nil) -(dolist (v '(4 5 outline-show-only-headings)) -  (add-to-list 'safe-local-variable-values `(outline-default-state . ,v))) - -(defun jao-outline-minor-mode-hide-all (&optional arg) -  (interactive "P") -  (outline-hide-sublevels (if arg 5 4))) - -(defun jao-outline-minor-expand-all () -  (when jao-outline-minor-mode (outline-show-all))) - -(defun jao-outline-minor-mode-toogle-fold (&optional arg) -  (interactive "P") -  (if (setq jao-outline-folded (not jao-outline-folded)) -      (jao-outline-minor-mode-hide-all arg) -    (jao-outline-minor-expand-all))) - -(use-package outline-minor-faces -  :ensure t -  :after outline) - -(define-minor-mode jao-outline-minor-mode -  "Minor outline mode for programming languages" -  :lighter "" -  :keymap `((,(kbd "C-c C-n") . outline-next-visible-heading) -            (,(kbd "C-c C-p") . outline-previous-visible-heading) -            (,(kbd "C-c o") . consult-outline) -            (,(kbd "<f3>") . jao-outline-minor-mode-toogle-fold)) -  (if jao-outline-minor-mode -      (progn (setq-local outline-level #'outline-level -                         outline-regexp (format "[%s]\\{3,\\} " comment-start)) -             (outline-minor-mode 1) -             (outline-minor-faces-mode 1)) -    (outline-minor-mode -1) -    (outline-minor-faces-mode -1))) - -(add-hook 'find-function-after-hook #'jao-outline-minor-expand-all) - -;;; Programming languages -;;;; Elisp -(add-hook 'emacs-lisp-mode-hook #'jao-outline-minor-mode) - -(use-package edit-list :ensure t) -;; (use-package package-lint :ensure t) -;; (use-package tree-inspector :ensure t) - -(defun elisp-disassemble (function) -  (interactive (list (function-called-at-point))) -  (disassemble function)) - -(defun elisp-pp (sexp) -  (with-output-to-temp-buffer "*Pp Eval Output*" -    (pp sexp) -    (with-current-buffer standard-output -      (emacs-lisp-mode)))) - -(defun elisp-macroexpand (form) -  (interactive (list (form-at-point 'sexp))) -  (elisp-pp (macroexpand form))) - -(defun elisp-macroexpand-all (form) -  (interactive (list (form-at-point 'sexp))) -  (elisp-pp (macroexpand-all form))) - -(defun elisp-find-definition (name) -  (interactive (list (thing-at-point 'symbol))) -  (cond (name -         (let ((symbol (intern-soft name)) -               (search (lambda (fun sym) -                         (let* ((r (save-excursion (funcall fun sym))) -                                (buffer (car r)) -                                (point (cdr r))) -                           (cond ((not point) -                                  (error "Found no definition for %s in %s" -                                         name buffer)) -                                 (t -                                  (switch-to-buffer buffer) -                                  (goto-char point) -                                  (recenter 1))))))) -           (cond ((fboundp symbol) -                  (xref-push-marker-stack) -                  (funcall search 'find-function-noselect symbol)) -                 ((boundp symbol) -                  (xref-push-marker-stack) -                  (funcall search 'find-variable-noselect symbol)) -                 (t -                  (message "Symbol not bound: %S" symbol))))) -        (t (message "No symbol at point")))) - - -(defun elisp-bytecompile-and-load () -  (interactive) -  (or buffer-file-name -      (error "The buffer must be saved in a file first")) -  (require 'bytecomp) -  ;; Recompile if file or buffer has changed since last compilation. -  (when  (and (buffer-modified-p) -              (y-or-n-p (format "save buffer %s first? " (buffer-name)))) -    (save-buffer)) -  (let ((filename (expand-file-name buffer-file-name))) -    (with-temp-buffer -      (byte-compile-file filename)))) - -(use-package elisp-mode -  :bind (:map emacs-lisp-mode-map -              (("C-c C-M" . emacs-lisp-macroexpand) -               ("C-c C-m" . elisp-macroexpand-all) -               ("C-c C-k" . elisp-bytecompile-and-load) -               ;; ("C-c C-p" . pp-eval-last-sexp) -               ("M-." . elisp-find-definition) -               ("M-," . pop-tag-mark) -               ("C-c <" . lc-show-package-summary)))) - -;;;; Clojure -(use-package clojure-mode -  :ensure t -  :config -  (defun jao-clojure--fix-things () -    (setq-local completion-styles '(basic partial-completion emacs22)) -    (eldoc-mode 1) -    (setq mode-name "λ")) -  :hook (clojure-mode . jao-clojure--fix-things)) - -(defun jao-cider-test-ns (ns) -  (let ((parts (string-split ns "\\."))) -    (if (string= "test" (cadr parts)) -        ns -        (mapconcat #'identity (cons (car parts) (cons "test" (cdr parts))) ".")))) - -(defun jao-kaocha-file-name () -  (let* ((filename (match-string 2)) -         (path (replace-regexp-in-string "\\." "/" (match-string 1)))) -    (substring-no-properties (concat "test/" path filename)))) - -(defconst jao-kaocha-compilation-error -  '(kaocha-error "^FAIL in \\(.+\\.\\)[^ ]+ (\\([^:]+\\.clj[cs]?\\):\\([0-9]+\\))" -                 jao-kaocha-file-name 3)) - -(use-package compile -  :config -  (add-to-list 'compilation-error-regexp-alist-alist -               jao-kaocha-compilation-error)) - -(use-package cider -  :ensure t -  :commands cider-mode -  :init (setq cider-annotate-completion-candidates t -              cider-auto-select-error-buffer nil -              cider-auto-select-test-report-buffer nil -              cider-eldoc-display-for-symbol-at-point t -              cider-eldoc-ns-function #'identity ;; #'cider-last-ns-segment -              cider-enrich-classpath nil -              cider-lein-parameters "repl :headless :host localhost" -              cider-mode-line  " ÷" -              cider-prompt-for-symbol nil -              cider-repl-history-file -              (expand-file-name "~/.emacs.d/cache/cider.history") -              cider-repl-pop-to-buffer-on-connect nil -              cider-repl-use-pretty-printing t -              cider-show-error-buffer 'except-in-repl -              cider-test-show-report-on-success nil -              cider-test-infer-test-ns #'jao-cider-test-ns -              cider-use-fringe-indicators nil -              cider-use-overlays nil -              clojure-docstring-fill-column 72 -              nrepl-prompt-to-kill-server-buffer-on-quit nil) -  :bind (("<f3>" . cider-selector))) - -(with-eval-after-load "cider-test" -  (advice-add 'cider-scale-background-color :override -              (lambda () (frame-parameter nil 'background-color))) -  (setq cider-test-items-background-color -        (frame-parameter nil 'background-color))) - -(use-package cider-macroexpansion -  :after cider -  :diminish " µ") - -;;;; Geiser -(defun jao-org--set-geiser-impl () (setq-local geiser-repl--impl 'guile)) -(add-hook 'org-mode-hook #'jao-org--set-geiser-impl) - -(jao-load-path "geiser") -;; (package-vc-install-from-checkout ...) -(use-package geiser -  :demand t -  :init -  (setq geiser-repl-history-filename "~/.emacs.d/cache/geiser-history" -        geiser-repl-startup-time 20000 -        geiser-debug-auto-display-images t -        geiser-log-verbose t) -  :config -  (dolist (m '(geiser-repl-mode geiser-doc-mode geiser-debug-mode)) -    (jao-define-attached-buffer `(major-mode . ,m) 0.4))) - -(jao-load-path "geiser-guile") -(use-package geiser-guile) - -(jao-load-path "geiser-chez") -(use-package geiser-chez) - -;; (jao-load-path "geiser/mit") -;; (use-package geiser-mit) - -;; (jao-load-path "geiser/chicken") -;; (use-package geiser-chicken) - -;; (jao-load-path "geiser/chibi") -;; (use-package geiser-chibi) - -;; (jao-load-path "geiser/gambit") -;; (use-package geiser-gambit) - -;; (jao-load-path "geiser/gauche") -;; (use-package geiser-gauche) - -;;;; Haskell -;;;;; packages -;; (jao-load-path "haskell-mode") - -(use-package haskell-mode -  :ensure t -  :custom -  ((inferior-haskell-find-project-root t) -   (haskell-check-remember-last-command-p nil) -   (haskell-completing-read-function 'completing-read) -   (haskell-font-lock-symbols nil) -   (haskell-hoogle-command "hoogle") -   (haskell-interactive-popup-errors t) -   (haskell-process-auto-import-loaded-modules t) -   (haskell-process-log t) -   (haskell-process-suggest-remove-import-lines t) -   (haskell-process-suggest-hoogle-imports t) -   (haskell-process-type 'cabal-repl) -   (haskell-process-use-presentation-mode t) -   (haskell-stylish-on-save nil) -   (haskell-tags-on-save t)) - -  :init -  ;; For use with M-x align -  (require 'align) -  (add-to-list 'align-rules-list -               '(haskell-types -                 (regexp . "\\(\\s-+\\)\\(::\\|∷\\)\\s-+") -                 (modes quote (haskell-mode haskell-literate-mode)))) -  (add-to-list 'align-rules-list -               '(haskell-assignment -                 (regexp . "\\(\\s-+\\)=\\s-+") -                 (modes quote (haskell-mode haskell-literate-mode)))) -  (add-to-list 'align-rules-list -               '(haskell-arrows -                 (regexp . "\\(\\s-+\\)\\(->\\|→\\)\\s-+") -                 (modes quote (haskell-mode haskell-literate-mode)))) -  (add-to-list 'align-rules-list -               '(haskell-left-arrows -                 (regexp . "\\(\\s-+\\)\\(<-\\|←\\)\\s-+") -                 (modes quote (haskell-mode haskell-literate-mode)))) - -  :config -  (defun jao-haskell-hoogle (no-info) -    (interactive "P") -    (haskell-hoogle (format "%s" (haskell-ident-at-point)) (not no-info))) - -  (put 'haskell-process-args-cabal-repl -       'safe-local-variable -       (apply-partially #'seq-every-p #'stringp)) - -  (defun jao-haskell-eldoc (cb) -    (let ((msg (or (haskell-doc-current-info--interaction t) -                   (haskell-doc-sym-doc (haskell-ident-at-point)) -                   ""))) -      (funcall cb (replace-regexp-in-string "[\n ]+" " " msg)))) - -  (setq tags-revert-without-query t) - -  (defun jao-haskell-mode () -    (require 'haskell-doc) -    (setq-local eldoc-documentation-function 'eldoc-documentation-default -                eldoc-documentation-functions '(jao-haskell-eldoc)) -    (eldoc-mode)) - -  (dolist (h '(jao-haskell-mode -               haskell-decl-scan-mode -               haskell-indentation-mode -               interactive-haskell-mode)) -    (add-hook 'haskell-mode-hook h)) - -  (add-hook 'haskell-presentation-mode-hook (lambda () (whitespace-mode -1))) - -  :bind (:map haskell-mode-map -              (("C-c C-d" . jao-haskell-hoogle) -               ("C-c C-s" . haskell-session-change-target) -               ("C-c h" . haskell-hoogle) -               ("C-c t" . haskell-doc-show-type) -               ("C-c C-e" . haskell-command-insert-language-pragma) -               ("C-M-n" . flymake-goto-next-error) -               ("C-M-p" . flymake-goto-prev-error) -               ("<f3>" . haskell-session-kill)))) - -(use-package hlint-refactor -  :ensure t -  :after haskell-mode -  :hook ((haskell-mode . hlint-refactor-mode)) -  :bind (:map haskell-mode-map (("C-M-h" . 'hlint-refactor-refactor-at-point) -                                ("C-M-S-h" . 'hlint-refactor-refactor-buffer))) -  :diminish) - -(use-package flymake-hlint -  :ensure t -  :after haskell-mode -  :hook ((haskell-mode . flymake-hlint-load))) - - -(use-package consult-hoogle -  :ensure t) - -(require 'haskell) - -(diminish 'interactive-haskell-mode " λ") -(diminish 'haskell-doc-mode) -(diminish 'haskell-decl-scan-mode) - -(jao-define-attached-buffer "\\*hoogle\\*.*") -(jao-define-attached-buffer '(major-mode . haskell-interactive-mode) 0.33) -(jao-define-attached-buffer '(major-mode . haskell-presentation-mode) 0.25) - -;;;;; transient -(jao-transient-major-mode haskell -  ["Imports" -   ("in" "Navigate imports" haskell-navigate-imports) -   ("if" "Format imports" haskell-mode-format-imports) -   ("is" "Sort imports" haskell-sort-imports) -   ("ia" "Align imports" haskell-align-imports)] -  ["Session" -   ("s" "Change the session's target" haskell-session-change-target)] -  ["Code" -   ("e" "insert language pragma" haskell-command-insert-language-pragma) -   ("v" "visit cabal file" haskell-cabal-visit-file) -   ("h" "hoogle" jao-haskell-hoogle) -   ("t" "show type" haskell-doc-show-type)] -  ["Flymake" -   ("n" "next error" flymake-goto-next-error) -   ("p" "previous error" flymake-goto-prev-error)]) - -;;;; Pie -(jao-load-path "pie") -(use-package pie -  :demand t -  :commands (pie-mode)) - -;;;; Prolog -;; (use-package ediprolog :ensure t) - -(use-package prolog -  :ensure t -  :commands (run-prolog prolog-mode mercury-mode) -  :init (progn -          (setq prolog-system 'swi) -          (add-to-list 'auto-mode-alist '("\\.pl$" . prolog-mode)) -          (setq prolog-consult-string '((t "[%f]."))) -          (setq prolog-program-name -                '(((getenv "EPROLOG") (eval (getenv "EPROLOG"))) -                  (eclipse "eclipse") -                  (mercury nil) -                  (sicstus "sicstus") -                  (swi "swipl") -                  (t "prolog"))))) - -;;;; Python -(use-package virtualenvwrapper -  :ensure t -  :config -  (venv-initialize-eshell) -  (jao-compilation-env "VIRTUAL_ENV")) -;;;; Javascript - -(use-package typescript-mode -  :ensure t -  :custom ((typescript-indent-level 2))) +(require 'jao-custom-programming)  ;;; Text/data formats  ;;;; json @@ -2498,20 +1622,17 @@  ;;; Network  ;;;; nm applet -(jao-shell-def-exec jao-nm-applet "nm-applet") +(jao-when-linux + (jao-shell-def-exec jao-nm-applet "nm-applet") -(defun jao-toggle-nm-applet () -  (interactive) -  (or (jao-shell-kill-p "nm-applet") (jao-nm-applet))) + (defun jao-toggle-nm-applet () +   (interactive) +   (or (jao-shell-kill-p "nm-applet") (jao-nm-applet))))  ;;;; bluetooth -(use-package bluetooth :ensure t) - -;;;; vpn -(use-package jao-mullvad :demand t) +(jao-when-linux (use-package bluetooth :ensure t))  ;;;; ssh -(use-package tramp)  (defun jao-tramp-hosts ()    (seq-uniq     (mapcan (lambda (x) @@ -2526,838 +1647,29 @@      (jao-exec-in-term (format "ssh %s" h) (format "*ssh %s*" h))))  ;;; Chats -;;;; circe -(defvar jao-libera-channels ()) -(defvar jao-oftc-channels ()) -(defvar jao-bitlbee-channels ()) -(defvar jao-slack-channels ()) - -(use-package circe -  :ensure t -  :bind (:map circe-channel-mode-map -              (("C-c C-a" . lui-track-jump-to-indicator))) -  :init -  (setq circe-chat-buffer-name "{target} - {network}" -        circe-default-realname "https://jao.io" -        circe-default-part-message "" -        circe-default-quit-message "" -        circe-ignore-list nil -        circe-server-coding-system '(undecided . undecided) -        circe-server-killed-confirmation 'ask-and-kill-all -        circe-server-auto-join-default-type :after-auth -        circe-server-buffer-name "{network} - {host}:{port}" -        circe-format-say "({nick}) {body}" -        circe-format-self-say "(jao) {body}" -        circe-new-buffer-behavior 'ignore -        circe-new-buffer-behavior-ignore-auto-joins t -        circe-nickserv-ghost-style 'after-auth -        circe-prompt-string ": " -        circe-completion-suffix ", " -        circe-reduce-lurker-spam t - -        circe-lagmon-mode-line-format-string "" ;;  "%.0f " -        circe-lagmon-mode-line-unknown-lag-string "" ;; "? " -        circe-lagmon-timer-tick 120 -        circe-lagmon-reconnect-interval 180 - -        lui-max-buffer-size 30000 -        lui-fill-column 80 -        lui-time-stamp-position 'right -        lui-time-stamp-format "%H:%M" -        lui-flyspell-p nil - -        lui-track-indicator (if window-system 'fringe 'bar) -        lui-track-behavior 'before-tracking-next-buffer) -  :config - -  (defsubst jao-circe-nick-no () -    (if (derived-mode-p 'circe-query-mode) -        2 -        (length (circe-channel-nicks)))) - -  (defsubst jao-circe-netowrk () -    (or (plist-get lui-logging-format-arguments :network) "")) - -  (define-minor-mode jao-circe-user-number-mode "" -    :lighter (:eval (format " [%s]" (jao-circe-nick-no)))) - -  (defun jao-circe-channel-hook () -    (when jao-mode-line-in-minibuffer -      (setq header-line-format -            '(" %b" (:eval (format "@%s - %s nicks" -                                   (jao-circe-netowrk) -                                   (jao-circe-nick-no)))))) -    (jao-circe-user-number-mode 1)) - -  (add-hook 'circe-channel-mode-hook #'jao-circe-channel-hook) -  (add-hook 'circe-query-mode-hook #'jao-circe-channel-hook) - -  (defun circe-command-RECOVER (&rest _ignore) -    "Recover nick" -    (jao-with-auth "freenode" u p -      (circe-command-MSG "nickserv" (format "IDENTIFY %s %s" u p)) -      (circe-command-MSG "nickserv" (format "GHOST %s" u)) -      (circe-command-MSG "nickserv" (format "RELEASE %s" u)) -      (circe-command-NICK u))) - -  (defun circe-command-NNICKS (&rest _) -    "Echo number of nicks" -    (circe-display-server-message -     (format "%d nicks in this channel" (jao-circe-nick-no)))) - -  (defun circe-command-SENDFILE (line) -    "/sendfile for localslackirc" -    (circe-command-QUOTE (format "sendfile %s" line))) - -  (advice-add 'circe-command-NAMES :after #'circe-command-NNICKS) - -  (defun jao-circe-reconnect-unmonitored () -    (interactive) -    (dolist (b (buffer-list)) -      (with-current-buffer b -        (when (and (derived-mode-p 'circe-server-mode) -                   circe-lagmon-disabled) -          (circe-reconnect))))) - -  (add-to-list 'jao-sleep-awake-functions #'jao-circe-reconnect-unmonitored) - -  (setq circe-network-options -        (list (jao-with-auth "libera" u p -                (list "Libera Chat" :nick u :channels jao-libera-channels -                      :tls t :sasl-username u :sasl-password p)) -              (jao-with-auth "oftc" u p -                (list "OFTC" -                      :nick u :channels jao-oftc-channels :nickserv-password p -                      :tls t :sasl-username u :sasl-password p)) -              (jao-with-auth "bitlbee" u p -                (list "Bitlbee" :host "127.0.0.1" :nick u -                      :channels jao-bitlbee-channels :lagmon-disabled t -                      :nickserv-password u :user p)))) - -  (jao-shorten-modes 'circe-channel-mode -                     'circe-server-mode -                     'circe-query-mode) - -  (enable-circe-display-images) -  (enable-lui-track) -  (circe-lagmon-mode)) - -;;;; telegram -(use-package telega -  :ensure t -  :custom -  (telega-use-tracking-for '(unmuted) ;; '(or unmuted mention) -   telega-rainbow-color-custom-for nil -   telega-msg-rainbow-title nil -   telega-sticker-set-download t -   telega-symbol-checkmark "·" -   telega-symbol-heavy-checkmark "×" -   telega-symbol-verified "*") -  :config -  (define-key global-map (kbd "C-c C-t") telega-prefix-map) -  (setq telega-chat-show-avatars nil -        telega-chat-prompt-insexp '(telega-ins "> ") -        telega-completing-read-function #'completing-read -        telega-root-show-avatars nil -        telega-emoji-use-images nil -        telega-temp-dir "/tmp/telega" -        telega-symbol-horizontal-bar -        (propertize "-" 'face 'jao-themes-f00) -        telega-symbol-vertical-bar -        (propertize "| " 'face 'jao-themes-dimm) -        telega-mode-line-string-format -        '(:eval (telega-mode-line-unread-unmuted)) -        telega-use-images (display-graphic-p) -        telega-open-file-function #'jao--see -        telega-open-message-as-file -        (unless (display-graphic-p) '(photo video animation))) -  (with-eval-after-load "tracking" -    (jao-shorten-modes 'telega-chat-mode) -    (jao-tracking-faces 'telega-tracking)) -  (telega-mode-line-mode 1)) - -(defun jao-telega () -  (interactive) -  (jao-tracking-go-to-chats) -  (if (get-buffer telega-root-buffer-name) -      (pop-to-buffer telega-root-buffer-name) -    (telega))) -;;;; ement -(use-package ement -  :disabled t -  :ensure t -  :init (setq ement-save-sessions t -              ement-sessions-file (locate-user-emacs-file "cache/ement.el") -              ement-room-avatars nil -              ement-notify-dbus-p nil -              ement-room-left-margin-width 0 -              ement-room-right-margin-width 11 -              ement-room-timestamp-format "%H:%M" -              ement-room-timestamp-header-format "--------") - -  :custom ((ement-room-message-format-spec "(%S) %B%r%R %t")) - -  :config -  (defun jao-ement-track (event room session) -    (when (ement-notify--room-unread-p event room session) -      (when-let ((n (ement-room--buffer-name room)) -                 (b (get-buffer n))) -        (tracking-add-buffer b)))) - -  (add-hook 'ement-event-hook #'jao-ement-track) -  (jao-shorten-modes 'ement-room-mode) -  (jao-tracking-cleaner "^\\*Ement Room: \\(.+\\)\\*" "@\\1")) - -;;;; mastodon -(use-package mastodon -  :ensure t -  :init -  (setq mastodon-instance-url "https://fosstodon.org" -        mastodon-active-user "jao@gnu.org" -        mastodon-group-notifications t -        mastodon-images-in-notifs t -        mastodon-tl-position-after-update nil -        mastodon-toot-display-orig-in-reply-buffer t -        mastodon-media--hide-sensitive-media nil) -  :config -  ;; (defun jao-mastodon--setup () -  ;;   (setq-local scroll-margin 12)) - -  ;; (add-hook 'mastodon-mode-hook #'jao-mastodon--setup) -  (with-eval-after-load "ewww" -    (define-key eww-mode-map (kbd "T") #'jao-mastodon-toot-url))) - -(defun jao-mastodon-toot-url () -  (interactive) -  (when-let (url (jao-url-around-point t)) -    (jao-tracking-go-to-chats) -    (mastodon-toot--compose-buffer nil nil nil url))) - -(defun jao-mastodon () -  (interactive) -  (jao-afio-goto-chats) -  (mastodon)) - -;; https://0x0.st/XJ14.txt -(jao-transient-major-mode mastodon - ["Timelines" -   ("H" "home"            mastodon-tl--get-home-timeline) -   ("L" "local"           mastodon-tl--get-local-timeline) -   ("F" "federated"       mastodon-tl--get-federated-timeline) -   ("K" "bookmarks"       mastodon-profile--view-bookmarks) -   ("V" "favorites"       mastodon-profile--view-favourites) -   ("'" "followed tags"   mastodon-tl--followed-tags-timeline) -   ("@" "mentions"        mastodon-notifications--get-mentions) -   ("N" "notifications"   mastodon-notifications-get) -   ("\\" "of remote host" mastodon-tl--get-remote-local-timeline)] - -  ;; u                    mastodon-tl--update - -  ["Search" -   ("s" "search"          mastodon-search--query) -   ("#" "tagged"          mastodon-tl--get-tag-timeline) -   ("\"" "followed tags"  mastodon-tl--list-followed-tags) -   ("I" "filter"          mastodon-views--view-filters) -   ("X" "lists"           mastodon-views--view-lists)] - -  ["Toots" -   ("n" "next"            mastodon-tl--goto-next-item :transient t) -   ("p" "prev"            mastodon-tl--goto-prev-item :transient t) -   ("c" "spoiler"         mastodon-tl--toggle-spoiler-text-in-toot :transient t) -   ("T" "thread"          mastodon-tl--thread) -   ("b" "(un)boost"       mastodon-toot--toggle-boost :transient t) -   ("f" "(un)fav"         mastodon-toot--toggle-favourite :transient t) -   ("i" "(un)pin"         mastodon-toot--pin-toot-toggle :transient t) -   ("k" "(un)bookmark"    mastodon-toot--toggle-bookmark :transient t) -   ("v" "vote"            mastodon-tl--poll-vote)] - -  ;; Z                    mastodon-tl--report-to-mods -  ;; o                    mastodon-toot--open-toot-url - -  ["Own Toots" -   ("r" "replay"          mastodon-toot--reply) -   ("t" "write"           mastodon-toot) -   ("e" "edit"            mastodon-toot--edit-toot-at-point) -   ("d" "delete"          mastodon-toot--delete-toot) -   ("D" "del & redraft"   mastodon-toot--delete-and-redraft-toot) -   ("E" "show edits"      mastodon-toot--view-toot-edits)] - -  ;; S                    mastodon-views--view-scheduled-toots - -  ["Users" -   ("W" "follow"          mastodon-tl--follow-user) -   ("R" "follow req"      mastodon-views--view-follow-requests) -   ("G" "suggestions"     mastodon-views--view-follow-suggestions) -   ("M" "mute user"       mastodon-tl--mute-user) -   ("B" "block user"      mastodon-tl--block-user) -   ("m" "message user"    mastodon-tl--dm-user) -   ;; "" -   ;; ("," "favouriters"     mastodon-toot--list-toot-favouriters) -   ;; ("." "boosters"        mastodon-toot--list-toot-boosters) -   ] - -  ;; S-RET                mastodon-tl--unmute-user -  ;; C-S-b                mastodon-tl--unblock-user - -  ["Profiles" -   ("A" "author"          mastodon-profile--get-toot-author) -   ("P" "any user"        mastodon-profile--show-user) -   ("O" "own"             mastodon-profile--my-profile) -   ("U" "update own"      mastodon-profile--update-user-profile-note)] - -  ["Misc" -   ("C" "copy URL"        mastodon-toot--copy-toot-url) -   ("?" "help"            describe-mode) -   ("q" "quit"            transient-quit-one)]) - -;;;; startup -(defun jao-chats (&optional p) -  (interactive "P") -  (when (or p (y-or-n-p "Connect to telegram? ")) -    (telega)) -  (when (and (fboundp 'ement-connect) (or p (y-or-n-p "Connect to matrix? "))) -    (unless (get-buffer "*Ement Rooms*") -      (jao-with-auth "matrix.org" u p (ement-connect :user-id u :password p)))) -  ;; (when (and (fboundp 'mastodon) (or p (y-or-n-p "Connect to mastodon? "))) -  ;;   (mastodon)) -  (dolist (c '(("Libera Chat" . "irc.libera.chat:6697"))) -    (unless (get-buffer (cdr c)) -      (when (or p (y-or-n-p (format "Connect to %s? " (car c)))) -        (circe (car c)))))) - -(defun jao-all-chats () -  (interactive) -  (when jao-tracking-use-scratch -    (jao-afio-goto-chats) -    (delete-other-windows)) -  (jao-chats t)) - -(defun jao-chats-telega () -  (interactive) -  (jao-buffer-same-mode '(telega-root-mode telega-chat-mode))) +(jao-when-linux (require 'jao-custom-chats)) -(defun jao-chats-slack () -  (interactive) -  (jao-buffer-same-mode 'slack-message-buffer-mode)) - -(defun jao-chats-irc () -  (interactive) -  (jao-buffer-same-mode '(circe-channel-mode circe-query-mode erc-mode))) - -;;;; consult narrowing -(defvar jao-chat-buffer-source -  (list :name "chats" -        :category 'buffer -        :action (lambda (b) (jao-afio-pop-to-buffer 0 b)) -        :hidden t -        :narrow (cons ?c "chats") -        :items (jao-consult--mode-buffers 'erc-mode -                                          'circe-channel-mode -                                          'circe-query-mode -                                          'signel-chat-mode -                                          'slack-message-buffer-mode -                                          'slack-thread-message-buffer-mode -                                          'telega-root-mode -                                          'telega-chat-mode -                                          'ement-room-mode -                                          'ement-room-list-mode))) -(with-eval-after-load "consult" -  (jao-consult-add-buffer-source 'jao-chat-buffer-source))  ;;; Multimedia -;;;; video -;; (use-package ready-player :ensure t) -;; (ready-player-mode 1) -;;;; mixer -(defun jao-mixer-get-level (&optional dev nomsg) -  (interactive) -  (let* ((dev (or dev "Master")) -         (s (shell-command-to-string (format "amixer sget %s" dev))) -         (s (car (last (split-string s "\n" t))))) -    (when (string-match ".*Front .*\\[\\([0-9]+\\)%\\] .*" s) -      (let ((level (match-string 1 s))) -        (unless nomsg (message "%s level: %s%%" dev level)) -        (string-to-number level))))) - -(defun jao-mixer-set (dev v) -  (jao-shell-exec* t "amixer" "sset" dev v) -  (jao-mixer-get-level dev)) - -(defun jao-mixer-master-toggle () -  (interactive) -  (jao-mixer-set "Master" "toggle")) - -(defun jao-mixer-master-up () -  (interactive) -  (jao-mixer-set "Master" "10%+")) - -(defun jao-mixer-master-down () -  (interactive) -  (jao-mixer-set "Master" "10%-")) - -(defun jao-mixer-capture-up () -  (interactive) -  (jao-mixer-set "Capture" "10%+")) - -(defun jao-mixer-capture-down () -  (interactive) -  (jao-mixer-set "Capture" "10%-")) - -(jao-shell-def-exec jao-audio-applet "pasystray") - -(defun jao-toggle-audio-applet () -  (interactive) -  (or (jao-shell-kill-p "paystray") (jao-audio-applet))) - -(global-set-key (kbd "<f4>") #'jao-toggle-audio-applet) - -;;;; streaming aliases -(defalias 'jao-streaming-list #'ignore) -(defalias 'jao-streaming-like #'ignore) -(defalias 'jao-streaming-dislike #'ignore) -(defalias 'jao-streaming-toggle-shuffle #'ignore) -(defalias 'jao-streaming-lyrics #'ignore) -(defalias 'jao-streaming-toggle #'ignore) -(defalias 'jao-streaming-next #'ignore) -(defalias 'jao-streaming-prev #'ignore) -(defalias 'jao-streaming-current #'ignore) -(defalias 'jao-streaming-seek #'ignore) -(defalias 'jao-streaming-seek-back #'ignore) -(defalias 'jao-streaming-volume #'ignore) -(defalias 'jao-streaming-volume-down #'ignore) - -;;;; mpris -(defun jao-mpris-lyrics (&optional force) -  (interactive "P") -  (jao-show-lyrics force #'jao-mpris-artist-title)) -(defun jao-mpris-mopidy-p () (string= "mopidy "jao-mpris-player)) - -(defun jao-mpc-mopidy-playlist () -  (interactive) -  (jao-mpc-show-playlist jao-mopidy-port)) - -(use-package jao-mpris :demand t) - -(defun jao-mpris-setup-aliases () -  (setq espotify-play-uri-function #'espotify-play-uri-with-dbus) -  ;; (setq jao-mpris-player "mopidy") -  (defalias 'jao-streaming-list #'jao-mpc-mopidy-playlist) -  (defalias 'jao-streaming-lyrics #'jao-mpris-lyrics) -  (defalias 'jao-streaming-toggle #'jao-mpris-play-pause) -  (defalias 'jao-streaming-next #'jao-mpris-next) -  (defalias 'jao-streaming-prev #'jao-mpris-previous) -  (defalias 'jao-streaming-current #'jao-mpris-show-osd) -  (defalias 'jao-streaming-seek #'jao-mpris-seek) -  (defalias 'jao-streaming-seek-back #'jao-mpris-seek-back) -  (defalias 'jao-streaming-volume #'jao-mpris-vol) -  (defalias 'jao-streaming-volume-down #'jao-mpris-vol-down)) - -(jao-mpris-register "playerctld" :session 70) -;; (jao-mpris-register "mopidy" :session 70) - -;;;; mpc -(use-package jao-mpc -  :demand t -  :commands jao-mpc-setup) - -(defvar jao-mopidy-port 6669) -(defvar jao-mpc-last-port jao-mpc-port) - -(defun jao-mpc-toggle-port () -  (interactive) -  (setq jao-mpc-port -        (if (equal jao-mpc-port jao-mopidy-port) 6600 jao-mopidy-port) -        jao-mpc-last-port jao-mpc-port)) - -(defsubst jao-mpc-mopidy-p () (equal jao-mpc-last-port jao-mopidy-port)) - -(jao-mpc-setup jao-mopidy-port 70) - -(defun jao-mpc-pport (&optional mop) -  (cond ((or mop (jao-mpc-playing-p jao-mopidy-port)) jao-mopidy-port) -        ((jao-mpc-playing-p) 6600) -        (t jao-mpc-last-port))) - -(defmacro jao-defun-play (name &optional mpc-name) -  (let ((arg (gensym))) -    `(defun ,(intern (format "jao-player-%s" name)) (&optional ,arg) -       (interactive "P") -       (,(intern (format "jao-mpc-%s" (or mpc-name name))) -        (setq jao-mpc-last-port (jao-mpc-pport ,arg)))))) - -(jao-defun-play toggle) -(jao-defun-play next) -(jao-defun-play previous) -(jao-defun-play stop) -(jao-defun-play echo echo-current-times) -(jao-defun-play list show-playlist) -(jao-defun-play info lyrics-track-data) -(jao-defun-play browse show-albums) -(jao-defun-play select-album) - -(defun jao-player-seek (delta) (jao-mpc-seek delta (jao-mpc-pport))) - -(defalias 'jao-player-connect 'jao-mpc-connect) -(defalias 'jao-player-play 'jao-mpc-play) - -;;;; spotify -(jao-load-path "espotify") - -(use-package espotify -  :demand t -  :init (setq espotify-service-name "mopidy")) - -(use-package consult-spotify :demand t) - -(defalias 'jao-streaming-album #'consult-spotify-album) -(defalias 'jao-streaming-track #'consult-spotify-track) -(defalias 'jao-streaming-artist #'consult-spotify-artist) -(defalias 'jao-streaming-playlist #'consult-spotify-playlist) - -(jao-def-exec-in-term "ncmpcpp" "ncmpcpp" (jao-afio-goto-scratch)) - -;;;; spt -(use-package jao-spt -  :demand t -  :config -  (defun jao-spt-setup-aliases () -    (setq espotify-play-uri-function #'jao-spt-play-uri) -    (defalias 'jao-streaming-list #'jao-term-spt) -    (defalias 'jao-streaming-lyrics #'jao-spt-show-lyrics) -    (defalias 'jao-streaming-toggle #'jao-spt-toggle) -    (defalias 'jao-streaming-next #'jao-spt-next) -    (defalias 'jao-streaming-prev #'jao-spt-previous) -    (defalias 'jao-streaming-current #'jao-spt-echo-current) -    (defalias 'jao-streaming-seek #'jao-spt-seek) -    (defalias 'jao-streaming-seek-back #'jao-spt-seek-back) -    (defalias 'jao-streaming-volume #'jao-spt-vol) -    (defalias 'jao-streaming-volume-down #'jao-spt-vol-down) -    (defalias 'jao-streaming-like #'jao-spt-like) -    (defalias 'jao-streaming-dislike #'jao-spt-dislike) -    (defalias 'jao-streaming-toggle-shuffle #'jao-spt-toggle-shuffle))) - -(jao-def-exec-in-term "spt" "spt" (jao-afio-goto-scratch)) - -(defvar jao-spt-on t) - -(defun jao-streaming-toggle-player () -  (interactive) -  (if jao-spt-on -      (progn (setq jao-mpris-player "playerctld") -             (require 'jao-mpris) -             (jao-mpris-setup-aliases)) -    (jao-spt-setup-aliases) -    (setq jao-mpris-player "spt")) -  (setq jao-spt-on (not jao-spt-on)) -  (message "%s activated " jao-mpris-player)) - -(jao-streaming-toggle-player) - -;;;; music transients -(require 'jao-lyrics) -(setq jao-lyrics-info-function #'jao-player-info) - -(defun jao-player-seek-10 () (interactive) (jao-player-seek 10)) -(defun jao-player-seek--10 () (interactive) (jao-player-seek -10)) - -(defun jao-streaming-clear () (interactive) (jao-mpc-clear jao-mopidy-port)) - -(defun jao-streaming-echo-current () -  (interactive) -  (jao-mpc-echo-current jao-mopidy-port)) - -(defun jao-streaming-show-playlist () -  (interactive) -  (jao-mpc-show-playlist jao-mopidy-port)) - -(use-package jao-random-album -  :demand t -  :config -  (defun jao--notify-album (album) -    (unless jao-minibuffer-mode -      (jao-notify album "Next album" jao-notify-audio-icon)) -    (jao-minibuffer-refresh)) -  (setq jao-random-album-notify #'jao--notify-album)) - -(defun jao-toggle-pasystray-applet () -  (interactive) -  (or (jao-shell-kill-p "pasystray") (jao-shell-exec "pasystray"))) - -(transient-define-prefix jao-transient-streaming () -  [:description -   (lambda () (format "Streaming using %s" jao-mpris-player)) -   ["Search" :if jao-mpris-mopidy-p -    ("a" "album" jao-streaming-album) -    ("A" "artist" jao-streaming-artist) -    ("t" "track" jao-streaming-track) -    ("P" "playlist" jao-streaming-playlist)] -   ["Play" -    ("s" "toggle" jao-streaming-toggle) -    ("n" "next" jao-streaming-next) -    ("p" "previous" jao-streaming-prev) -    ("T" "toggle player" jao-streaming-toggle-player)] -   ["Seek & shout" -    ("f" "seek fwd" jao-streaming-seek :transient t) -    ("F" "seek bwd" jao-streaming-seek-back :transient t) -    ("u" "up" jao-streaming-volume :transient t) -    ("d" "down" jao-streaming-volume-down :transient t)] -   ["Browse" -    ("l" "playing list" jao-streaming-list :if jao-mpris-mopidy-p) -    ("L" "lyrics" jao-streaming-lyrics) -    ("w" "currently playing" jao-streaming-current)] -   ["Act"  :if jao-mpris-mopidy-p -    ("k" "like" jao-streaming-like) -    ("K" "dislike" jao-streaming-dislike) -    ("S" "toggle shuffle" jao-streaming-toggle-shuffle)]]) - -(transient-define-prefix jao-transient-media () -  [["Play" -    ("m" "toggle" jao-player-toggle) -    ("n" "next" jao-player-next) -    ("p" "previous" jao-player-previous) -    ("s" "select album" jao-player-select-album)] -   ["Seek and search" -    ("f" "seek fwd" jao-player-seek-10 :transient t) -    ("F" "seek bwd" jao-player-seek--10 :transient t) -    ("a" "search album" jao-mpc-select-album) -    ("S" "play stream" jao-mpc-play-stream)] -   ["Browse" -    ("b" "browse" jao-player-browse) -    ("l" "show play list" jao-player-list) -    ("L" "show lyrics" jao-show-lyrics) -    ("w" "now playing" jao-player-echo)] -   [:description -    (lambda () -      (message "%s %s" -               (if (jao-mpc-mopidy-p) "mopidy" "mpd") -               (if (jao-mpc-playing-p) -                   (jao-mpc--current-timestr t) -                 (jao-mpc--current-str))) -      (format "Master %s%%" (jao-mixer-get-level nil t))) -    ("d" "down" jao-mixer-master-down :transient t) -    ("u" "up" jao-mixer-master-up :transient t) -    ("M" "toggle" jao-mixer-master-toggle)] -   [:description -    (lambda () (format "Capture %s%%" (jao-mixer-get-level "Capture" t))) -    ("D" "down" jao-mixer-capture-down :transient t) -    ("U" "up" jao-mixer-capture-up :transient t)] -   ["Utilities" -    ("c" "reconnect to mpd" jao-player-connect) -    ("N" "next random album" jao-random-album-next) -    ("r" (lambda () -           (concat (if jao-random-album-active "dis" "en") "able random album")) -     jao-random-album-toggle) -    ;; ("P" (lambda () (concat "Toggle to " (if (jao-mpc-mopidy-p) "mpd" "mopidy"))) -    ;;  jao-mpc-toggle-port) -    ("P" "pasystray" jao-toggle-pasystray-applet)]]) - -(global-set-key (kbd "s-m") #'jao-transient-media) +(jao-when-linux (require 'jao-custom-multimedia))  ;;; Graphical window system -;;;; x11 utils -(defun jao-xdotool (arg-or-wait &rest args) -  (apply 'jao-shell-exec* -         (if (stringp arg-or-wait) "xdotool" arg-or-wait) -         (if (stringp arg-or-wait) arg-or-wait "xdotool") -         args)) - -(defsubst jao-xdotool-string (&rest args) -  (apply 'jao-shell-string "xdotool" args)) - -(defsubst jao-x11-focused-id () (jao-xdotool-string "getwindowfocus")) - -(defsubst jao-x11-window-name (&optional wid) -  (jao-xdotool-string "getwindowname" (or wid (jao-x11-focused-id)))) - -(defsubst jao-x11-search-window (title) -  (jao-xdotool-string "search" "--name" title)) - -(defsubst jao-x11-goto-ws (n) (jao-xdotool t "set_desktop" (format "%s" n))) - -;;;; exwm -(defvar jao-exwm-enabled nil) -(defun jao-exwm-enabled-p () jao-exwm-enabled) - -(defun jao-exwm-enable () -  (require 'jao-custom-exwm) -  (setq jao-exwm-enabled t) -  (display-time-mode -1) -  (jao-ednc-setup 95) -  (x-change-window-property "_XMONAD_TRAYPAD" "" nil nil nil nil 0) -  (jao-mode-line-add-to-minibuffer-left 90) -  (jao-xmobar-restart) -  (jao-trisect t)) - -;;;; xmonad -(defvar jao-xmonad-enabled (string= "xmonad" (or (getenv "wm") ""))) -(defun jao-xmonad-enabled-p () jao-xmonad-enabled) - -(defun jao-xmonad-enable () -  (setq jao-browse-doc-use-emacs-p (display-graphic-p)) -  (setq jao-mode-line-in-minibuffer nil) -  (display-battery-mode -1) -  (jao-trisect) -  (message "Welcome to xmonad")) - -(when jao-xmonad-enabled -  (add-hook 'after-init-hook #'jao-xmonad-enable)) - -;;;; wayland - -(use-package jao-wayland :demand t) - -(defun jao-wayland-enable () -  (interactive) -  (defalias 'x-change-window-property #'ignore) -  (jao-trisect) -  (message "Welcome to wayland")) - -(defun jao-river-enable () -  (jao-wayland-enable) -  (when (jao-shell-running-p "i3bar-river") -    (jao-tracking-set-log "")) -  (message "Welcome to river")) -(when jao-river-enabled -  (add-hook 'after-init-hook #'jao-river-enable t)) - -(when jao-sway-enabled -  (add-hook 'after-init-hook #'jao-wayland-enable t)) - -;;;; wallpaper -(defvar jao-wallpaper-dir "~/.wallpapers/") - -(defvar jao-wallpaper-random-candidates -  '("wallpaper.jpg" "wallpaper2.jpg")) - -(defvar jao-wallpaper-random-candidates-light -  '("wallpaper.jpg" "wallpaper2.jpg")) - -(defvar jao-wallpaper-random-wake t -  "Set to t for getting a new wallpaper on awaking from sleep") - -(defun jao-set-wallpaper (&optional path) -  (interactive) -  (let ((current (format "~/.wallpaper.%s" (jao-colors-scheme)))) -    (when-let ((f (or (and path (expand-file-name path)) -                      (read-file-name "Image: " -                                      jao-wallpaper-dir -                                      (file-symlink-p current) -                                      t)))) -      (make-symbolic-link f current t) -      (cond (jao-river-enabled (jao-river-set-wallpaper f)) -            (jao-sway-enabled (jao-sway-set-wallpaper f)) -            (t (shell-command-to-string (format "xwallpaper --zoom %s" f))))))) - -(defun jao-set-random-wallpaper () -  (interactive) -  (when (or (called-interactively-p 'interactive) -            jao-wallpaper-random-wake) -    (let* ((ws (if (jao-colors-scheme-dark-p) -                   jao-wallpaper-random-candidates -                 jao-wallpaper-random-candidates-light)) -           (f (seq-random-elt ws))) -      (jao-set-wallpaper (expand-file-name f jao-wallpaper-dir)) -      (message "%s" f)))) - -(add-to-list 'jao-sleep-awake-functions #'jao-set-random-wallpaper) - -;;;; screensaver and lock -(defun jao-screensaver-enabled () -  (string= (jao-shell-string "xdg-screensaver status") "enabled")) - -(defvar jao-screensaver--wid nil) -(defun jao-screensaver-toggle () -  (interactive) -  (if (jao-screensaver-enabled) -      (let ((wid (jao-x11-focused-id))) -        (setq jao-screensaver--wid wid) -        (jao-shell-exec* t "xdg-screensaver" "suspend" wid)) -    (jao-shell-exec* t "xdg-screensaver" "resume" jao-screensaver--wid) -    (setq jao-screensaver--wid nil)) -  (jao-notify (format "Screensaver %s" -                      (jao-shell-string "xdg-screensaver status")))) - -(jao-shell-def-exec jao-xlock-screen "xdg-screensaver" "activate") -(jao-shell-def-exec jao-suspend "sudo" "systemctl" "suspend") -(jao-shell-def-exec jao-poweroff "sudo" "systemctl" "poweroff") - -(defun jao-lock-screen () -  (interactive) -  (if jao-wayland-enabled -      (shell-command "swaylock -i ~/.lockimage") -    (jao-xlock-screen))) - -(transient-define-prefix jao-transient-sleep () -  ["Sleep" -   ("l" "lock screen" jao-lock-screen) -   ("z" "sleep" jao-suspend) -   ("u" (lambda () -          (if (jao-screensaver-enabled) "suspend screensaver" "resume screensaver")) -    jao-screensaver-toggle) -   ("poof" "power-off" jao-poweroff)]) - -;;;; X clipboard -(setq select-enable-clipboard t -      select-enable-primary t -      selection-timeout 100 -      xterm-select-active-regions t) - -(use-package xclip -  :ensure t -  :init (setq xclip-method (if jao-wayland-enabled 'wl-copy 'xclip))) - -(unless (display-graphic-p) (xclip-mode 1)) - -;;;; pop-up frames -(defun jao-open-in-x-frame (&optional width height) -  (interactive) -  (make-frame `((window-system . x) -                (name . "emacs popup") -                (width . ,(or width (window-width))) -                (height . ,(or height (window-height))))) -  (define-key (current-local-map) "q" #'delete-frame)) - -;;;; xmobar -(defun jao-xmobar-kill () -  (interactive) -  (shell-command "killall xmobar-single")) - -(defun jao-xmobar-restart () -  (interactive) -  (jao-xmobar-kill) -  (start-process "" nil "xmobar-single" "-d")) - -(use-package tab-bar -  :init (setq tab-bar-close-button-show nil -              tab-bar-show (> emacs-major-version 28) -              tab-bar-format ())) - -(use-package xmobar -  :init (setq  xmobar-tab-bar t -               xmobar-tab-split "*" -               xmobar-tab-bar-format -               (if window-system -                   '(xmobar-left-string -                     tab-bar-format-align-right -                     xmobar-right-string) -                 '(xmobar-left-string -                   xmobar-elastic-space -                   xmobar-right-string)) -               xmobar-command -               (if window-system '("xmobar-emacs" "-TAnsi") "xmobar-emacs"))) +(jao-when-linux (require 'jao-custom-window-system))  ;;; Global transients  (defun jao-list-packages ()    (interactive) -  (jao-afio-goto-scratch) +  (jao-when-linux (jao-afio-goto-scratch))    (package-list-packages))  (defun jao-window-system-p () -  (or jao-exwm-enabled jao-xmonad-enabled jao-wayland-enabled)) +  (or (not (jao-is-linux)) +      jao-exwm-enabled jao-xmonad-enabled jao-wayland-enabled)) -(defun jao-x11-p () (or jao-exwm-enabled jao-xmonad-enabled)) +(defun jao-x11-p () +  (jao-when-linux (or jao-exwm-enabled jao-xmonad-enabled)))  (defun jao-reveal ()    (interactive) @@ -3368,56 +1680,74 @@  (jao-def-exec-in-term "aptitude" "aptitude" (jao-afio-goto-scratch))  (jao-def-exec-in-term "htop" "htop" (jao-afio-goto-scratch)) -(transient-define-prefix jao-transient-utils () -  "Global operations." -  [["Notes" -    ("n" "create new note" jao-org-notes-create) -    ("/" "open note" jao-org-notes-open) -    ("\\" "open note by tags" jao-org-notes-consult-tags) -    ("g" "ripgrep notes" jao-org-notes-consult-ripgrep)] -   ["Documents" -    ("dd" "go to doc" jao-select-pdf :if display-graphic-p) -    ("do" "open doc" jao-open-doc) -    ("dr" "search docs with recoll" jao-recoll-consult-docs)] -   ["Monitors" -    ("p" "list projects" list-projects) -    ;; ("p" "htop" jao-term-htop) -    ("P" "pasytray" jao-toggle-pasystray-applet) -    ("x" "restart i3bar" jao-river-restart-i3bar :if jao-river-enabled-p) -    ("x" "restart xmobar" jao-xmobar-restart :if jao-exwm-enabled-p) -    ("x" "kill xmobar" jao-xmobar-kill :if jao-xmonad-enabled-p)] -   ["Network" -    ("s" "ssh" jao-ssh) -    ("b" "bluetooth" bluetooth-list-devices) -    ("c" "connect chats" jao-all-chats) -    ("m" "proton bridge" run-proton-bridge)] -   ["Chats" -    ("i"  "irc" jao-chats-irc) -    ("M" "mastodon" jao-mastodon) -    ("T" "telegram rooster" jao-telega)] -   ["Window system" :if jao-window-system-p -    ("w" "set wallpaper" jao-set-wallpaper) -    ("W" "set radom wallpaper" jao-set-random-wallpaper) -    ("B u" (lambda () -             (let ((b (jao-brightness))) -               (format "bright up %s" (and (string-match ".*\\((.+)\\).*" b) -                                           (match-string 1 b))))) -     jao-bright-up :transient t) -    ("B d" "bright down" jao-bright-down :transient t)] -   ["Utilities" -    ("a" "aptitude" jao-term-aptitude) -    ("l" "packages" jao-list-packages) -    ("v" "view video" jao-view-video)] -   ["Timers" -    ("t t" "set new" tmr) -    ("t c" "cancel" tmr-cancel) -    ("t l" "list" tmr-list-timers)] -   ["Helpers" -    ;; ("r" "reveal" jao-reveal) -    ("r" "translate" reverso) -    ("f" "copy buffer file name" copy-buffer-file-name-as-kill) -    ("k" (lambda () (concat "keyboard" (when (jao-kb-toggled-p) "*"))) -     jao-kb-toggle :if jao-x11-p)]]) +(jao-d-l + (transient-define-prefix jao-transient-utils () +   "Global operations." +   [["Notes" +     ("n" "create new note" jao-org-notes-create) +     ("/" "open note" jao-org-notes-open) +     ("\\" "open note by tags" jao-org-notes-consult-tags) +     ("g" "ripgrep notes" jao-org-notes-consult-ripgrep)] +    ["Timers" +     ("t t" "set new" tmr) +     ("t c" "cancel" tmr-cancel) +     ("t l" "list" tmr-list-timers)] +    ["Network" +     ("s" "ssh" jao-ssh)] +    ["Utilities" +     ("l" "packages" jao-list-packages) +     ("r" "translate" reverso) +     ("f" "copy buffer file name" copy-buffer-file-name-as-kill)]]) + (transient-define-prefix jao-transient-utils () +   "Global operations." +   [["Notes" +     ("n" "create new note" jao-org-notes-create) +     ("/" "open note" jao-org-notes-open) +     ("\\" "open note by tags" jao-org-notes-consult-tags) +     ("g" "ripgrep notes" jao-org-notes-consult-ripgrep)] +    ["Documents" +     ("dd" "go to doc" jao-select-pdf :if display-graphic-p) +     ("do" "open doc" jao-open-doc) +     ("dr" "search docs with recoll" jao-recoll-consult-docs)] +    ["Monitors" +     ("p" "list projects" list-projects) +     ;; ("p" "htop" jao-term-htop) +     ("P" "pasytray" jao-toggle-pasystray-applet) +     ("x" "restart i3bar" jao-river-restart-i3bar :if jao-river-enabled-p) +     ("x" "restart xmobar" jao-xmobar-restart :if jao-exwm-enabled-p) +     ("x" "kill xmobar" jao-xmobar-kill :if jao-xmonad-enabled-p)] +    ["Network" +     ("s" "ssh" jao-ssh) +     ("b" "bluetooth" bluetooth-list-devices) +     ("c" "connect chats" jao-all-chats) +     ("m" "proton bridge" run-proton-bridge)] +    ["Chats" +     ("i"  "irc" jao-chats-irc) +     ("M" "mastodon" jao-mastodon) +     ("T" "telegram rooster" jao-telega)] +    ["Window system" :if jao-window-system-p +     ("w" "set wallpaper" jao-set-wallpaper) +     ("W" "set radom wallpaper" jao-set-random-wallpaper) +     ("B u" (lambda () +              (let ((b (jao-brightness))) +                (format "bright up %s" (and (string-match ".*\\((.+)\\).*" b) +                                            (match-string 1 b))))) +      jao-bright-up :transient t) +     ("B d" "bright down" jao-bright-down :transient t)] +    ["Utilities" +     ("a" "aptitude" jao-term-aptitude) +     ("l" "packages" jao-list-packages) +     ("v" "view video" jao-view-video)] +    ["Timers" +     ("t t" "set new" tmr) +     ("t c" "cancel" tmr-cancel) +     ("t l" "list" tmr-list-timers)] +    ["Helpers" +     ;; ("r" "reveal" jao-reveal) +     ("r" "translate" reverso) +     ("f" "copy buffer file name" copy-buffer-file-name-as-kill) +     ("k" (lambda () (concat "keyboard" (when (jao-kb-toggled-p) "*"))) +      jao-kb-toggle :if jao-x11-p)]]))  (global-set-key (kbd "s-w") #'jao-transient-utils) diff --git a/lib/doc/jao-org-notes.el b/lib/doc/jao-org-notes.el index d3f18b8..bd45723 100644 --- a/lib/doc/jao-org-notes.el +++ b/lib/doc/jao-org-notes.el @@ -57,7 +57,11 @@          (string-to-number (cadr m))))  (defun jao-org-notes--matches (lines) -  (mapcar (lambda (l) (jao-org-notes--clean-match (split-string l "\0" t))) lines)) +  (seq-keep (lambda (l) +              (let ((m (split-string (or l "") "\0" t))) +                (when (and (car m) (cadr m)) +                  (jao-org-notes--clean-match m)))) +            lines))  (defun jao-org-notes--grep-rx (rx &rest rg-args)    (let ((default-directory jao-org-notes-dir)) @@ -212,7 +216,8 @@  (defun jao-org-notes-setup (mnemonic)    "Set up the notes system, providing a mnemonic character for its org template."    (setq org-capture-templates -        (add-to-list 'org-capture-templates (jao-org-notes--template mnemonic)) +        (add-to-list 'org-capture-templates +                     (jao-org-notes--template mnemonic))          jao-org-notes--tags (jao-org-notes-all-tags))    (when (fboundp 'org-capture-upgrade-templates)      (org-capture-upgrade-templates org-capture-templates))) | 
