Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/doomemacs/doomemacs into …
Browse files Browse the repository at this point in the history
…nano-doom
  • Loading branch information
HyunggyuJang committed Apr 29, 2024
2 parents 6bd0101 + 9620bb4 commit e7470ba
Show file tree
Hide file tree
Showing 24 changed files with 199 additions and 191 deletions.
2 changes: 1 addition & 1 deletion lisp/cli/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ list remains lean."
(setq want-native-compile nil))
(and (or want-byte-compile want-native-compile)
(or (file-newer-than-file-p repo-dir build-dir)
(file-exists-p (straight--modified-dir (or local-repo package)))
(file-exists-p (straight--modified-dir package))
(cl-loop with outdated = nil
for file in (doom-files-in build-dir :match "\\.el$" :full t)
if (or (if want-byte-compile (doom-packages--elc-file-outdated-p file))
Expand Down
43 changes: 22 additions & 21 deletions lisp/doom-editor.el
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ tell you about it. Very annoying. This prevents that."
(letf! ((#'sit-for #'ignore))
(apply fn args)))

;; HACK Emacs generates long file paths for its auto-save files; long =
;; `auto-save-list-file-prefix' + `buffer-file-name'. If too long, the
;; filesystem will murder your family. To appease it, I compress
;; `buffer-file-name' to a stable 40 characters.
;; TODO PR this upstream; should be a universal issue!
;; HACK: Emacs generates long file paths for its auto-save files; long =
;; `auto-save-list-file-prefix' + `buffer-file-name'. If too long, the
;; filesystem will murder your family. To appease it, I compress
;; `buffer-file-name' to a stable 40 characters.
;; TODO: PR this upstream; should be a universal issue!
(defadvice! doom-make-hashed-auto-save-file-name-a (fn)
"Compress the auto-save file name so paths don't get too long."
:around #'make-auto-save-file-name
Expand All @@ -156,7 +156,7 @@ tell you about it. Very annoying. This prevents that."
;; Don't do anything for non-file-visiting buffers. Names
;; generated for those are short enough already.
(null buffer-file-name)
;; If an alternate handler exists for this path, bow out. Most of
;; If an alternate handler exists for this path, bow out. Most of
;; them end up calling `make-auto-save-file-name' again anyway, so
;; we still achieve this advice's ultimate goal.
(find-file-name-handler buffer-file-name
Expand All @@ -165,8 +165,8 @@ tell you about it. Very annoying. This prevents that."
(sha1 buffer-file-name))))
(funcall fn)))

;; HACK ...does the same for Emacs backup files, but also packages that use
;; `make-backup-file-name-1' directly (like undo-tree).
;; HACK: ...does the same for Emacs backup files, but also packages that use
;; `make-backup-file-name-1' directly (like undo-tree).
(defadvice! doom-make-hashed-backup-file-name-a (fn file)
"A few places use the backup file name so paths don't get too long."
:around #'make-backup-file-name-1
Expand All @@ -191,7 +191,7 @@ tell you about it. Very annoying. This prevents that."

;; Favor spaces over tabs. Pls dun h8, but I think spaces (and 4 of them) is a
;; more consistent default than 8-space tabs. It can be changed on a per-mode
;; basis anyway (and is, where tabs are the canonical style, like go-mode).
;; basis anyway (and is, where tabs are the canonical style, like `go-mode').
(setq-default indent-tabs-mode nil
tab-width 4)

Expand Down Expand Up @@ -269,19 +269,20 @@ tell you about it. Very annoying. This prevents that."
;; Only prompts for confirmation when buffer is unsaved.
revert-without-query (list "."))

;; `auto-revert-mode' and `global-auto-revert-mode' would, normally, abuse the
;; heck out of file watchers _or_ aggressively poll your buffer list every X
;; seconds. Too many watchers can grind Emacs to a halt if you preform
;; expensive or batch processes on files outside of Emacs (e.g. their mtime
;; changes), and polling your buffer list is terribly inefficient as your
;; buffer list grows into the hundreds.
;; PERF: `auto-revert-mode' and `global-auto-revert-mode' would, normally,
;; abuse the heck out of file watchers _or_ aggressively poll your buffer
;; list every X seconds. Too many watchers can grind Emacs to a halt if you
;; preform expensive or batch processes on files outside of Emacs (e.g.
;; their mtime changes), and polling your buffer list is terribly
;; inefficient as your buffer list grows into the hundreds.
;;
;; Doom does this lazily instead. i.e. All visible buffers are reverted
;; immediately when a) a file is saved or b) Emacs is refocused (after using
;; another app). Meanwhile, buried buffers are reverted only when they are
;; switched to. This way, Emacs only ever has to operate on, at minimum, a
;; single buffer and, at maximum, ~10 buffers (after all, when do you ever
;; have more than 10 windows in any single frame?).
;; Doom does this lazily instead. i.e. All visible buffers are reverted
;; immediately when a) a file is saved or b) Emacs is refocused (after using
;; another app). Meanwhile, buried buffers are reverted only when they are
;; switched to. This way, Emacs only ever has to operate on, at minimum, a
;; single buffer and, at maximum, ~10 x F buffers, where F = number of open
;; frames (after all, when do you ever have more than 10 windows in any
;; single frame?).
(defun doom-auto-revert-buffer-h ()
"Auto revert current buffer, if necessary."
(unless (or auto-revert-mode (active-minibuffer-window))
Expand Down
28 changes: 14 additions & 14 deletions lisp/doom-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -246,29 +246,29 @@ TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions."
(fset
fn (lambda (&rest _)
;; Only trigger this after Emacs has initialized.
(when (and after-init-time
(not running?)
(when (and (not running?)
(not (doom-context-p 'init))
(or (daemonp)
;; In some cases, hooks may be lexically unset to
;; inhibit them during expensive batch operations on
;; buffers (such as when processing buffers
;; internally). In these cases we should assume this
;; hook wasn't invoked interactively.
;; internally). In that case assume this hook was
;; invoked non-interactively.
(and (boundp hook)
(symbol-value hook))))
(setq running? t) ; prevent infinite recursion
(doom-run-hooks hook-var)
(set hook-var nil))))
(cond ((daemonp)
;; In a daemon session we don't need all these lazy loading
;; shenanigans. Just load everything immediately.
(add-hook 'after-init-hook fn 'append))
((eq hook 'find-file-hook)
;; Advise `after-find-file' instead of using `find-file-hook'
;; because the latter is triggered too late (after the file has
;; opened and modes are all set up).
(advice-add 'after-find-file :before fn '((depth . -101))))
((add-hook hook fn -101)))
(when (daemonp)
;; In a daemon session we don't need all these lazy loading shenanigans.
;; Just load everything immediately.
(add-hook 'server-after-make-frame-hook fn 'append))
(if (eq hook 'find-file-hook)
;; Advise `after-find-file' instead of using `find-file-hook' because
;; the latter is triggered too late (after the file has opened and
;; modes are all set up).
(advice-add 'after-find-file :before fn '((depth . -101)))
(add-hook hook fn -101))
fn)))

(defun doom-compile-functions (&rest fns)
Expand Down
2 changes: 1 addition & 1 deletion lisp/doom-packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ uses a straight or package.el command directly).")
(alist-get 'straight packages)
(doom--ensure-straight recipe pin))
(doom--ensure-core-packages
(seq-filter (fn! (eq (plist-get % :type) 'core))
(seq-filter (fn! (eq (plist-get (cdr %) :type) 'core))
packages)))))

(defun doom-initialize-packages (&optional force-p)
Expand Down
40 changes: 23 additions & 17 deletions lisp/doom-start.el
Original file line number Diff line number Diff line change
Expand Up @@ -101,34 +101,40 @@
;;; Disable UI elements early
;; PERF,UI: Doom strives to be keyboard-centric, so I consider these UI elements
;; clutter. Initializing them also costs a morsel of startup time. What's
;; more, the menu bar exposes functionality that Doom doesn't endorse. Perhaps
;; one day Doom will support these, but today is not that day. By disabling
;; them early, we save Emacs some time.
;; more, the menu bar exposes functionality that Doom doesn't endorse or
;; police. Perhaps one day Doom will support these, but today is not that day.
;; By disabling them early, we save Emacs some time.

;; HACK: I intentionally avoid calling `menu-bar-mode', `tool-bar-mode', and
;; `scroll-bar-mode' because their manipulation of frame parameters can
;; trigger/queue a superfluous (and expensive, depending on the window system)
;; frame redraw at startup.
;; frame redraw at startup. The variables must be set to `nil' as well so
;; users don't have to call the functions twice to re-enable them.
(push '(menu-bar-lines . 0) default-frame-alist)
(push '(tool-bar-lines . 0) default-frame-alist)
(push '(vertical-scroll-bars) default-frame-alist)
;; And set these to nil so users don't have to toggle the modes twice to
;; reactivate them.
(setq menu-bar-mode nil
tool-bar-mode nil
scroll-bar-mode nil)
;; FIX: On MacOS, disabling the menu bar makes MacOS treat Emacs as a
;; non-application window -- which means it doesn't automatically capture
;; focus when it is started, among other things, so enable the menu-bar for
;; GUI frames, but keep it disabled in terminal frames because there it
;; unavoidably activates an ugly, in-frame menu bar.
(eval-when! doom--system-macos-p
(add-hook! '(window-setup-hook after-make-frame-functions)
(defun doom-restore-menu-bar-in-gui-frames-h (&optional frame)
(when-let (frame (or frame (selected-frame)))
(when (display-graphic-p frame)
(set-frame-parameter frame 'menu-bar-lines 1))))))

;; HACK: The menu-bar needs special treatment on MacOS. On Linux and Windows
;; (and TTY frames in MacOS), the menu-bar takes up valuable in-frame real
;; estate -- so we disable it -- but on MacOS (GUI frames only) the menu bar
;; lives outside of the frame, on the MacOS menu bar, which is acceptable, but
;; disabling Emacs' menu-bar also makes MacOS treat Emacs GUI frames like
;; non-application windows (e.g. it won't capture focus on activation, among
;; other things), so the menu-bar should be preserved there.
;;
(when doom--system-macos-p
;; NOTE: The correct way to disable this hack is to toggle `menu-bar-mode' (or
;; put it on a hook). Don't try to undo the hack below, as it may change
;; without warning, but will always respect `menu-bar-mode'.
(setcdr (assq 'menu-bar-lines default-frame-alist) 'tty)
(add-hook! 'after-make-frame-functions
(defun doom--init-menu-bar-on-macos-h (&optional frame)
(if (eq (frame-parameter frame 'menu-bar-lines) 'tty)
(set-frame-parameter frame 'menu-bar-lines
(if (display-graphic-p frame) 1 0))))))

;;; Encodings
;; Contrary to what many Emacs users have in their configs, you don't need more
Expand Down
73 changes: 37 additions & 36 deletions lisp/doom-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -497,42 +497,43 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original

(defun doom-init-fonts-h (&optional _reload)
;; "Loads `doom-font', `doom-serif-font', and `doom-variable-pitch-font'."
;; (let ((this-frame (selected-frame)))
;; (dolist (map `((default . ,doom-font)
;; (fixed-pitch . ,doom-font)
;; (fixed-pitch-serif . ,doom-serif-font)
;; (variable-pitch . ,doom-variable-pitch-font)))
;; (condition-case e
;; (when-let* ((face (car map))
;; (font (cdr map)))
;; (dolist (frame (frame-list))
;; (when (display-multi-font-p frame)
;; (set-face-attribute face frame
;; :width 'normal :weight 'normal
;; :slant 'normal :font font)))
;; (custom-push-theme
;; 'theme-face face 'user 'set
;; (let* ((base-specs (cadr (assq 'user (get face 'theme-face))))
;; (base-specs (or base-specs '((t nil))))
;; (attrs '(:family :foundry :slant :weight :height :width))
;; (new-specs nil))
;; (dolist (spec base-specs)
;; ;; Each SPEC has the form (DISPLAY ATTRIBUTE-PLIST)
;; (let ((display (car spec))
;; (plist (copy-tree (nth 1 spec))))
;; ;; Alter only DISPLAY conditions matching this frame.
;; (when (or (memq display '(t default))
;; (face-spec-set-match-display display this-frame))
;; (dolist (attr attrs)
;; (setq plist (plist-put plist attr (face-attribute face attr)))))
;; (push (list display plist) new-specs)))
;; (nreverse new-specs)))
;; (put face 'face-modified nil))
;; ('error
;; (ignore-errors (doom--reset-inhibited-vars-h))
;; (if (string-prefix-p "Font not available" (error-message-string e))
;; (signal 'doom-font-error (list (font-get (cdr map) :family)))
;; (signal (car e) (cdr e)))))))
;; (let ((initialized-frames (unless reload (get 'doom-font 'initialized-frames))))
;; (dolist (frame (if reload (frame-list) (list (selected-frame))))
;; (unless (member frame initialized-frames)
;; (dolist (map `((default . ,doom-font)
;; (fixed-pitch . ,doom-font)
;; (fixed-pitch-serif . ,doom-serif-font)
;; (variable-pitch . ,doom-variable-pitch-font)))
;; (condition-case e
;; (when-let* ((face (car map))
;; (font (cdr map)))
;; (when (display-multi-font-p frame)
;; (set-face-attribute face frame
;; :width 'normal :weight 'normal
;; :slant 'normal :font font))
;; (custom-push-theme
;; 'theme-face face 'user 'set
;; (let* ((base-specs (cadr (assq 'user (get face 'theme-face))))
;; (base-specs (or base-specs '((t nil))))
;; (attrs '(:family :foundry :slant :weight :height :width))
;; (new-specs nil))
;; (dolist (spec base-specs)
;; (let ((display (car spec))
;; (plist (copy-tree (nth 1 spec))))
;; (when (or (memq display '(t default))
;; (face-spec-set-match-display display frame))
;; (dolist (attr attrs)
;; (setq plist (plist-put plist attr (face-attribute face attr)))))
;; (push (list display plist) new-specs)))
;; (nreverse new-specs)))
;; (put face 'face-modified nil))
;; ('error
;; (ignore-errors (doom--reset-inhibited-vars-h))
;; (if (string-prefix-p "Font not available" (error-message-string e))
;; (signal 'doom-font-error (list (font-get (cdr map) :family)))
;; (signal (car e) (cdr e))))))
;; (put 'doom-font 'initialized-frames
;; (cons frame (cl-delete-if-not #'frame-live-p initialized-frames))))))
(when (fboundp 'set-fontset-font)
(set-fontset-font t 'symbol "Apple Symbols")
(set-fontset-font t 'unicode "Apple Color Emoji")
Expand Down
12 changes: 10 additions & 2 deletions lisp/lib/files.el
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,17 @@ which case it will save it without prompting."
(defun doom/remove-recent-file (file)
"Remove FILE from your recently-opened-files list."
(interactive
(list (completing-read "Remove recent file: " recentf-list
(list (completing-read "Remove recent file: "
(lambda (string predicate action)
(if (eq action 'metadata)
'(metadata
(display-sort-function . identity)
(cycle-sort-function . identity)
(category . file))
(complete-with-action
action recentf-list string predicate)))
nil t)))
(setq recentf-list (delete file recentf-list))
(setq recentf-list (delete (recentf-expand-file-name file) recentf-list))
(recentf-save-list)
(message "Removed %S from `recentf-list'" (abbreviate-file-name file)))

Expand Down
4 changes: 0 additions & 4 deletions modules/app/everywhere/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
;; buffers anyway.
(setq-hook! 'emacs-everywhere-init-hooks doom-inhibit-local-var-hooks t)

;; REVIEW: Fixes tecosaur/emacs-everywhere#75. Remove when dealt with
;; upstream.
(define-key emacs-everywhere-mode-map "\C-c\C-c" #'emacs-everywhere-finish)

(after! doom-modeline
(doom-modeline-def-segment emacs-everywhere
(concat
Expand Down
22 changes: 0 additions & 22 deletions modules/checkers/spell/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -135,28 +135,6 @@
prog-mode-hook)
#'spell-fu-mode))
:config
;; TODO PR this fix upstream!
(defadvice! +spell--fix-face-detection-a (fn &rest args)
"`spell-fu--faces-at-point' uses face detection that won't penetrary
overlays (like `hl-line'). This makes `spell-fu-faces-exclude' demonstrably less
useful when it'll still spellcheck excluded faces on any line that `hl-line' is
displayed on, even momentarily."
:around #'spell-fu--faces-at-point
(letf! (defun get-char-property (pos prop &optional obj)
(or (plist-get (text-properties-at pos) prop)
(funcall get-char-property pos prop obj)))
(apply fn args)))

(defadvice! +spell--create-word-dict-a (_word words-file _action)
"Prevent `spell-fu--word-add-or-remove' from throwing non-existant
directory errors when writing a personal dictionary file (by creating the
directory first)."
:before #'spell-fu--word-add-or-remove
(unless (file-exists-p words-file)
(make-directory (file-name-directory words-file) t)
(with-temp-file words-file
(insert (format "personal_ws-1.1 %s 0\n" ispell-dictionary)))))

(add-hook! 'spell-fu-mode-hook
(defun +spell-init-excluded-faces-h ()
"Set `spell-fu-faces-exclude' according to `+spell-excluded-faces-alist'."
Expand Down
Loading

0 comments on commit e7470ba

Please sign in to comment.