[emacs][wip] a/async-babel-tangle: add option to byte-recompile-file
[~bandali/configs] / init.org
index 9927089..3cf7343 100644 (file)
--- a/init.org
+++ b/init.org
@@ -296,6 +296,8 @@ and without compromising on performance.
           debug-on-error t)
   (setq use-package-verbose nil
         use-package-expand-minimally t))
+
+(setq use-package-always-defer t)
 #+end_src
 
 *** COMMENT Epkg
@@ -727,6 +729,7 @@ for this.
 ** Bindings
 
 #+begin_src emacs-lisp
+(require 'bind-key)
 (bind-keys
  ("C-c a i" . ielm)
 
@@ -894,9 +897,12 @@ file.
   (defvar a/show-async-tangle-time nil
     "Show the time spent tangling the file.")
 
-  (defvar a/async-tangle-post-compile "make ti"
+  (defvar a/async-tangle-post-compile nil
     "If non-nil, pass to `compile' after successful tangle.")
 
+  (defvar a/async-tangle-byte-recompile t
+    "If non-nil, byte-recompile the file on successful tangle.")
+
   (defun a/async-babel-tangle ()
     "Tangle org file asynchronously."
     (interactive)
@@ -904,7 +910,7 @@ file.
            (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)
@@ -913,6 +919,7 @@ file.
          `(lambda (result)
             (if result
                 (progn
+                  (setq byte-compile-warnings '(not noruntime unresolved))
                   (message "Tangled %s%s"
                            ,file-nodir
                            (if a/show-async-tangle-time
@@ -921,7 +928,9 @@ file.
                                                                   ',file-tangle-start-time)))
                              ""))
                   (when a/async-tangle-post-compile
-                    (compile a/async-tangle-post-compile)))
+                    (compile a/async-tangle-post-compile))
+                  (when a/async-tangle-byte-recompile
+                    (byte-recompile-file (concat ,file-noext ".el"))))
               (message "Tangling %s failed" ,file-nodir))))))))
 
 (add-to-list
@@ -969,6 +978,18 @@ Recently opened files.
   (setq recentf-max-saved-items 40))
 #+end_src
 
+*** smex
+
+#+begin_quote
+A smart M-x enhancement for Emacs.
+#+end_quote
+
+Mostly because =counsel= needs it to remember history.
+
+#+begin_src emacs-lisp
+(use-package smex)
+#+end_src
+
 *** [[https://github.com/abo-abo/swiper][Ivy]] (and friends)
 
 #+begin_quote
@@ -1067,7 +1088,6 @@ There's no way I could top that, so I won't attempt to.
 
 #+begin_src emacs-lisp
 (use-feature ibuffer
-  :defer t
   :bind
   (("C-x C-b" . ibuffer-other-window)
    :map ibuffer-mode-map
@@ -1138,7 +1158,6 @@ There's no way I could top that, so I won't attempt to.
 
 #+begin_src emacs-lisp
 (use-feature outline
-  :defer t
   :hook (prog-mode . outline-minor-mode)
   :bind
   (:map
@@ -1163,7 +1182,6 @@ There's no way I could top that, so I won't attempt to.
   :custom (ls-lisp-dirs-first t))
 
 (use-feature dired
-  :defer t
   :config
   (setq dired-listing-switches "-alh"
         ls-lisp-use-insert-directory-program nil)
@@ -1172,6 +1190,7 @@ There's no way I could top that, so I won't attempt to.
   ;; https://oremacs.com/2017/03/18/dired-ediff/
   (defun dired-ediff-files ()
     (interactive)
+    (require 'dired-aux)
     (defvar ediff-after-quit-hook-internal)
     (let ((files (dired-get-marked-files))
           (wnd (current-window-configuration)))
@@ -1191,6 +1210,7 @@ There's no way I could top that, so I won't attempt to.
                         (set-window-configuration wnd))))
         (error "no more than 2 files should be marked"))))
   :bind (:map dired-mode-map
+              ("b"  . dired-up-directory)
               ("e"  . dired-ediff-files)
               ("E"  . dired-toggle-read-only)
               ("\\" . dired-hide-details-mode)
@@ -1204,7 +1224,6 @@ There's no way I could top that, so I won't attempt to.
 
 #+begin_src emacs-lisp
 (use-feature help
-  :defer t
   :config
   (temp-buffer-resize-mode)
   (setq help-window-select t))
@@ -1214,7 +1233,6 @@ There's no way I could top that, so I won't attempt to.
 
 #+begin_src emacs-lisp
 (use-feature tramp
-  :defer t
   :config
   (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
   (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
@@ -1226,7 +1244,6 @@ There's no way I could top that, so I won't attempt to.
 
 #+begin_src emacs-lisp
 (use-package dash
-  :defer t
   :config (dash-enable-font-lock))
 #+end_src
 
@@ -1388,15 +1405,13 @@ Automatically save place in each file.
 #+begin_src emacs-lisp
 (use-package alloy-mode
   :straight (:host github :repo "dwwmmn/alloy-mode")
-  :defer t
   :config (setq alloy-basic-offset 2))
 #+end_src
 
 ** [[https://coq.inria.fr][Coq]] (with [[https://github.com/ProofGeneral/PG][Proof General]])
 
 #+begin_src emacs-lisp
-(use-package proof-general
-  :defer t)
+(use-package proof-general)
 #+end_src
 
 ** [[https://leanprover.github.io][Lean]] (with [[https://github.com/leanprover/lean-mode][lean-mode]])
@@ -1423,7 +1438,6 @@ Automatically save place in each file.
 
 #+begin_src emacs-lisp
 (use-package haskell-mode
-  :defer t
   :config
   (setq haskell-indentation-layout-offset 4
         haskell-indentation-left-offset 4
@@ -1612,7 +1626,6 @@ instead.
 
 #+begin_src emacs-lisp
 (use-package sgml-mode
-  :defer t
   :config
   (setq sgml-basic-offset 2))
 #+end_src
@@ -1621,7 +1634,6 @@ instead.
 
 #+begin_src emacs-lisp
 (use-package css-mode
-  :defer t
   :config
   (setq css-indent-offset 2))
 #+end_src
@@ -1630,7 +1642,6 @@ instead.
 
 #+begin_src emacs-lisp
 (use-package web-mode
-  :defer t
   :mode "\\.html\\'"
   :config
   (a/setq-every 2
@@ -1749,7 +1760,7 @@ treemacs
 (use-package guix)
 #+end_src
 
-* COMMENT Emacs enhancements
+* Emacs enhancements
 :PROPERTIES:
 :CUSTOM_ID: emacs-enhancements
 :END:
@@ -1758,7 +1769,6 @@ treemacs
 
 #+begin_src emacs-lisp
 (use-feature man
-  :defer t
   :config (setq Man-width 80))
 #+end_src
 
@@ -1829,6 +1839,7 @@ Emacs package that displays available keybindings in popup
 
 #+begin_src emacs-lisp
 (use-package smart-mode-line
+  :commands (sml/apply-theme)
   :config
   (sml/setup))
 #+end_src
@@ -1864,7 +1875,7 @@ Emacs package that displays available keybindings in popup
 ** [[https://github.com/bbatsov/crux][crux]]
 
 #+begin_src emacs-lisp
-(use-package crux
+(use-package crux                       ; results in Waiting for git... [2 times]
   :defer 1
   :bind (("C-c b k" . crux-kill-other-buffers)
          ("C-c d"   . crux-duplicate-current-line-or-region)
@@ -1890,7 +1901,6 @@ Emacs package that displays available keybindings in popup
 
 #+begin_src emacs-lisp
 (use-package projectile
-  :defer t
   :bind-keymap ("C-c p" . projectile-command-map)
   :config
   (projectile-mode)
@@ -2102,7 +2112,7 @@ Also see [[https://www.emacswiki.org/emacs/rebox2][rebox2]].
                ("a" . mc/mark-all-like-this))))
 #+end_src
 
-* COMMENT Email
+* Email
 :PROPERTIES:
 :CUSTOM_ID: email
 :END:
@@ -2121,7 +2131,7 @@ Also see [[https://www.emacswiki.org/emacs/rebox2][rebox2]].
  mail-user-agent   'gnus-user-agent
  read-mail-command 'gnus)
 
-(use-package gnus
+(use-feature gnus
   :bind (("s-m"   . gnus)
          ("s-M"   . gnus-unplugged))
   :init
@@ -2154,7 +2164,7 @@ Also see [[https://www.emacswiki.org/emacs/rebox2][rebox2]].
    gnus-interactive-exit nil
    gnus-gcc-mark-as-read t))
 
-(use-package gnus-art
+(use-feature gnus-art
   :config
   (setq
    gnus-visible-headers
@@ -2183,7 +2193,7 @@ Also see [[https://www.emacswiki.org/emacs/rebox2][rebox2]].
    ("R"   . gnus-article-wide-reply-with-original)
    ("M-L" . org-store-link)))
 
-(use-package gnus-sum
+(use-feature gnus-sum
   :bind (:map gnus-summary-mode-map
               :prefix-map a/gnus-summary-prefix-map
               :prefix "v"
@@ -2198,7 +2208,7 @@ Also see [[https://www.emacswiki.org/emacs/rebox2][rebox2]].
    ("M-L" . org-store-link))
   :hook (gnus-summary-mode . a/no-mouse-autoselect-window))
 
-(use-package gnus-msg
+(use-feature gnus-msg
   :config
   (setq gnus-posting-styles
         '((".*"
@@ -2215,19 +2225,19 @@ Also see [[https://www.emacswiki.org/emacs/rebox2][rebox2]].
            (address "abandali@uwaterloo.ca")
            (gcc "\"nnimap+uwaterloo:Sent Items\"")))))
 
-(use-package gnus-topic
+(use-feature gnus-topic
   :hook (gnus-group-mode . gnus-topic-mode))
 
-(use-package gnus-agent
+(use-feature gnus-agent
   :config
   (setq gnus-agent-synchronize-flags 'ask)
   :hook (gnus-group-mode . gnus-agent-mode))
 
-(use-package gnus-group
+(use-feature gnus-group
   :config
   (setq gnus-permanently-visible-groups "\\((INBOX\\|gnu$\\)"))
 
-(use-package mm-decode
+(use-feature mm-decode
   :config
   (setq mm-discouraged-alternatives '("text/html" "text/richtext")))
 #+end_src
@@ -2235,7 +2245,7 @@ Also see [[https://www.emacswiki.org/emacs/rebox2][rebox2]].
 ** sendmail
 
 #+begin_src emacs-lisp
-(use-package sendmail
+(use-feature sendmail
   :config
   (setq sendmail-program "/usr/bin/msmtp"
         ;; message-sendmail-extra-arguments '("-v" "-d")
@@ -2246,7 +2256,7 @@ Also see [[https://www.emacswiki.org/emacs/rebox2][rebox2]].
 ** message
 
 #+begin_src emacs-lisp
-(use-package message
+(use-feature message
   :config
   (defconst a/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
   (defconst message-cite-style-bandali
@@ -2291,7 +2301,7 @@ Also see [[https://www.emacswiki.org/emacs/rebox2][rebox2]].
 Convenient footnotes in =message-mode=.
 
 #+begin_src emacs-lisp
-(use-package footnote
+(use-feature footnote
   :after message
   :bind
   (:map message-mode-map
@@ -2314,14 +2324,14 @@ Convenient footnotes in =message-mode=.
 
 #+begin_src emacs-lisp
 (use-package ebdb
-  :defer 1
+  :after gnus
   :bind (:map gnus-group-mode-map ("e" . ebdb))
   :config
   (setq ebdb-sources (no-littering-expand-var-file-name "ebdb"))
   (with-eval-after-load 'swiper
     (add-to-list 'swiper-font-lock-exclude 'ebdb-mode t)))
 
-(use-package ebdb-com
+(use-feature ebdb-com
   :after ebdb)
 
 ;; (use-package ebdb-complete
@@ -2338,7 +2348,7 @@ Convenient footnotes in =message-mode=.
                     (add-to-list (make-local-variable 'company-backends)
                                  'company-ebdb))))
 
-(use-package ebdb-gnus
+(use-feature ebdb-gnus
   :after ebdb
   :custom
   (ebdb-gnus-window-configuration
@@ -2349,7 +2359,7 @@ Convenient footnotes in =message-mode=.
                            (article 1.0)
                            (ebdb-gnus 0.3))))))
 
-(use-package ebdb-mua
+(use-feature ebdb-mua
   :after ebdb
   ;; :custom (ebdb-mua-pop-up nil)
   )
@@ -2389,7 +2399,7 @@ Convenient footnotes in =message-mode=.
     (gnus-harvest-install)))
 #+end_src
 
-* COMMENT Blogging
+* Blogging
 :PROPERTIES:
 :CUSTOM_ID: blogging
 :END:
@@ -2400,8 +2410,8 @@ Convenient footnotes in =message-mode=.
 (use-package ox-hugo
   :after ox)
 
-(use-package ox-hugo-auto-export
-  :load-path "lib/ox-hugo")
+(use-feature ox-hugo-auto-export
+  :after ox-hugo)
 #+end_src
 
 * Post initialization
@@ -2428,6 +2438,6 @@ Display how long it took to load the init file.
 
 * COMMENT Local Variables                                           :ARCHIVE:
 # Local Variables:
-# eval: ;; (add-hook 'after-save-hook #'a/async-babel-tangle 'append 'local)
+# eval: (add-hook 'after-save-hook #'a/async-babel-tangle 'append 'local)
 # eval: (typo-mode -1)
 # End: