Fix some byte-compiler warnings and remove some version workarounds
[~bandali/configs] / init.el
diff --git a/init.el b/init.el
index f8f755a..2df0724 100644 (file)
--- a/init.el
+++ b/init.el
@@ -19,8 +19,7 @@
 
 ;; GNU Emacs configuration of Amin Bandali, computer scientist,
 ;; Free Software activist, and GNU maintainer & webmaster.  Packages
-;; are installed through GNU Guix for a fully reproducible setup.
-;; Before switching to Guix, I used straight.el, and before that Borg.
+;; are installed through using Borg for a fully reproducible setup.
 
 ;; Over the years, I've taken inspiration from configurations of many
 ;; great people.  Some that I can remember off the top of my head are:
 \f
 ;;; Package management
 
-;; No package.el  (for emacs 26 and before)
-(when (version< emacs-version "27")
-  (setq package-enable-at-startup nil)
-  ;; (package-initialize)
-  )
-;; for emacs 27 and later, we use early-init.el.  see
-;; https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b
-
 (progn ;   `borg'
   (add-to-list 'load-path
                (expand-file-name "lib/borg" user-emacs-directory))
 ;; start up emacs server.  see
 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
 (use-package server
-  :defer 0.4
+  :defer 0.5
   :config (or (server-running-p) (server-mode)))
 
 \f
 ;;; Useful utilities
 
-;; useful libraries
-(require 'cl-lib)
-(require 'subr-x)
-
 (defmacro b/setq-every (value &rest vars)
   "Set all the variables from VARS to value VALUE."
   (declare (indent defun) (debug t))
 (defun b/add-elisp-section ()
   (interactive)
   (insert "\n")
-  (previous-line)
+  (forward-line -1)
   (insert "\n\f\n;;; "))
 
 ;; (defvar b/fill-column 47
@@ -279,7 +266,7 @@ For disabling the behaviour for certain buffers and/or modes."
  indent-tabs-mode nil
  tab-width 4
  ;; cursor shape
- cursor-type 'bar)
+ cursor-type t)
 
 ;; unicode support
 (comment
@@ -377,7 +364,7 @@ For disabling the behaviour for certain buffers and/or modes."
   (display-time-mode)
   :custom
   (display-time-default-load-average nil)
-  (display-time-format "%a %b %-e %-l:%M%P")
+  (display-time-format " %a %b %-e %-l:%M%P")
   (display-time-mail-icon '(image :type xpm :file "gnus/gnus-pointer.xpm" :ascent center))
   (display-time-use-mail-icon t))
 
@@ -386,7 +373,7 @@ For disabling the behaviour for certain buffers and/or modes."
   :config
   (display-battery-mode)
   :custom
-  (battery-mode-line-format " %p%% %t"))
+  (battery-mode-line-format "%p%% %t"))
 
 (use-package fringe
   :demand
@@ -473,9 +460,7 @@ For disabling the behaviour for certain buffers and/or modes."
   :config
   ;; ask for GPG passphrase in minibuffer
   ;; this will fail if gpg>=2.1 is not available
-  (if (version< "27" emacs-version)
-      (setq epg-pinentry-mode 'loopback)
-    (setq epa-pinentry-mode 'loopback))
+  (setq epg-pinentry-mode 'loopback)
   :custom
   (epg-gpg-program (executable-find "gpg")))
 
@@ -510,6 +495,10 @@ For disabling the behaviour for certain buffers and/or modes."
  ("C-c e u" . emacs-uptime)
  ("C-c e v" . emacs-version)
 
+ ("C-c f ." . find-file)
+ ("C-c f d" . find-name-dired)
+ ("C-c f l" . find-library)
+
  ("C-c F m" . make-frame-command)
  ("C-c F d" . delete-frame)
  ("C-c F D" . server-edit)
@@ -517,6 +506,8 @@ For disabling the behaviour for certain buffers and/or modes."
  ("C-S-h C" . describe-char)
  ("C-S-h F" . describe-face)
 
+ ("C-c x"   . execute-extended-command)
+
  ("C-x k"   . b/kill-current-buffer)
  ("C-x K"   . kill-buffer)
  ("C-x s"   . save-buffer)
@@ -543,108 +534,18 @@ For disabling the behaviour for certain buffers and/or modes."
 \f
 ;;; Essential packages
 
+(add-to-list
+ 'load-path
+ (expand-file-name
+  (convert-standard-filename "lisp") user-emacs-directory))
+
 (when b/exwm-p
   (require 'bandali-exwm))
 
-(use-package org
-  :config
-  (setq org-src-tab-acts-natively t
-        org-src-preserve-indentation nil
-        org-edit-src-content-indentation 0
-        org-link-email-description-format "Email %c: %s" ; %.30s
-        org-highlight-latex-and-related '(entities)
-        org-use-speed-commands t
-        org-startup-folded 'content
-        org-catch-invisible-edits 'show-and-error
-        org-log-done 'time)
-  (when (version< org-version "9.3")
-    (setq org-email-link-description-format
-          org-link-email-description-format))
-  (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t)
-  (add-to-list 'org-modules 'org-habit)
-  :bind
-  (("C-c a o a" . org-agenda)
-   :map org-mode-map
-   ("M-L" . org-insert-last-stored-link)
-   ("M-O" . org-toggle-link-display))
-  :hook ((org-mode . org-indent-mode)
-         (org-mode . auto-fill-mode)
-         (org-mode . flyspell-mode))
-  :custom
-  (org-pretty-entities t)
-  (org-agenda-files '("~/usr/org/todos/personal.org"
-                      "~/usr/org/todos/habits.org"
-                      "~/src/git/masters-thesis/todo.org"))
-  (org-agenda-start-on-weekday 0)
-  (org-agenda-time-leading-zero t)
-  (org-habit-graph-column 44)
-  (org-latex-packages-alist '(("" "listings") ("" "color")))
-  :custom-face
-  '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21"))))
-  '(org-block ((t (:background "#1d1f21"))))
-  '(org-latex-and-related ((t (:foreground "#b294bb")))))
-
-(use-package ox-latex
-  :after ox
-  :config
-  (setq org-latex-listings 'listings
-        ;; org-latex-prefer-user-labels t
-        )
-  (add-to-list 'org-latex-classes
-               '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
-                 ("\\section{%s}"       . "\\section*{%s}")
-                 ("\\subsection{%s}"    . "\\subsection*{%s}")
-                 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
-                 ("\\paragraph{%s}"     . "\\paragraph*{%s}")
-                 ("\\subparagraph{%s}"  . "\\subparagraph*{%s}"))
-               t)
-  (require 'ox-beamer))
-
-(use-package ox-extra
-  :config
-  (ox-extras-activate '(latex-header-blocks ignore-headlines)))
-
-;; asynchronous tangle, using emacs-async to asynchronously tangle an
-;; org file.  closely inspired by
-;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
-(with-eval-after-load 'org
-  (defvar b/show-async-tangle-results nil
-    "Keep *emacs* async buffers around for later inspection.")
-
-  (defvar b/show-async-tangle-time nil
-    "Show the time spent tangling the file.")
-
-  (defun b/async-babel-tangle ()
-    "Tangle org file asynchronously."
-    (interactive)
-    (let* ((file-tangle-start-time (current-time))
-           (file (buffer-file-name))
-           (file-nodir (file-name-nondirectory file))
-           ;; (async-quiet-switch "-q")
-           (file-noext (file-name-sans-extension file)))
-      (async-start
-       `(lambda ()
-          (require 'org)
-          (org-babel-tangle-file ,file))
-       (unless b/show-async-tangle-results
-         `(lambda (result)
-            (if result
-                (message "Tangled %s%s"
-                         ,file-nodir
-                         (if b/show-async-tangle-time
-                             (format " (%.3fs)"
-                                     (float-time (time-subtract (current-time)
-                                                                ',file-tangle-start-time)))
-                           ""))
-              (message "Tangling %s failed" ,file-nodir))))))))
-
-(add-to-list
- 'safe-local-variable-values
- '(eval add-hook 'after-save-hook #'b/async-babel-tangle 'append 'local))
+(require 'bandali-org)
 
 ;; *the* right way to do git
 (use-package magit
-  :defer 0.5
   :bind (("C-x g"   . magit-status)
          ("C-c g g" . magit-status)
          ("C-c g b" . magit-blame-addition)
@@ -679,16 +580,6 @@ For disabling the behaviour for certain buffers and/or modes."
   :custom
   (recentf-max-saved-items 2000))
 
-;; smart M-x enhancement (needed by counsel for history)
-;; (use-package smex)
-
-(bind-keys
- ("C-c f ." . find-file)
- ("C-c f d" . find-name-dired)
- ("C-c f l" . find-library)
- ;; ("C-c f r" . recentf-open-files)
- ("C-c x"   . execute-extended-command))
-
 (comment
   (use-package ido
     :demand