diff options
Diffstat (limited to 'lisp/emacs-lisp/smie.el')
-rw-r--r-- | lisp/emacs-lisp/smie.el | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el index d0c6cac79fa..f2163b243ee 100644 --- a/lisp/emacs-lisp/smie.el +++ b/lisp/emacs-lisp/smie.el @@ -533,9 +533,9 @@ PREC2 is a table as returned by `smie-precs->prec2' or (setq y (cons nil (cons nil nil))) (push (cons (cdr k) y) table)) (pcase v - (`= (push (cons x y) eqs)) - (`< (push (cons x y) csts)) - (`> (push (cons y x) csts)) + ('= (push (cons x y) eqs)) + ('< (push (cons x y) csts)) + ('> (push (cons y x) csts)) (_ (error "SMIE error: prec2 has %S↦%S which ∉ {<,+,>}" k v)))))) prec2) @@ -612,8 +612,8 @@ PREC2 is a table as returned by `smie-precs->prec2' or (dolist (x (gethash :smie-open/close-alist prec2)) (let* ((token (car x)) (cons (pcase (cdr x) - (`closer (cddr (assoc token table))) - (`opener (cdr (assoc token table)))))) + ('closer (cddr (assoc token table))) + ('opener (cdr (assoc token table)))))) ;; `cons' can be nil for openers/closers which only contain ;; "atomic" elements. (when cons @@ -1446,9 +1446,9 @@ in order to figure out the indentation of some other (further down) point." (and (smie-indent--bolp) (save-excursion (comment-normalize-vars) - (re-search-forward (concat comment-start-skip + (re-search-forward (concat "\\(?:" comment-start-skip "\\)" "fixindent" - comment-end-skip) + "\\(?:" comment-end-skip "\\)") ;; 1+ to account for the \n comment termination. (1+ (line-end-position)) t)) (current-column))) @@ -1648,11 +1648,33 @@ should not be computed on the basis of the following token." (let ((ppss (syntax-ppss))) (save-excursion (forward-line -1) - (if (<= (point) (nth 8 ppss)) - (progn (goto-char (1+ (nth 8 ppss))) (current-column)) - (skip-chars-forward " \t") - (if (looking-at (regexp-quote continue)) - (current-column)))))))) + (let ((start (nth 8 ppss))) + (if (<= (point) start) + (progn + (goto-char start) + (if (not (and comment-start-skip + (looking-at comment-start-skip))) + (forward-char 1) + (goto-char (match-end 0)) + (skip-chars-backward " \t") + ;; Try to align the first char of the comment-continue + ;; with the second char of the comment-start or the + ;; first char if the comment-start is made of + ;; a single char. E.g. + ;; + ;; /* foo + ;; * bar */ + ;; + ;; but + ;; + ;; { foo + ;; | bar } + (goto-char (if (eq (point) (1+ start)) + start (1+ start)))) + (current-column)) + (skip-chars-forward " \t") + (if (looking-at (regexp-quote continue)) + (current-column))))))))) (defun smie-indent-comment-close () (and (boundp 'comment-end-skip) @@ -1856,9 +1878,9 @@ KEYWORDS are additional arguments, which can use the following keywords: (let ((k (pop keywords)) (v (pop keywords))) (pcase k - (`:forward-token + (:forward-token (set (make-local-variable 'smie-forward-token-function) v)) - (`:backward-token + (:backward-token (set (make-local-variable 'smie-backward-token-function) v)) (_ (message "smie-setup: ignoring unknown keyword %s" k))))) (let ((ca (cdr (assq :smie-closer-alist grammar)))) |