Last active
September 30, 2019 14:09
-
-
Save clemera/ea0cb473b03f6b6655018665077cfbe4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; print immediately but only after certain commands | |
(setq eldoc-idle-delay 0) | |
(setq eldoc-print-after-edit t) | |
(add-hook 'eldoc-mode-hook | |
(defun eldoc--add-commands+ () | |
;; remove any preloaded commands | |
(setq eldoc-message-commands | |
(make-vector eldoc-message-commands-table-size 0)) | |
(eldoc-add-command 'eldoc-show-help+))) | |
(advice-add 'self-insert-command :after | |
(defun eldoc-after-space+ (&rest _) | |
(when (and (eq last-input-event ?\s) | |
(not (in-string-or-comment+))) | |
(setq this-command 'eldoc-show-help+)))) | |
(advice-add 'electric-pair--insert :after #'eldoc-show-help+) | |
(global-set-key (kbd "S-SPC") | |
(defun eldoc-show-help+ (&rest _) | |
(interactive) | |
(setq this-command 'eldoc-show-help+))) | |
;; helpers | |
(defsubst in-string-p+ (&optional pos) | |
(in-ppss-p+ 'string pos)) | |
(defsubst in-comment-p+ (&optional pos) | |
(in-ppss-p+ 'comment pos)) | |
(defun in-string-or-comment+ (&optional pos) | |
(or (in-string-p+ pos) | |
(in-comment-p+ pos))) | |
(defun in-ppss-p+ (type &optional pos) | |
"Type is comment or string" | |
(let* ((ppss (syntax-ppss pos)) | |
(beg nil) | |
(reg (cond ((and (eq type 'string) | |
(setq beg (nth 8 ppss))) | |
(cons beg (nth 3 ppss))) | |
((and (eq type 'comment) | |
(nth 4 ppss) | |
(setq beg (nth 8 ppss))) | |
(cons beg | |
(save-excursion | |
(goto-char beg) | |
(forward-comment 1) | |
(point))))))) | |
reg)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment