Skip to content

Commit

Permalink
[try] use commands and autoloads
Browse files Browse the repository at this point in the history
  • Loading branch information
pkryger committed Nov 11, 2024
1 parent c961ef3 commit 7b15261
Show file tree
Hide file tree
Showing 25 changed files with 228 additions and 347 deletions.
11 changes: 2 additions & 9 deletions modules/init-autocomplete.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@
;;; Code:

(use-package auto-complete
;; The following :preface should be replaced with builtin :functions, i.e.
;; :functions (ac-stop
;; ac-complete)
;; But for some reason it doesn't work pre Emacs-30 ¯\_(ツ)_/¯.
:preface
(when (bound-and-true-p byte-compile-current-file)
(declare-function ac-stop "auto-complete")
(declare-function ac-complete "auto-complete"))

:commands (ac-stop
ac-complete)
:custom
;; Case sensitivity is important when finding matches
;; Values are: t, nil, or 'smart
Expand Down
27 changes: 10 additions & 17 deletions modules/init-company.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,19 @@
;;

;;; Code:
(eval-when-compile
(unless (featurep 'init-require)
(load (file-name-concat (locate-user-emacs-file "modules") "init-require"))))
(exordium-require 'init-forge)

;; Need to get to known to compiler slots available in `forge-repository' EIEIO
;; object.
(eval-when-compile
(use-package forge)) ; init-forge.el
(use-package rtags)) ; init-rtags

(use-package company
:diminish "CA"
:after (rtags forge)
:functions (forge-get-repository)
:defines (rtags-completions-enabled)
;; The following :preface should be replaced with builtin :functions, i.e.
;; :functions (company-begin-backend
;; company-abort)
;; But for some reason it doesn't work pre Emacs-30 ¯\_(ツ)_/¯.
:preface
(when (bound-and-true-p byte-compile-current-file)
(declare-function company-begin-backend "company")
(declare-function company-abort "company"))
:defer
:after (forge)
:commands (company-begin-backend
company-abort)
:init
(defun exordium-company-assignees (command &optional arg &rest _ignored)
"A `company-mode' backend for assigneees in `forge-mode' repository."
Expand Down Expand Up @@ -88,8 +81,8 @@

(use-package company-statistics
:ensure t
:after company
:init
:after (company)
:config
(company-statistics-mode))

(provide 'init-company)
Expand Down
54 changes: 29 additions & 25 deletions modules/init-cpp.el
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
(eval-when-compile
(unless (featurep 'init-require)
(load (file-name-concat (locate-user-emacs-file "modules") "init-require"))))
(exordium-require 'init-prefs)
(exordium-require 'init-lib)

(require 'cl-lib)
Expand Down Expand Up @@ -168,32 +169,35 @@ With argument, switch to the second choice. For example, from a


;;; C++11 keywords
(pcase exordium-enable-c++11-keywords
(:simple
(let ((keywords (concat "\\<"
(regexp-opt
'("alignas"
"alignof"
"char16_t"
"char32_t"
"constexpr"
"decltype"
"final"
"noexcept"
"nullptr"
"override"
"static_assert"
"thread_local")
t)
"\\>")))
(add-hook 'c++-mode-hook
#'(lambda()
;; This can be completed with other things later (C++17?)
(font-lock-add-keywords
nil `((,keywords . font-lock-keyword-face))))
t)))
(:modern
(use-package modern-cpp-font-lock
:diminish modern-c++-font-lock-mode
:hook (c++-mode . modern-c++-font-lock-mode))))

(require 'init-prefs)
(use-package cl-lib :ensure nil)

(defconst exordium-extra-c++-keywords
(cl-remove-if #'null
(list
;; This can be completed with other things later (C++17?)
(when (eq exordium-enable-c++11-keywords :simple)
'("\\<\\(alignas\\|alignof\\|char16_t\\|char32_t\\|constexpr\\|decltype\\|noexcept\\|nullptr\\|static_assert\\|thread_local\\|override\\|final\\)\\>" . font-lock-keyword-face))))
"A-list of pairs (regex . face) for highlighting extra keywords in C++ mode.")

(when exordium-extra-c++-keywords
(add-hook 'c++-mode-hook
#'(lambda()
(font-lock-add-keywords nil exordium-extra-c++-keywords))
t))

(use-package modern-cpp-font-lock
:if (eq exordium-enable-c++11-keywords :modern)
:diminish modern-c++-font-lock-mode
:hook (c++-mode . modern-c++-font-lock-mode))

(use-package cmake-mode
:mode (("/CMakeLists\\.txt\\'" . cmake-mode)
("\\.cmake\\'" . cmake-mode)))


(provide 'init-cpp)
Expand Down
2 changes: 2 additions & 0 deletions modules/init-desktop.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
;;; Code:

(require 'saveplace)
(require 'savehist)
(require 'desktop)

(defun exordium--restore-desktop ()
"Restore desktop."
(setq desktop-path `(,user-emacs-directory))
Expand Down
10 changes: 2 additions & 8 deletions modules/init-dired.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@

(use-package dired
:ensure nil
;; The following :preface should be replaced with builtin :functions, i.e.
;; :functions (dired-mouse-find-file-other-window)
;; But for some reason it doesn't work pre Emacs-30 ¯\_(ツ)_/¯.
:preface
(when (bound-and-true-p byte-compile-current-file)
(declare-function dired-mouse-find-file-other-window "dired"))

:commands (dired-mouse-find-file-other-window)
:bind
(("C-x C-j" . #'dired-jump)
("C-x 4 C-j" . #'dired-jump-other-window)
:map dired-mode-map
([(mouse-3)] . #'dired-mouse-find-file-other-window)))
("<mouse-3>" . #'dired-mouse-find-file-other-window)))

(use-package wdired
:ensure nil
Expand Down
8 changes: 4 additions & 4 deletions modules/init-docker.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
:bind ("C-c D" . #'docker))

(use-package dockerfile-mode
:mode
("Dockerfile\\'" . dockerfile-mode)
:config
(setq-default docker-use-sudo nil))
:mode "Dockerfile\\'"
:custom
(docker-use-sudo nil))

(when (version< emacs-version "29")
(use-package docker-tramp
:after docker
:defer t))

(provide 'init-docker)
Expand Down
21 changes: 6 additions & 15 deletions modules/init-flycheck.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

(eval-when-compile
(use-package markdown-mode)) ; init-markdown.el

(use-package poly-rst)

(defvar exordium--flycheck-mypy-error-codes-alist nil
Expand All @@ -22,21 +23,11 @@ mypy error code and BODY is a rst body of the code.")
;;; Basic configuration (as need for lsp and for shellcheck)
(use-package flycheck
:functions (exodrium--flycheck-mypy-retrieve-error-codes)
;; The following :preface should be replaced with builtin :functions, i.e.
;; :functions (flycheck-add-next-checker
;; flycheck-buffer-saved-p
;; flycheck-call-checker-process
;; flycheck-flake8-fix-error-level
;; flycheck-sanitize-errors)
;; But for some reason it doesn't work pre Emacs-30 ¯\_(ツ)_/¯.
:preface
(when (bound-and-true-p byte-compile-current-file)
(declare-function flycheck-add-next-checker "flycheck")
(declare-function flycheck-buffer-saved-p "flycheck")
(declare-function flycheck-call-checker-process "flycheck")
(declare-function flycheck-flake8-fix-error-level "flycheck")
(declare-function flycheck-sanitize-errors "flycheck"))

:autoload (flycheck-add-next-checker
flycheck-buffer-saved-p
flycheck-call-checker-process
flycheck-flake8-fix-error-level
flycheck-sanitize-errors)
:commands flycheck-mode
:custom
(flycheck-global-modes '(not c++-mode c-mode org-mode))
Expand Down
4 changes: 1 addition & 3 deletions modules/init-font-lock.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
(defvar lazy-lock-stealth-time)
(setq lazy-lock-stealth-time 10)
(defvar lazy-lock-minimum-size)
(setq lazy-lock-minimum-size 10000)))
;;(fci-always-use-textual-rule t)
)
(setq lazy-lock-minimum-size 10000))))
(t
;; Disable font lock completely.
(global-font-lock-mode -1)))
Expand Down
45 changes: 19 additions & 26 deletions modules/init-forge.el
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@
;;; Code:

(eval-when-compile
(use-package ghub) ; dependency
(use-package magit) ; init-git.el
(use-package markdown-mode)) ; init-markdown.el
(unless (featurep 'init-require)
(load (file-name-concat (locate-user-emacs-file "modules") "init-require"))))
(exordium-require 'init-git)
(exordium-require 'init-markdown)

(use-package async
:autoload (async-inject-variables))
(use-package ghub
:autoload (ghub-graphql))

(require 'cl-lib)

(use-package async)

;; `emacsql' (a dependency of `forge') requires sqlite3 support. How the
;; support is provided changes with emacs-29 (i.e., built-in). See
Expand All @@ -34,27 +40,16 @@

;;; Magit Forge
(use-package forge
:defer t
:after (ghub magit markdown-mode)
:functions (exordium-forge--add-draft
exordium-ghub-graphql--pull-request-id
exordium-ghub-grqphql--mark-pull-request-ready-for-review
exordium-forge-markdown-preview
exordium-forge-post-submit-draft
exordium-forge-mark-ready-for-rewiew
markdown-preview
ghub-graphql
magit-git-string)
;; The following :preface should be replaced with builtin :functions, i.e.
;; :functions (forge-post-submit
;; forge-post-at-point
;; forge-current-topic)
;; But for some reason it doesn't work pre Emacs-30 ¯\_(ツ)_/¯.
:preface
(when (bound-and-true-p byte-compile-current-file)
(declare-function forge-post-submit "forge")
(declare-function forge-post-at-point "forge")
(declare-function forge-current-topic "forge"))

exordium-forge-mark-ready-for-rewiew)
:commands (forge-post-submit)
:autoload (forge-post-at-point
forge-current-topic)
:init

(defun exordium-forge-markdown-preview ()
Expand Down Expand Up @@ -156,13 +151,11 @@ USERNAME, AUTH, and HOST behave as for `ghub-request'."

(use-package forge
:functions (exordium-forge-cleanup-known-repositories--concat
exordium-forge-cleanup-known-repositories--question
async-inject-variables
magit-refresh
forge-sql)
:after async
exordium-forge-cleanup-known-repositories--question)
:autoload (forge-sql)
:after (magit async)
:demand t
:init

(defun exordium-forge-cleanup-known-repositories--question (to-delete &optional number)
"Return a question about deletion of up to NUMBER of TO-DELETE repositories.
Expand Down
39 changes: 15 additions & 24 deletions modules/init-git.el
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,15 @@ with `exordium-magit-quit-session'."

;;; Git gutter fringe: display added/removed/changed lines in the left fringe.

(when (bound-and-true-p byte-compile-current-file)
(declare-function git-gutter--turn-on "git-gutter"))
(defvar git-gutter-mode)
(use-package git-gutter
:if exordium-git-gutter
:diminish
:autoload (git-gutter--turn-on)
:commands (git-gutter:next-hunk
git-gutter:previous-hunk
git-gutter:popup-hunk
git-gutter:revert-hunk))

;;;###autoload
(define-globalized-minor-mode exordium-global-git-gutter-mode
git-gutter-mode
Expand All @@ -245,10 +251,6 @@ with `exordium-magit-quit-session'."
:diminish)

(use-package git-gutter-fringe
:functions (git-gutter:next-hunk
git-gutter:previous-hunk
git-gutter:popup-hunk
git-gutter:revert-hunk)
:if (and exordium-git-gutter (not exordium-git-gutter-non-fringe))
:diminish git-gutter-mode
:bind
Expand All @@ -275,7 +277,6 @@ with `exordium-magit-quit-session'."

;;; Git Timemachine
(use-package git-timemachine
:defer t
:bind
(:map exordium-git-map
("t" . #'git-timemachine-toggle)))
Expand All @@ -298,20 +299,10 @@ with `exordium-magit-quit-session'."

(use-package ediff
:ensure nil
:functions (exordium-ediff-copy-both-to-C
exordium--ediff-set-help-message
exordium--add-copy-both-to-ediff-mode-map)
;; The following :preface should be replaced with builtin :functions, i.e.
;; :functions (ediff-copy-diff
;; ediff-get-region-contents)
;; But for some reason it doesn't work pre Emacs-30 ¯\_(ツ)_/¯.
:preface
(when (bound-and-true-p byte-compile-current-file)
(declare-function ediff-copy-diff "ediff")
(declare-function ediff-get-region-contents "ediff"))

:defer t
:config
:functions (exordium-ediff-copy-both-to-C)
:autoload (ediff-copy-diff
ediff-get-region-contents)
:init
(defun exordium-ediff-copy-both-to-C (first second)
"Copy FIRST then SECOND into the C buffer in `ediff-mode'.
This command should be called form `ediff''s control buffer.
Expand Down Expand Up @@ -370,8 +361,8 @@ This follows what `ediff-set-help-message' function is doing."
(when ediff-use-long-help-message
(setq ediff-help-message ediff-long-help-message))))

(add-hook 'ediff-display-help-hook #'exordium--ediff-set-help-message)
(add-hook 'ediff-keymap-setup-hook #'exordium--add-copy-both-to-ediff-mode-map))
:hook ((ediff-display-help . exordium--ediff-set-help-message)
(ediff-keymap-setup . exordium--add-copy-both-to-ediff-mode-map)))



Expand Down
Loading

0 comments on commit 7b15261

Please sign in to comment.