]> git.eshelyaron.com Git - dotfiles.git/commitdiff
Emacs configuration updates
authorEshel Yaron <me@eshelyaron.com>
Fri, 5 Aug 2022 07:36:41 +0000 (10:36 +0300)
committerEshel Yaron <me@eshelyaron.com>
Fri, 5 Aug 2022 07:38:51 +0000 (10:38 +0300)
.emacs.d/esy.org
.zshenv

index d8d9ad993042a81e187de5794589f479967a7e61..c3bde603f28d619c732a7475551d27df24c65baa 100644 (file)
@@ -154,8 +154,8 @@ For further information about Elisp headers, see [[info:elisp#Library
           exec-path-from-shell flymake-swi-prolog ggtags git-blamed
           git-timemachine gitconfig-mode gitignore-mode
           gnu-elpa-keyring-update gnuplot gnuplot-mode go-mode
-          graphviz-dot-mode highlight-escape-sequences htmlize
-          ialign keyfreq keycast iedit lin list-unicode-display
+          graphviz-dot-mode haskell-mode highlight-escape-sequences
+          htmlize ialign keyfreq keycast iedit lin list-unicode-display
           logos lorem-ipsum magit marginalia markdown-mode move-dup
           no-littering ns-auto-titlebar ob-prolog olivetti orderless
           org-modern paredit pdf-tools rainbow-delimiters rg slack
@@ -353,6 +353,11 @@ For a list of available frame parameters, see [[info:elisp#Frame Parameters][eli
       (byte-compile-file esy/target-path)))
 
   (add-hook 'kill-emacs-hook #'esy/tangle-and-compile-config)
+
+  (defun esy/find-esy-org ()
+    "Open my Emacs configuration."
+    (interactive)
+    (find-file esy/source-path))
 #+end_src
 
 ** Org-mode basic settings
@@ -459,7 +464,7 @@ refiling directly into deeper headings as well.
 #+begin_src emacs-lisp
 
   (defvar esy/org-capture-to-project-heading-history-list nil
-    "History list for 'esy/org-capture-to-project-heading'.")
+    "History list for `esy/org-capture-to-project-heading'.")
 
   (with-eval-after-load 'savehist
    (add-to-list 'savehist-additional-variables
@@ -838,8 +843,10 @@ refiling directly into deeper headings as well.
     (keymap-set ctl-x-map "l" #'org-store-link)
     (keymap-set ctl-x-map "c" #'org-capture)
     (keymap-set ctl-x-map "o" #'ace-window)
+    (keymap-set ctl-x-map "F" #'esy/find-esy-org)
     (keymap-set ctl-x-map "O" #'other-window)
     (keymap-set ctl-x-map "w" #'esy/eww)
+    (keymap-set ctl-x-map "S" #'esy/vterm-at)
     (keymap-set ctl-x-map "V" #'vertalen-at-point)
     (keymap-set ctl-x-map "G" #'gnus)
     (keymap-set ctl-x-map "E" #'elfeed)
@@ -857,6 +864,8 @@ refiling directly into deeper headings as well.
 #+begin_src emacs-lisp
   (defun esy/customize-search-map ()
     "Configure the `search-map' keymap."
+    (keymap-set search-map "r" #'rg)
+    (keymap-set search-map "l" #'rg-literal)
     (keymap-set search-map "b" #'some-button))
 
   (add-hook 'after-init-hook #'esy/customize-search-map)
@@ -879,6 +888,27 @@ refiling directly into deeper headings as well.
 :CUSTOM_ID: applications
 :END:
 
+** tramp
+:PROPERTIES:
+:CUSTOM_ID: tramp-optimization
+:END:
+#+begin_src emacs-lisp
+  (with-eval-after-load 'tramp
+    (tramp-set-completion-function "ssh" '((tramp-parse-netrc "~/.authinfo"))))
+
+  (define-advice project--find-in-directory (:override (dir) no-remote-projects)
+    (unless (file-remote-p dir)
+      (run-hook-with-args-until-success 'project-find-functions dir)))
+
+  (define-advice completion-file-name-table (:filter-args (args) no-remote-file-name-completion)
+    (let ((string (car args))
+          (pred (cadr args))
+          (action (caddr args)))
+      (if (and (file-remote-p string) (eq pred #'file-exists-p))
+          (list string nil action)
+        (list string pred action))))
+#+end_src
+
 ** Dired
 :PROPERTIES:
 :CUSTOM_ID: dired
@@ -890,6 +920,35 @@ refiling directly into deeper headings as well.
   (add-hook 'dired-mode-hook #'all-the-icons-dired-mode)
 #+end_src
 
+** vterm                                                               :cmd:
+:PROPERTIES:
+:CUSTOM_ID: remote-vtrem
+:END:
+Start =vterm= in a given directory and with a given shell, possibly
+over ssh for remote connections.
+
+#+begin_src emacs-lisp
+  (setq vterm-shell "/bin/bash")
+
+  (defun esy/vterm-with (arg shell)
+    (interactive
+     (list current-prefix-arg
+           (completing-read
+            "Start vterm with shell: "
+            '("bash" "zsh" "sh")
+            nil t nil nil "bash")))
+    (require 'vterm)
+    (let ((vterm-shell (concat "/bin/" shell)))
+      (vterm arg)))
+
+  (defun esy/vterm-at (arg dir)
+    (interactive
+     (list current-prefix-arg (read-directory-name "Start vterm in directory: " )))
+    (require 'vterm)
+    (let ((default-directory dir))
+      (vterm arg)))
+#+end_src
+
 ** Elfeed
 :PROPERTIES:
 :CUSTOM_ID: elfeed
@@ -900,6 +959,7 @@ refiling directly into deeper headings as well.
     (setq elfeed-feeds
           '("https://lwn.net/headlines/rss"
             "https://reddit.com/r/prolog/.rss"
+            "https://matt-rickard.com/rss"
             "https://www.haskellforall.com/feeds/posts/default"
             "https://cestlaz.github.io/rss.xml"
             "https://drewdevault.com/blog/index.xml"
@@ -1165,8 +1225,7 @@ does in the shell.
     (let ((bs (bounds-of-thing-at-point 'filename)))
       (when bs
         (let* ((start (car bs))
-               (end   (cdr bs))
-               (file  (buffer-substring-no-properties start end)))
+               (end   (cdr bs)))
           `(,start ,end completion--file-name-table . (:exclusive no))))))
 
   (defun esy/margin-formatter (metadata)
@@ -1427,6 +1486,17 @@ include =emacs-lisp-mode= and =lisp-interaction-mode=.
   (add-hook 'lisp-data-mode-hook #'esy/setup-lisp)
 #+end_src
 
+** Haskell specific settings
+:PROPERTIES:
+:CUSTOM_ID: haskell
+:END:
+
+#+begin_src emacs-lisp
+  (add-hook 'haskell-mode-hook #'interactive-haskell-mode)
+  (add-hook 'haskell-mode-hook #'haskell-decl-scan-mode)
+  (add-hook 'haskell-mode-hook #'haskell-doc-mode)
+#+end_src
+
 ** Prolog specific settings
 :PROPERTIES:
 :CUSTOM_ID: prolog
@@ -1444,6 +1514,40 @@ include =emacs-lisp-mode= and =lisp-interaction-mode=.
   (add-hook 'prolog-mode-hook #'esy/setup-prolog)
 #+end_src
 
+*** Make =rg= regard =.pl= files as Prolog rather than Perl
+:PROPERTIES:
+:CUSTOM_ID: rg-pl-is-prolog-not-perl
+:END:
+
+#+begin_src emacs-lisp
+  (with-eval-after-load 'rg
+    (add-to-list 'rg-custom-type-aliases '("Prolog" . "*.pl *.plt *.pro *.prolog")))
+#+end_src
+
+
+*** Per project Prolog top-level history                             :hook:
+:PROPERTIES:
+:CUSTOM_ID: per-project-prolog-history
+:CreatedAt: <2022-08-04 Thu>
+:CapturedAt:
+:CapturedAs: Emacs configuration fragment
+:END:
+
+#+begin_src emacs-lisp
+  (defconst esy/prolog-input-ring-file-name ".swipl_history")
+
+  (defun esy/setup-project-prolog-history ()
+    "Setup per-project Prolog top-level history."
+    (if-let ((project (project-current)))
+        (progn
+          (add-hook 'kill-buffer-hook #'comint-write-input-ring nil t)
+          (setq comint-input-ring-file-name (expand-file-name esy/prolog-input-ring-file-name (project-root project))
+                 comint-input-ignoredups      t)
+          (comint-read-input-ring t))))
+
+  (add-hook 'prolog-inferior-mode-hook #'esy/setup-project-prolog-history)
+#+end_src
+
 * LaTeX and PDF settings
 :PROPERTIES:
 :CUSTOM_ID: latex-and-pdf
@@ -1508,7 +1612,9 @@ without asking each time.
   (with-eval-after-load 'project
     (add-to-list 'project-switch-commands '(project-compile "Compile"))
     (when (boundp 'project-prefix-map)
+      (define-key project-prefix-map "R" #'rg-project)
       (define-key project-prefix-map "m" #'magit-project-status)
+      (add-to-list 'project-switch-commands '(rg-project "rg") t)
       (add-to-list 'project-switch-commands '(magit-project-status "Magit") t)))
 #+end_src
 
@@ -1620,7 +1726,7 @@ without asking each time.
     (logos--mode 'flymake-mode -1))
 
   (with-eval-after-load 'olivetti
-    (setq olivetti-body-width 90))
+    (setq-default olivetti-body-width 100))
 
   (with-eval-after-load 'logos
     (setq-default logos-olivetti               t
diff --git a/.zshenv b/.zshenv
index 0983380ad0050f09b43ec7bad906c5e4fb371de3..5c6d4251db74d0793c7b5824d3da6853f4888c83 100644 (file)
--- a/.zshenv
+++ b/.zshenv
@@ -1 +1 @@
-export PATH=/Applications/Emacs.app/Contents/MacOS:/Applications/Emacs.app/Contents/MacOS/bin/:$PATH
+export PATH=/Applications/Emacs.app/Contents/MacOS:/Applications/Emacs.app/Contents/MacOS/bin:/Users/eshelyaron/go/bin:$PATH