]> git.eshelyaron.com Git - dotfiles.git/commitdiff
Update Emacs configuration
authorEshel Yaron <me@eshelyaron.com>
Sat, 30 Sep 2023 20:39:56 +0000 (22:39 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 30 Sep 2023 20:39:56 +0000 (22:39 +0200)
.emacs.d/init.el

index 9438d0964062960ec7554da7195932d2994b8eac..3012935d449c11b898b1fb6ed33ac09a7b961693 100644 (file)
          :repo "https://git.sr.ht/~pkal/do-at-point"
          :pre-build (("pandoc" "-o" "do-at-point.texi" "README.md"))))
 (elpaca rfc-mode)
-(elpaca pdf-tools)
+(elpaca (auctex
+         :files ("*.el" "*.info*")
+         :pre-build (("./autogen.sh")
+                     ("./configure" "--with-lispdir=." "--with-texmf-dir=/tmp")
+                     ("make")
+                     ("cp" "doc/auctex.info" "doc/auctex.info-1" "doc/auctex.info-2" "doc/preview-latex.info" "."))))
+(elpaca (pdf-tools
+         :pre-build (("emacs" "--batch" "-l" "ox-texinfo" "README.org"
+                      "--eval" "(setq org-babel-confirm-evaluate-answer-no t)"
+                      "--eval" "(setq org-export-with-broken-links t)"
+                      "-f" "org-texinfo-export-to-texinfo")
+                     ("mv" "README.texi"  "pdf-tools.texi"))))
 
 (elpaca-wait)
 
                                         "Global Bindings:"
                                         "Function key map translations"
                                         "pixel-scroll-precision-mode"
-                                        "context-menu-mode")))))
+                                        "context-menu-mode"))))
+ TeX-view-program-selection '((output-pdf "PDF Tools"))
+ TeX-source-correlate-start-server t
+ TeX-data-directory "~/.emacs.d/elpaca/builds/auctex/"
+ TeX-lisp-directory TeX-data-directory
+ TeX-auto-save t
+ TeX-parse-self t
+ TeX-source-correlate-mode t
+ TeX-electric-sub-and-superscript t
+ ;; TeX-electric-escape t
+ LaTeX-electric-left-right-brace t
+ TeX-mode-alist '((tex-mode . tex-mode)
+                  (plain-tex-mode . tex-mode)
+                  (latex-mode . tex-mode)
+                  (doctex-mode . tex-mode)))
 
 (setq-default indent-tabs-mode nil)
 
 (set-face-attribute 'default nil             :family "Iosevka")
 (set-face-attribute 'fixed-pitch nil         :family "Iosevka")
 (set-face-attribute 'variable-pitch nil      :family "Iosevka Etoile")
-(set-face-attribute 'mode-line nil
-                    :box nil
-                    :background "pink")
-(set-face-attribute 'mode-line-inactive nil  :box nil)
+(set-face-attribute 'mode-line nil :box nil :background nil :overline nil)
+(set-face-attribute 'mode-line-active nil
+                    :overline "black"
+                    :background "lavender"
+                    :underline nil)
+(set-face-attribute 'mode-line-inactive nil
+                    :box nil :background nil :underline "black")
 (set-face-attribute 'fringe nil              :background nil)
 (set-face-attribute 'line-number-current-line nil
                     :background "yellow"
@@ -955,6 +983,7 @@ Interactively, POINT is point and KILL is the prefix argument."
   (add-to-list 'project-switch-commands '(project-shell "Shell"))
   (when (boundp 'project-prefix-map)
     (define-key project-prefix-map "R" #'rg-project)
+    (define-key project-prefix-map "w" #'project-copy-relative-file-name-as-kill)
     (define-key project-prefix-map "m" #'magit-project-status))
 
   (defvar esy/project-name-history nil)
@@ -987,7 +1016,26 @@ as the initial input for completion, and return that directory."
                                            nil t name))
                  (project (project-current nil dir)))
             (when project (project-remember-project project))
-            dir)))))
+            dir))))
+
+  (defun project-copy-relative-file-name-as-kill ()
+    (interactive)
+    (if-let ((project (project-current))
+             (root (expand-file-name (project-root project)))
+             (directory-abbrev-alist (cons (cons root "")
+                                           directory-abbrev-alist))
+             (fn (abbreviate-file-name (or (buffer-file-name)
+                                           (expand-file-name default-directory)))))
+        (if (string-empty-p fn)
+            (user-error "At project root!")
+          (progn
+            (kill-new fn)
+            (message (concat (propertize "Copied file name " 'face 'shadow)
+                             (propertize fn 'face 'bold)
+                             (propertize " relative to " 'face 'shadow)
+                             (propertize (project-name project) 'face 'italic)
+                             (propertize " project root directory" 'face 'shadow)))))
+      (user-error "Not a project buffer!"))))
 
 ;;; Configure SQL connections
 
@@ -1205,6 +1253,8 @@ as the initial input for completion, and return that directory."
 
 ;;; Configure PDF handling
 
+(pdf-loader-install)
+
 (add-to-list 'revert-without-query "\\.pdf\\'")
 
 ;;; Configure terminal emulation via `vterm'
@@ -1252,7 +1302,8 @@ as the initial input for completion, and return that directory."
                 ("\\.rb\\'"    . ruby-ts-mode)
                 ("\\.rs\\'"    . rust-ts-mode)
                 ("\\.go\\'"    . go-ts-mode)
-                ("\\.plt?\\'"  . prolog-mode)))
+                ("\\.plt?\\'"  . prolog-mode)
+                ("\\.tex\\'"   . TeX-latex-mode)))
   (push cell auto-mode-alist))
 
 ;;; Configure Help
@@ -1352,9 +1403,10 @@ as the initial input for completion, and return that directory."
 
 (with-eval-after-load 'tex-mode
   (add-hook 'latex-mode-hook #'electric-pair-local-mode)
-  (setq display-tex-shell-buffer-action nil
-        ;; '(display-buffer-no-window
-        ;;   (allow-no-window . t))
+  (setq display-tex-shell-buffer-action
+        '(display-buffer-no-window
+          (allow-no-window . t))
+        tex-start-options "--synctex=1"
         ;; latex-run-command "pdflatex"
         )
   (define-advice tex-terminate-paragraph (:around (fun &rest args) fill-and-indent)
@@ -1362,6 +1414,16 @@ as the initial input for completion, and return that directory."
     (apply fun args)
     (indent-according-to-mode)))
 
+(with-eval-after-load 'tex
+  (add-hook 'plain-TeX-mode-hook
+            (lambda () (set (make-local-variable 'TeX-electric-math)
+                            (cons "$" "$"))))
+  (add-hook 'LaTeX-mode-hook
+            (lambda () (set (make-local-variable 'TeX-electric-math)
+                            (cons "\\(" "\\)"))))
+  (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)
+  (add-hook 'LaTeX-mode-hook #'LaTeX-math-mode))
+
 ;;; Track currency exchange rates
 
 (defvar esy/eur-to-ils-rates nil)
@@ -1446,8 +1508,12 @@ as the initial input for completion, and return that directory."
 
 (defvar esy/mode-line-format
   '(" %+ "
+    (:eval (when-let (project (project-current))
+             (list
+              (propertize (concat (project-name project) "/ ")
+                          'face 'italic))))
     mode-line-buffer-identification
-    " (%["
+    "(%["
     mode-name mode-line-process minor-mode-alist
     (:eval (when (window-dedicated-p)
              " Dedicated"))