summary refs log tree commit diff stats
path: root/emacs
diff options
context:
space:
mode:
authorAlan Pearce2017-09-01 20:37:43 +0200
committerAlan Pearce2017-09-01 20:37:43 +0200
commit57de1e62030f812a20918509fdb07154c7622e73 (patch)
tree866dacdd0d11face903902f06f9bd815e9baf8e7 /emacs
parentbfdf0f4afb759fecbc6d374dadf1b522f70f9e54 (diff)
downloadnixfiles-57de1e62030f812a20918509fdb07154c7622e73.tar.lz
nixfiles-57de1e62030f812a20918509fdb07154c7622e73.tar.zst
nixfiles-57de1e62030f812a20918509fdb07154c7622e73.zip
Emacs: Silence most byte-compiler warnings
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/main.el77
1 files changed, 53 insertions, 24 deletions
diff --git a/emacs/.emacs.d/main.el b/emacs/.emacs.d/main.el
index 1b4bff36..3e454195 100644
--- a/emacs/.emacs.d/main.el
+++ b/emacs/.emacs.d/main.el
@@ -242,7 +242,8 @@
 
 ;; #+BEGIN_SRC emacs-lisp
 (if (eq window-system 'mac)
-    (mac-auto-operator-composition-mode +1)
+    (if (fboundp 'mac-auto-operator-composition-mode)
+        (mac-auto-operator-composition-mode +1))
     (global-prettify-symbols-mode +1))
 ;; #+END_SRC
 
@@ -301,7 +302,7 @@
 ;; #+BEGIN_SRC emacs-lisp
 (defvar mode-line-default-format mode-line-format)
 (defvar mode-line-default-hidden nil
-  "Whether to hide the mode line by default")
+  "Whether to hide the mode line by default.")
 
 (defun show-mode-line ()
   (interactive)
@@ -434,6 +435,8 @@
 
 ;; #+BEGIN_SRC emacs-lisp
 (use-package nix-sandbox
+  :defines (flycheck-command-wrapper-function
+            flycheck-executable-find)
   :config (progn
             (with-eval-after-load 'flycheck
               (setq flycheck-command-wrapper-function
@@ -527,6 +530,7 @@
 
 ;; #+BEGIN_SRC emacs-lisp
 (defun switch-to-dotfiles ()
+  "Switch to dotfiles project."
   (interactive)
   (projectile-switch-project-by-name (car (split-string (shell-command-to-string "ghq list --full-path dotfiles")))))
 ;; #+END_SRC
@@ -782,9 +786,10 @@
 
 ;; #+BEGIN_SRC emacs-lisp
 (defun my-create-non-existent-directory ()
+  "Offer to create non-existent directories of found-file."
   (let ((parent-directory (file-name-directory buffer-file-name)))
     (when (and (not (file-exists-p parent-directory))
-               (y-or-n-p (format "Directory `%s' does not exist!  Create it?" parent-directory)))
+               (y-or-n-p (format "Directory `%s' does not exist!  Create it? " parent-directory)))
       (make-directory parent-directory t))))
 (add-to-list 'find-file-not-found-functions #'my-create-non-existent-directory)
 ;; #+END_SRC
@@ -794,7 +799,7 @@
 
 ;; #+BEGIN_SRC emacs-lisp
 (defun kill-or-delete-this-buffer-dwim (&optional arg)
-  "Kills current buffer.  With prefix arg, delete it."
+  "Kill current buffer.  With prefix ARG, delete it."
   (interactive "P")
   (if (equal arg '(4))
       (delete-current-buffer-file)
@@ -812,9 +817,11 @@
 
 ;; #+BEGIN_SRC emacs-lisp
 (defun show-trailing-whitespace-on ()
+  "Show trailing whitespace."
   (interactive)
   (setq-local show-trailing-whitespace t))
 (defun show-trailing-whitespace-off ()
+  "Hide trailing whitespace."
   (interactive)
   (setq-local show-trailing-whitespace nil))
 (add-hook 'prog-mode-hook #'show-trailing-whitespace-on)
@@ -1180,8 +1187,9 @@
 ;; Sometimes I want to insert a date or time into a buffer.
 ;; #+BEGIN_SRC emacs-lisp
 (defun insert-date (prefix)
-  "Insert the current date.  With prefix-argument, use British format.  With
-     two prefix arguments, write out the day and month name."
+  "Insert the current date.
+With PREFIX, use British format.
+With two prefix arguments, write out the day and month name."
   (interactive "P")
   (let ((format (cond
                  ((not prefix) "%Y-%m-%d")
@@ -1190,7 +1198,7 @@
     (insert (format-time-string format))))
 
 (defun insert-datetime (prefix)
-  "Insert the current date and time."
+  "Insert current date and time.  With PREFIX, use ISO8601 format."
   (interactive "P")
   (let ((format (cond
                  ((not prefix) "%Y-%m-%d %H:%M:%S")
@@ -1200,7 +1208,7 @@
 
 ;; #+BEGIN_SRC emacs-lisp
 (defun yesterday-time ()
-  "Provide the date/time 24 hours before the time now in the format of current-time."
+  "Provide the date/time 24 hours before the time now in the format of `current-time'."
   (timer-relative-time (current-time) -86400))
 ;; #+END_SRC
 
@@ -1233,6 +1241,7 @@
 
 ;; #+BEGIN_SRC emacs-lisp
 (defun turn-on-dired-omit-mode ()
+  "Enable dired-omit mode."
   (interactive)
   (dired-omit-mode 1))
 
@@ -1374,6 +1383,10 @@
                             (file-truename
                              (executable-find "mu")))))
   (use-package mu4e
+    :defines (mu4e-use-fancy-chars
+              mu4e-attachment-dir
+              mu4e-view-show-images
+              mu4e-headers-date-format)
     :config (progn
               (setq mu4e-use-fancy-chars nil
                     mu4e-attachment-dir "~/Downloads/"
@@ -1453,11 +1466,11 @@
 ;; #+BEGIN_SRC emacs-lisp
 (defvar *init-file*
   (file-truename user-init-file)
-  "Where the emacs init file really is, passing through symlinks.")
+  "Where the Emacs init file really is, passing through symlinks.")
 (set-register ?e `(file . ,*init-file*))
 
 (defun ap/remove-extra-cr ()
-  "Remove extraneous CR codes from a file"
+  "Remove extraneous CR codes from a file."
   (interactive)
   (save-excursion
     (goto-char (point-min))
@@ -1467,12 +1480,15 @@
 
 (use-package rect
   :ensure nil
+  :defines (killed-rectangle)
   :init (defun copy-rectangle (start end)
           "Copy the region-rectangle."
           (interactive "r")
           (setq killed-rectangle (extract-rectangle start end))))
 
 (defun shell-execute (to-current-buffer)
+  "Execute shell command, replacing % with the current buffer file name.
+With prefix TO-CURRENT-BUFFER, insert command output into buffer."
   (interactive "P")
   (let ((file-buffer (if (buffer-file-name)
                          (file-name-nondirectory (buffer-file-name))
@@ -1481,7 +1497,7 @@
     (shell-command (replace-regexp-in-string "%" file-buffer command) to-current-buffer)))
 
 (defun process-exit-code (program &rest args)
-  "Run PROGRAM with ARGS and return the exit code"
+  "Run PROGRAM with ARGS and return the exit code."
   (apply 'call-process program nil nil nil args))
 
 (defun narrow-to-region-indirect (start end)
@@ -1510,14 +1526,16 @@
       (concat "/run/user/" (number-to-string (user-uid)) "/gnupg/S.gpg-agent.ssh")))
 
 (defun read-gpg-file (file)
+  "Read (decrypt) given GPG file FILE."
   (let ((file-to-decrypt (expand-file-name file user-emacs-directory))
-	(ctx (epg-make-context epa-protocol)))
+        (ctx (epg-make-context epa-protocol)))
     (if (file-exists-p file-to-decrypt)
-	(epg-decrypt-file ctx file-to-decrypt nil)
+        (epg-decrypt-file ctx file-to-decrypt nil)
       (message "Decrypting %s...failed" file-to-decrypt)
       (error "File %s does not exist" file-to-decrypt))))
 
 (defun load-gpg (file)
+  "Load FILE if private key is available."
   (if have-private-key
       (load file)
     (message "WARNING: Couldn't load %s (No gpg key found)" file)))
@@ -1525,6 +1543,7 @@
 ; load this in a post-frame hook because gpg-agent asks for a password on first
 ; startup and caches it. Don't want emacs daemon to hang because of gpg-agent.
 (defun load-private-data ()
+  "Load encrypted config in file based upon hostname."
   (interactive)
   (if (not (file-exists-p (expand-file-name (concat (system-name) ".el.gpg") user-emacs-directory)))
       (message "No encrypted configuration matches system name `%s'" (system-name))
@@ -1541,7 +1560,8 @@
       (add-to-list 'load-suffixes ".el.gpg")
       (load-gpg (expand-file-name (system-name) user-emacs-directory)))))
 
-(defun first-frame-hook (frame)
+(defun first-frame-hook ()
+  "Hook run only after first frame is created."
   (remove-hook 'after-make-frame-functions #'first-frame-hook)
   (run-at-time nil nil 'load-private-data))
 
@@ -1628,6 +1648,7 @@
 
 ;; #+BEGIN_SRC emacs-lisp
 (use-package smex
+  :defines (smex-key-advice-ignore-menu-bar)
   :commands (smex
              smex-update
              smex-initialize)
@@ -1733,6 +1754,8 @@
 (use-package ledger-mode
   :mode ("\\.ledger\\'" . ledger-mode)
   :functions ledger-report
+  :defines (ledger-use-iso-dates
+            ledger-post-use-completion-engine)
   :init (progn
           (defun open-budget ()
             (interactive)
@@ -1802,6 +1825,7 @@
          ("C-c a" . org-agenda)
          ("C-c l" . org-store-link))
   :defer 8
+  :defines (org-table-duration-custom-format)
   :init (setq org-replace-disputed-keys t
               org-ellipsis "…")
   :config (progn
@@ -1828,8 +1852,6 @@
 
                   org-src-fontify-natively nil
 
-                  org-export-have-math t
-
                   org-blank-before-new-entry '((heading . t)
                                                (plain-list-item . auto))
                   org-fontify-done-headline t
@@ -1887,9 +1909,9 @@
             (define-hook-helper org-journal-mode ()
               (use-variable-fonts)
               (text-scale-adjust 4)
-              (if smartparens-strict-mode
+              (if (fboundp 'smartparens-strict-mode)
                   (smartparens-strict-mode -1))
-              (if show-smartparens-mode
+              (if (fboundp 'show-smartparens-mode)
                   (show-smartparens-mode -1)))
             (defun org-journal-display-entry-yesterday ()
               "Show org-journal entry for yesterday"
@@ -2399,11 +2421,13 @@
 
 ;; #+BEGIN_SRC emacs-lisp
 (defun live-coding ()
+  "Configure display for live coding."
   (interactive)
   (ap/set-fonts "SF Mono" 18 nil nil t 0.1)
   (global-command-log-mode 1))
 
 (defun live-coding-stop ()
+  "Revert live coding display configuration."
   (interactive)
   (ap/set-fonts-according-to-system)
   (global-command-log-mode -1))
@@ -2413,11 +2437,11 @@
 
 ;; #+BEGIN_SRC emacs-lisp
 (use-package command-log-mode
-  :defines command-log-mode-key-binding-open-log
-  :init (progn
-          (setq command-log-mode-key-binding-open-log nil
-                command-log-mode-auto-show t
-                command-log-mode-is-global t)))
+  :defines (command-log-mode-key-binding-open-log)
+  :config (progn
+            (setq command-log-mode-key-binding-open-log nil
+                  command-log-mode-auto-show t
+                  command-log-mode-is-global t)))
 ;; #+END_SRC
 
 ;; ** Spelling
@@ -2528,6 +2552,7 @@
   :bind ("C-c s" .  eshell)
   :defer 10
   :functions (eshell/pwd)
+  :defines (eshell-prompt-function)
   :config (progn
             (setq eshell-directory-name "~/.emacs.d/eshell"
                   eshell-prompt-function (lambda ()
@@ -2549,6 +2574,8 @@
 
 (autoload #'eshell/cd "em-dirs")
 (defun eshell-goto-current-dir (&optional arg)
+  "Open `default-directory' in eshell.
+Pass optional ARG to `eshell' (which see)."
   (interactive "P")
   (let ((dir default-directory))
     (eshell arg)
@@ -2573,6 +2600,8 @@
   :config (bind-key "C-c C-l" #'counsel-shell-history comint-mode-map))
 
 (defun comint-delchar-or-eof-or-kill-buffer (arg)
+  "DWIM command for ^D to behave like in shells.
+Pass ARG to `comint-delchar-or-maybe-eof'."
   (interactive "p")
   (if (null (get-buffer-process (current-buffer)))
       (kill-buffer)
@@ -2765,7 +2794,7 @@
             (bind-key "M-<up>" #'sp-splice-sexp-killing-backward smartparens-mode-map)
             (bind-key "M-<down>" #'sp-splice-sexp-killing-forward smartparens-mode-map)
             (bind-key "C-M-S-k" #'sp-kill-hybrid-sexp smartparens-mode-map)
-            (bind-key "C-S-<right>" #'sp-slurp-hybrid-sexp smartparens-mode-map) 
+            (bind-key "C-S-<right>" #'sp-slurp-hybrid-sexp smartparens-mode-map)
             (show-smartparens-global-mode t)
             (smartparens-global-strict-mode t)
             (define-hook-helper lisp-mode-common ()