Skip to content

Commit

Permalink
Ensure bind maps, autoloads, and commands from correct packages
Browse files Browse the repository at this point in the history
  • Loading branch information
pkryger committed Dec 3, 2024
1 parent 4941b84 commit 9402a66
Show file tree
Hide file tree
Showing 24 changed files with 227 additions and 124 deletions.
7 changes: 5 additions & 2 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,16 @@ TEMP-FILE is the temporary log file to communicate compilation
results to parrent Emacs.")

(use-package async
:autoload (async-bytecomp-package-mode)
:defines (async-byte-compile-log-file)
:functions (exordium--async-cleanup-temp-file
exordium--async-generate-temp-file
exordium--async-with-temp-file
exordium--async-package-reload-previously-loaded)
:init
(use-package async-bytecomp
:ensure async
:defer t
:autoload (async-bytecomp-package-mode)
:defines (async-byte-compile-log-file))
(defun exordium--async-cleanup-temp-file (file-or-directory)
"Remove the file associated with FILE-OR-DIRECTORY.
Also remove the FILE-OR-DIRECTORY from `exordium--async-bytecomp-log-alist'."
Expand Down
4 changes: 2 additions & 2 deletions modules/init-autocomplete.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
(;; Key to force trigger auto-complete (useful if ac-auto-start is set to nil)
("C-." . #'auto-complete)
:map ac-completing-map
("ESC" . #'ac-stop)
("RET" . #'ac-complete)))
("ESC" . #'ac-stop)
("RET" . #'ac-complete)))

(provide 'init-autocomplete)

Expand Down
8 changes: 6 additions & 2 deletions modules/init-company.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@

(use-package company
:diminish "CA"
:after (forge)
:commands (company-begin-backend
company-abort)
:init
(use-package forge-core
:ensure forge
:defer t
:autoload (forge-get-repository))

(defun exordium-company-assignees (command &optional arg &rest _ignored)
"A `company-mode' backend for assigneees in `forge-mode' repository."
(interactive (list 'interactive))
Expand Down Expand Up @@ -77,7 +81,7 @@
:bind
(("C-." . #'company-complete)
:map company-active-map
("ESC" . #'company-abort)))
("ESC" . #'company-abort)))


(use-package company-statistics
Expand Down
34 changes: 31 additions & 3 deletions modules/init-cpp.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,56 @@
(load (file-name-concat (locate-user-emacs-file "modules") "init-require"))))
(exordium-require 'init-prefs)
(exordium-require 'init-lib)
(when exordium-help-extensions
(exordium-require 'init-help))

(require 'cl-lib)

(use-package cc-mode
:ensure nil
:config
;;; Open a header file in C++ mode by default
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode)))


;;; IEdit: rename the symbol under point
(use-package iedit
:custom
;; Fix A bug: normal key is "C-;", but we're going to roll our own bindings
;; with bind-key
(iedit-toggle-key-default nil)
:init
;;; Fix A bug (normal key is "C-;")
:bind ("C-c ;" . #'iedit-mode))
(use-package isearch
:ensure nil
:defer t
:bind
(:map isearch-mode-map
("C-c ;" . #'iedit-mode-from-isearch)))
(use-package help
:ensure nil
:defer t
:bind
(:map help-map
("C-;" . #'iedit-mode-toggle-on-function)))
(when exordium-help-extensions
(use-package helpful
:defer t
:bind
(:map helpful-mode-map
("C-;" . #'iedit-mode-toggle-on-function))))
:bind
(("C-c ;" . #'iedit-mode)
:map esc-map
("C-;" . #'iedit-execute-last-modification)))

;;; Don't show the abbrev minor mode in the mode line
(diminish 'abbrev-mode)


;;; Highlight dead code between #if 0 and #endif

(use-package cpp)
(use-package cpp
:ensure nil)
(defun cpp-highlight-dead-code ()
"Highlight c/c++ #if 0 #endif macros."
(let ((color (face-background 'shadow)))
Expand Down
2 changes: 1 addition & 1 deletion modules/init-dired.el
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(("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
30 changes: 16 additions & 14 deletions modules/init-elisp.el
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,29 @@
:defer t
:bind
(:map emacs-lisp-mode-map
("M-C-g" . #'helm-imenu)
("C-c M-e" . #'pp-eval-last-sexp)
("M-." . #'xref-find-definitions)
("M-," . #'xref-go-back)
("M-r" . #'xref-find-references)
:map lisp-interaction-mode-map
("M-C-g" . #'helm-imenu)
("C-c M-e" . #'pp-eval-last-sexp)
("M-." . #'xref-find-definitions)
("M-," . #'xref-go-back)
("M-r" . #'xref-find-references)))
("M-C-g" . #'helm-imenu)
("C-c M-e" . #'pp-eval-last-sexp)
("M-." . #'xref-find-definitions)
("M-," . #'xref-go-back)
("M-r" . #'xref-find-references)
:map lisp-interaction-mode-map
("M-C-g" . #'helm-imenu)
("C-c M-e" . #'pp-eval-last-sexp)
("M-." . #'xref-find-definitions)
("M-," . #'xref-go-back)
("M-r" . #'xref-find-references)))

(use-package elisp-mode
:ensure nil
:defer t
:if exordium-help-extensions
:bind
(:map emacs-lisp-mode-map
("M-?" . #'helpful-at-point)
:map lisp-interaction-mode-map
("M-?" . #'helpful-at-point)))
("M-?" . #'helpful-at-point)
("C-c C-d" . #'helpful-at-point)
:map lisp-interaction-mode-map
("M-?" . #'helpful-at-point)
("C-c C-d" . #'helpful-at-point)))


;;; Display page breaks with an horizontal line instead of ^L.
Expand Down
5 changes: 5 additions & 0 deletions modules/init-flb-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
(load (file-name-concat (locate-user-emacs-file "modules") "init-require"))))
(exordium-require 'init-git)

(use-package magit-mode
:ensure magit
:defer t
:autoload (magit-save-repository-buffers))

(require 'cl-lib)

(define-minor-mode flb-mode
Expand Down
19 changes: 12 additions & 7 deletions modules/init-flycheck.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
(exordium-require 'init-prefs)
(exordium-require 'init-lib)
(exordium-require 'init-markdown)
(exordium-require 'init-helm)

(require 'cc-mode)

Expand All @@ -31,11 +32,17 @@
(flycheck-mode)
(diminish 'flycheck-mode))
(helm-flycheck))
:bind
(:map c-mode-base-map
("C-c r r" . #'exordium-helm-flycheck)
:map helm-command-map
("f" . #'exordium-helm-flycheck)))
(use-package cc-mode
:ensure nil
:defer t
:bind
(:map c-mode-base-map
("C-c r r" . #'exordium-helm-flycheck)))
(use-package helm
:defer t
:bind
(:map helm-command-map
("f" . #'exordium-helm-flycheck))))

(use-package poly-rst
:defer t)
Expand All @@ -55,8 +62,6 @@ mypy error code and BODY is a rst body of the code.")
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))
:hook
Expand Down
60 changes: 41 additions & 19 deletions modules/init-forge.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@
(exordium-require 'init-git)
(exordium-require 'init-markdown)

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

(require 'cl-lib)


;; `emacsql' (a dependency of `forge') requires sqlite3 support. How the
;; support is provided changes with emacs-29 (i.e., built-in). See
;; support is provided changes with Emacs-29 (i.e., built-in). See
;; https://github.com/magit/emacsql/commit/6401226 for more details.
(unless (and (fboundp 'sqlite-available-p)
(sqlite-available-p))
Expand All @@ -47,12 +41,28 @@
exordium-forge-markdown-preview
exordium-forge-post-submit-draft
exordium-forge-mark-ready-for-rewiew)
:commands (forge-post-submit)
:autoload (forge-post-at-point
forge-current-topic
forge-get-repository) ; required by init-company.el
:defer t
:init
(use-package ghub-graphql
:ensure ghub
:defer t
:autoload (ghub-graphql))
(use-package forge-post
:ensure forge
:defer t
:commands (forge-post-submit)
:autoload (forge-post-at-point))
(use-package forge-topic
:ensure forge
:defer t
:autoload (forge-current-topic))
(use-package magit-git
:ensure magit
:defer t
:autoload (magit-git-string))
(use-package markdown-mode
:defer t
:autoload (markdown-preview))

(defun exordium-forge-markdown-preview ()
"Preview current buffer as a preview in a `markdown-mode' buffer would do."
Expand Down Expand Up @@ -139,24 +149,36 @@ USERNAME, AUTH, and HOST behave as for `ghub-request'."
(message "PR #%s is ready for review." number)
(user-error "Nothing at point that is a PR or mark failed")))

(use-package magit
:defer t
:bind
(:map magit-status-mode-map
("C-c C-d" . #'exordium-forge-mark-ready-for-rewiew)))
:hook
(forge-post-mode . (lambda ()
(set-fill-column 1000)))
:bind
(:map forge-post-mode-map
("C-c C-p" . #'exordium-forge-markdown-preview)
("C-c C-d" . #'exordium-forge-post-submit-draft)
:map magit-status-mode-map
("C-c C-d" . #'exordium-forge-mark-ready-for-rewiew)
("C-c C-p" . #'exordium-forge-markdown-preview)
("C-c C-d" . #'exordium-forge-post-submit-draft)
:map forge-topic-mode-map
("C-c C-d" . #'exordium-forge-mark-ready-for-rewiew)))
("C-c C-d" . #'exordium-forge-mark-ready-for-rewiew)))

(use-package forge
(use-package forge-db
:ensure forge
:functions (exordium-forge-cleanup-known-repositories--concat
exordium-forge-cleanup-known-repositories--question)
:commands (exordium-forge-cleanup-known-repositories)
exordium-forge-cleanup-known-repositories--question
exordium-forge-cleanup-known-repositories)
:autoload (forge-sql)
:init
(use-package async
:defer t
:autoload (async-inject-variables))
(use-package magit-mode
:ensure magit
:defer t
:autoload (magit-refresh))

(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
38 changes: 18 additions & 20 deletions modules/init-git.el
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ These are restored by `exordium-magit-quit-session'.")
exordium--magit-fullscreen
exordium-projectile-add-known-project)

:autoload (magit-refresh ; required by init-forge.el
magit-git-string ; required by init-forge.el
magit-save-repository-buffers) ; required by init-flb-mode.el

:defines (magit-last-seen-setup-instructions)
:init
(defun exordium-projectile-add-known-project
Expand Down Expand Up @@ -119,13 +115,13 @@ with `exordium-magit-quit-session'."

:bind
(:map exordium-git-map
("s" . #'magit-status)
("l" . #'exordium-magit-log)
("f" . #'exordium-magit-log-buffer)
("b" . #'exordium-magit-blame)
("c" . #'magit-clone)
("s" . #'magit-status)
("l" . #'exordium-magit-log)
("f" . #'exordium-magit-log-buffer)
("b" . #'exordium-magit-blame)
("c" . #'magit-clone)
:map magit-status-mode-map
("q" . #'exordium-magit-quit-session))
("q" . #'exordium-magit-quit-session))

:hook
(magit-status-mode . exordium-magit--dont-insert-symbol-for-search)
Expand Down Expand Up @@ -221,7 +217,7 @@ with `exordium-magit-quit-session'."
:defer t
:bind
(:map smerge-mode-map
("C-c ^ d" . #'exordium-smerge-dispatch)))
("C-c ^ d" . #'exordium-smerge-dispatch)))

(defun exordium-smerge-dispatch-maybe ()
"Display `exordium-smerge-dispatch' when buffer is in `smerge-mode'."
Expand Down Expand Up @@ -268,12 +264,12 @@ with `exordium-magit-quit-session'."
:diminish git-gutter-mode
:bind
(:map exordium-git-map
("<down>" . #'git-gutter:next-hunk)
("n" . #'git-gutter:next-hunk)
("<up>" . #'git-gutter:previous-hunk)
("p" . #'git-gutter:previous-hunk)
("d" . #'git-gutter:popup-hunk)
("r" . #'git-gutter:revert-hunk))
("<down>" . #'git-gutter:next-hunk)
("n" . #'git-gutter:next-hunk)
("<up>" . #'git-gutter:previous-hunk)
("p" . #'git-gutter:previous-hunk)
("d" . #'git-gutter:popup-hunk)
("r" . #'git-gutter:revert-hunk))
:config
(exordium-global-git-gutter-mode t)

Expand Down Expand Up @@ -315,7 +311,7 @@ with `exordium-magit-quit-session'."

(use-package ediff
:ensure nil
:commands (exordium-ediff-copy-both-to-C)
:functions (exordium-ediff-copy-both-to-C)
:autoload (ediff-copy-diff
ediff-get-region-contents)
:init
Expand All @@ -326,8 +322,10 @@ This command should be called form `ediff''s control buffer.
Adapted from:
http://stackoverflow.com/questions/9656311/conflict-resolution-with-emacs-ediff-how-can-i-take-the-changes-of-both-version"
(interactive
(let ((first-string (completing-read "First: " '("A" "B") nil t "A"))
(second-string (completing-read "Second: " '("A" "B") nil t "B")))
(let* ((first-string (completing-read "First: " '("A" "B") nil t "A"))
(second-string (completing-read "Second: " '("A" "B") nil t
(if (equal first-string "A")
"B" "A"))))
(list first-string second-string)))
(let ((first (or first "A"))
(second (or second "B")))
Expand Down
Loading

0 comments on commit 9402a66

Please sign in to comment.