Remove hard dependency on sp-point-in-* predicates
This commit is contained in:
parent
060636966f
commit
7c273ad173
2 changed files with 10 additions and 4 deletions
|
@ -1,11 +1,13 @@
|
||||||
;;; core/autoload/text.el -*- lexical-binding: t; -*-
|
;;; core/autoload/text.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
(defvar doom-point-in-comment-functions ()
|
(defvar doom-point-in-comment-functions ()
|
||||||
"List of functions to run to determine if point is in a comment.
|
"List of functions to run to determine if point is in a comment.
|
||||||
|
|
||||||
Each function takes one argument: the position of the point. Stops on the first
|
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'.")
|
function to return non-nil. Used by `doom-point-in-comment-p'.")
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
(defvar doom-point-in-string-functions ()
|
(defvar doom-point-in-string-functions ()
|
||||||
"List of functions to run to determine if point is in a string.
|
"List of functions to run to determine if point is in a string.
|
||||||
|
|
||||||
|
@ -42,16 +44,18 @@ lines, above and below, with only whitespace in between."
|
||||||
"Return non-nil if POS is in a comment.
|
"Return non-nil if POS is in a comment.
|
||||||
POS defaults to the current position."
|
POS defaults to the current position."
|
||||||
(let ((pos (or pos (point))))
|
(let ((pos (or pos (point))))
|
||||||
(or (run-hook-with-args-until-success 'doom-point-in-comment-functions pos)
|
(if doom-point-in-comment-functions
|
||||||
(sp-point-in-comment pos))))
|
(run-hook-with-args-until-success 'doom-point-in-comment-functions pos)
|
||||||
|
(nth 4 (syntax-ppss pos)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-point-in-string-p (&optional pos)
|
(defun doom-point-in-string-p (&optional pos)
|
||||||
"Return non-nil if POS is in a string."
|
"Return non-nil if POS is in a string."
|
||||||
;; REVIEW Should we cache `syntax-ppss'?
|
;; REVIEW Should we cache `syntax-ppss'?
|
||||||
(let ((pos (or pos (point))))
|
(let ((pos (or pos (point))))
|
||||||
(or (run-hook-with-args-until-success 'doom-point-in-string-functions pos)
|
(if doom-point-in-string-functions
|
||||||
(sp-point-in-string pos))))
|
(run-hook-with-args-until-success 'doom-point-in-string-functions pos)
|
||||||
|
(nth 3 (syntax-ppss pos)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-point-in-string-or-comment-p (&optional pos)
|
(defun doom-point-in-string-or-comment-p (&optional pos)
|
||||||
|
|
|
@ -540,6 +540,8 @@ files, so this replace calls to `pp' with the much faster `prin1'."
|
||||||
:hook (doom-first-buffer . smartparens-global-mode)
|
:hook (doom-first-buffer . smartparens-global-mode)
|
||||||
:commands sp-pair sp-local-pair sp-with-modes sp-point-in-comment sp-point-in-string
|
:commands sp-pair sp-local-pair sp-with-modes sp-point-in-comment sp-point-in-string
|
||||||
:config
|
: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...
|
;; smartparens recognizes `slime-mrepl-mode', but not `sly-mrepl-mode', so...
|
||||||
(add-to-list 'sp-lisp-modes 'sly-mrepl-mode)
|
(add-to-list 'sp-lisp-modes 'sly-mrepl-mode)
|
||||||
;; Load default smartparens rules for various languages
|
;; Load default smartparens rules for various languages
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue