]> git.eshelyaron.com Git - dotfiles.git/commitdiff
Update Emacs configuration
authorEshel Yaron <me@eshelyaron.com>
Thu, 23 Nov 2023 14:54:56 +0000 (15:54 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 23 Nov 2023 14:54:56 +0000 (15:54 +0100)
.emacs.d/init.el
.emacs.d/lisp/esy-comm.el

index 3fee3e0591e701733cdc3dee144cd2d7c81ad0e0..039b8943d653ca7e05514ce9ed83d0674293eca4 100644 (file)
@@ -417,7 +417,7 @@ DEADLINE: %(format-time-string \"<%Y-%m-%d %H:%M>\" (org-read-date t t))
  ;; completion-auto-help 'visible
  completions-max-height 16
  completion-auto-wrap t
- completion-at-point-functions '(esy/file-capf)
+ completion-at-point-functions nil
  corfu-cycle t
  corfu-indexed-start     1
  shell-kill-buffer-on-exit t
@@ -547,6 +547,7 @@ DEADLINE: %(format-time-string \"<%Y-%m-%d %H:%M>\" (org-read-date t t))
 
 (defun esy/ttyper ()
   (interactive)
+  (require 'eat)
   (let ((default-directory "~")
         (eat-kill-buffer-on-exit t))
     (eat "ttyper -c ~/.config/ttyper/config.toml" t)))
@@ -872,16 +873,20 @@ Interactively, POINT is point and KILL is the prefix argument."
                                  (when (require 'rainbow-delimiters nil t)
                                    (rainbow-delimiters-mode))))
 
-;;; Extend other standard hooks
+;;; Extend standard text mode hooks
 
 (add-hook 'text-mode-hook #'flyspell-mode)
 (add-hook 'text-mode-hook #'completion-preview-mode)
-(add-hook 'text-mode-hook
-          (lambda ()
-            (add-hook 'completion-at-point-functions #'cape-dict 10 t)))
+;; (add-hook 'text-mode-hook
+;;           (lambda ()
+;;             (add-hook 'completion-at-point-functions
+;;                       #'ispell-completion-at-point nil t)))
+;; (keymap-unset text-mode-map "C-M-i" t)
+
 
 ;;; Bind some keys
 
+(keymap-global-set "C-M-i" #'completion-at-point)
 (keymap-global-set "C-c c" #'org-capture)
 (keymap-global-set "C-c l" #'org-store-link)
 (keymap-global-set "C-c a" #'org-agenda)
@@ -1147,15 +1152,33 @@ as the initial input for completion, and return that directory."
   (with-eval-after-load 'embark
     (require 'embark-consult)))
 
-;;; Set up some global `completion-at-point-functions'
+;;; Define some custom `completion-at-point-functions'
 
-(defun esy/file-capf ()
+(defun file-capf ()
   "File completion at point function."
-  (let ((bs (bounds-of-thing-at-point 'filename)))
-    (when bs
-      (let* ((start (car bs))
-             (end   (cdr bs)))
-        `(,start ,end completion-file-name-table :exclusive no)))))
+  (pcase (bounds-of-thing-at-point 'filename)
+    (`(,beg . ,end)
+     (list beg end #'completion-file-name-table
+           :annotation-function (lambda (_) " File")
+           :exclusive 'no))))
+
+(add-hook 'completion-at-point-functions #'file-capf)
+
+;; (defun ispell-completion-at-point ()
+;;   "Word completion function for use in `completion-at-point-functions'."
+;;   (pcase (bounds-of-thing-at-point 'word)
+;;     (`(,beg . ,end)
+;;      (when (and (< beg (point)) (<= (point) end))
+;;        (let ((word (buffer-substring-no-properties beg end)))
+;;          (require 'ispell)
+;;          (list beg end
+;;                (completion-table-subvert
+;;                 (seq-remove
+;;                  (apply-partially #'string-equal-ignore-case word)
+;;                  (let ((inhibit-message t)) (ispell-lookup-words word)))
+;;                 word (downcase word))
+;;                :annotation-function (lambda (_) " Dictionary word")
+;;                :exclusive 'no))))))
 
 ;;; Configure highlighting of the current line via `lin'
 
@@ -1376,11 +1399,22 @@ as the initial input for completion, and return that directory."
   (add-hook 'plain-TeX-mode-hook
             (lambda () (set (make-local-variable 'TeX-electric-math)
                             (cons "$" "$"))))
+  (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))
+
+(with-eval-after-load 'latex
   (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))
+
+  (add-hook 'LaTeX-mode-hook #'LaTeX-math-mode)
+
+  (defun LaTeX-mark-math ()
+    (interactive)
+    (when-let ((beg (search-backward "\\(" nil t))
+               (end (search-forward "\\)" nil t)))
+      (set-mark beg)))
+
+  (keymap-set LaTeX-mode-map "C-c C-SPC" #'LaTeX-mark-math))
 
 (with-eval-after-load 'elisp-mode
   (setq elisp-flymake-byte-compile-load-path (cons "./" load-path)))
index 79947c3ecaa3ccbe8e361db61c5f02c089874c07..5707e4f12f2d4afb04bda6e3f81d259ff7d2d9df 100644 (file)
@@ -95,6 +95,7 @@
 
  ;; BBDB
  bbdb-phone-style nil
+ bbdb-complete-mail nil
  bbdb-complete-mail-allow-cycling t
  bbdb-completion-display-record nil