dev: merge branch 'master' into emenel
This commit is contained in:
commit
e9b11dc6f4
22 changed files with 226 additions and 126 deletions
|
@ -604,8 +604,6 @@ current buffer."
|
|||
:hook (doom-first-buffer . smartparens-global-mode)
|
||||
:commands sp-pair sp-local-pair sp-with-modes sp-point-in-comment sp-point-in-string
|
||||
:config
|
||||
(add-to-list 'doom-point-in-string-functions 'sp-point-in-string)
|
||||
(add-to-list 'doom-point-in-comment-functions 'sp-point-in-comment)
|
||||
;; smartparens recognizes `slime-mrepl-mode', but not `sly-mrepl-mode', so...
|
||||
(add-to-list 'sp-lisp-modes 'sly-mrepl-mode)
|
||||
;; Load default smartparens rules for various languages
|
||||
|
|
|
@ -163,7 +163,12 @@
|
|||
|
||||
(defun doom-run-local-var-hooks-h ()
|
||||
"Run MODE-local-vars-hook after local variables are initialized."
|
||||
(unless (or doom-inhibit-local-var-hooks delay-mode-hooks)
|
||||
(unless (or doom-inhibit-local-var-hooks
|
||||
delay-mode-hooks
|
||||
;; Don't trigger local-vars hooks in temporary (internal) buffers
|
||||
(string-prefix-p
|
||||
" " (buffer-name (or (buffer-base-buffer)
|
||||
(current-buffer)))))
|
||||
(setq-local doom-inhibit-local-var-hooks t)
|
||||
(doom-run-hooks (intern-soft (format "%s-local-vars-hook" major-mode)))))
|
||||
|
||||
|
|
|
@ -302,6 +302,10 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
|||
(setq use-short-answers t)
|
||||
;; DEPRECATED: Remove when we drop 27.x support
|
||||
(advice-add #'yes-or-no-p :override #'y-or-n-p))
|
||||
;; HACK: By default, SPC = yes when `y-or-n-p' prompts you (and
|
||||
;; `y-or-n-p-use-read-key' is off). This seems too easy to hit by accident,
|
||||
;; especially with SPC as our default leader key.
|
||||
(define-key y-or-n-p-map " " nil)
|
||||
|
||||
;; Try to keep the cursor out of the read-only portions of the minibuffer.
|
||||
(setq minibuffer-prompt-properties '(read-only t intangible t cursor-intangible t face minibuffer-prompt))
|
||||
|
|
|
@ -355,9 +355,8 @@ without needing to check if they are available."
|
|||
|
||||
(defun doom--help-current-module-str ()
|
||||
(cond ((save-excursion
|
||||
(require 'smartparens)
|
||||
(ignore-errors
|
||||
(sp-beginning-of-sexp)
|
||||
(thing-at-point--beginning-of-sexp)
|
||||
(unless (eq (char-after) ?\()
|
||||
(backward-char))
|
||||
(let ((sexp (sexp-at-point)))
|
||||
|
|
|
@ -29,9 +29,10 @@
|
|||
;;;###autoload
|
||||
(defun doom-plist-merge (from-plist to-plist)
|
||||
"Non-destructively merge FROM-PLIST onto TO-PLIST"
|
||||
(let ((plist (copy-sequence from-plist)))
|
||||
(while plist
|
||||
(cl-callf plist-put to-plist (pop plist) (pop plist)))
|
||||
(let ((from-plist (copy-sequence from-plist))
|
||||
(to-plist (copy-sequence to-plist)))
|
||||
(while from-plist
|
||||
(cl-callf plist-put to-plist (pop from-plist) (pop from-plist)))
|
||||
to-plist))
|
||||
|
||||
;;;###autoload
|
||||
|
|
|
@ -1,18 +1,32 @@
|
|||
;;; lisp/lib/text.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defvar doom-point-in-comment-functions ()
|
||||
"List of functions to run to determine if point is in a comment.
|
||||
(defvar-local doom--sppss-memo-last-point nil)
|
||||
(defvar-local doom--sppss-memo-last-result nil)
|
||||
|
||||
Each function takes one argument: the position of the point. Stops on the first
|
||||
function to return non-nil. Used by `doom-point-in-comment-p'.")
|
||||
(defun doom--sppss-memo-reset-h (&rest _ignored)
|
||||
"Reset memoization as a safety precaution.
|
||||
|
||||
IGNORED is a dummy argument used to eat up arguments passed from
|
||||
the hook where this is executed."
|
||||
(setq doom--sppss-memo-last-point nil
|
||||
doom--sppss-memo-last-result nil))
|
||||
|
||||
;;;###autoload
|
||||
(defvar doom-point-in-string-functions ()
|
||||
"List of functions to run to determine if point is in a string.
|
||||
(defun doom-syntax-ppss (&optional p)
|
||||
"Memoize the last result of `syntax-ppss'.
|
||||
|
||||
Each function takes one argument: the position of the point. Stops on the first
|
||||
function to return non-nil. Used by `doom-point-in-string-p'.")
|
||||
P is the point at which we run `syntax-ppss'"
|
||||
(let ((p (or p (point)))
|
||||
(mem-p doom--sppss-memo-last-point))
|
||||
(if (and (eq p (nth 0 mem-p))
|
||||
(eq (point-min) (nth 1 mem-p))
|
||||
(eq (point-max) (nth 2 mem-p)))
|
||||
doom--sppss-memo-last-result
|
||||
;; Add hook to reset memoization if necessary
|
||||
(unless doom--sppss-memo-last-point
|
||||
(add-hook 'before-change-functions #'doom--sppss-memo-reset-h t t))
|
||||
(setq doom--sppss-memo-last-point (list p (point-min) (point-max))
|
||||
doom--sppss-memo-last-result (syntax-ppss p)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-surrounded-p (pair &optional inline balanced)
|
||||
|
@ -40,22 +54,49 @@ lines, above and below, with only whitespace in between."
|
|||
(= (- pt nbeg) (- nend pt))))))))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-point-in-comment-p (&optional pos)
|
||||
"Return non-nil if POS is in a comment.
|
||||
POS defaults to the current position."
|
||||
(let ((pos (or pos (point))))
|
||||
(if doom-point-in-comment-functions
|
||||
(run-hook-with-args-until-success 'doom-point-in-comment-functions pos)
|
||||
(nth 4 (syntax-ppss pos)))))
|
||||
(defun doom-point-in-comment-p (&optional pt)
|
||||
"Return non-nil if point is in a comment.
|
||||
PT defaults to the current position."
|
||||
(let ((pt (or pt (point))))
|
||||
(ignore-errors
|
||||
(save-excursion
|
||||
;; We cannot be in a comment if we are inside a string
|
||||
(unless (nth 3 (doom-syntax-ppss pt))
|
||||
(or (nth 4 (doom-syntax-ppss pt))
|
||||
;; this also test opening and closing comment delimiters... we
|
||||
;; need to chack that it is not newline, which is in "comment
|
||||
;; ender" class in elisp-mode, but we just want it to be treated
|
||||
;; as whitespace
|
||||
(and (< pt (point-max))
|
||||
(memq (char-syntax (char-after pt)) '(?< ?>))
|
||||
(not (eq (char-after pt) ?\n)))
|
||||
;; we also need to test the special syntax flag for comment
|
||||
;; starters and enders, because `syntax-ppss' does not yet know if
|
||||
;; we are inside a comment or not (e.g. / can be a division or
|
||||
;; comment starter...).
|
||||
(when-let ((s (car (syntax-after pt))))
|
||||
(or (and (/= 0 (logand (ash 1 16) s))
|
||||
(nth 4 (syntax-ppss (+ pt 2))))
|
||||
(and (/= 0 (logand (ash 1 17) s))
|
||||
(nth 4 (syntax-ppss (+ pt 1))))
|
||||
(and (/= 0 (logand (ash 1 18) s))
|
||||
(nth 4 (syntax-ppss (- pt 1))))
|
||||
(and (/= 0 (logand (ash 1 19) s))
|
||||
(nth 4 (syntax-ppss (- pt 2))))))))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-point-in-string-p (&optional pos)
|
||||
"Return non-nil if POS is in a string."
|
||||
;; REVIEW Should we cache `syntax-ppss'?
|
||||
(let ((pos (or pos (point))))
|
||||
(if doom-point-in-string-functions
|
||||
(run-hook-with-args-until-success 'doom-point-in-string-functions pos)
|
||||
(nth 3 (syntax-ppss pos)))))
|
||||
(defun doom-point-in-string-p (&optional pt)
|
||||
"Return non-nil if point is inside string.
|
||||
|
||||
This function actually returns the 3rd element of `syntax-ppss'
|
||||
which can be a number if the string is delimited by that
|
||||
character or t if the string is delimited by general string
|
||||
fences.
|
||||
|
||||
If optional argument PT is present test this instead of point."
|
||||
(ignore-errors
|
||||
(save-excursion
|
||||
(nth 3 (doom-syntax-ppss pt)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-point-in-string-or-comment-p (&optional pos)
|
||||
|
|
|
@ -6,13 +6,17 @@
|
|||
(add-hook! 'doom-load-theme-hook
|
||||
(defun doom-apply-customized-faces-h ()
|
||||
"Run `doom-customize-theme-hook'."
|
||||
(run-hooks 'doom-customize-theme-hook)))
|
||||
(letf! ((#'custom--should-apply-setting #'ignore)
|
||||
(defun custom-push-theme (prop symbol theme mode &optional value)
|
||||
(funcall custom-push-theme prop symbol theme mode value)
|
||||
(if (facep symbol) (face-spec-set symbol value t))))
|
||||
(run-hooks 'doom-customize-theme-hook))))
|
||||
|
||||
(defun doom--custom-theme-set-face (spec)
|
||||
(defun doom--normalize-face-spec (spec)
|
||||
(cond ((listp (car spec))
|
||||
(cl-loop for face in (car spec)
|
||||
collect
|
||||
(car (doom--custom-theme-set-face (cons face (cdr spec))))))
|
||||
(car (doom--normalize-face-spec (cons face (cdr spec))))))
|
||||
((keywordp (cadr spec))
|
||||
`((,(car spec) ((t ,(cdr spec))))))
|
||||
(`((,(car spec) ,(cdr spec))))))
|
||||
|
@ -27,13 +31,12 @@ all themes. It will apply to all themes once they are loaded."
|
|||
(let ((fn (gensym "doom--customize-themes-h-")))
|
||||
`(progn
|
||||
(defun ,fn ()
|
||||
(let (custom--inhibit-theme-enable)
|
||||
(dolist (theme (ensure-list (or ,theme 'user)))
|
||||
(when (or (eq theme 'user)
|
||||
(custom-theme-enabled-p theme))
|
||||
(dolist (theme (ensure-list (or ,theme 'user)))
|
||||
(if (or (eq theme 'user)
|
||||
(custom-theme-enabled-p theme))
|
||||
(apply #'custom-theme-set-faces theme
|
||||
(mapcan #'doom--custom-theme-set-face
|
||||
(list ,@specs)))))))
|
||||
(mapcan #'doom--normalize-face-spec
|
||||
(list ,@specs))))))
|
||||
;; Apply the changes immediately if the user is using the default theme
|
||||
;; or the theme has already loaded. This allows you to evaluate these
|
||||
;; macros on the fly and customize your faces iteratively.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue