From: Noam Postavsky Date: Thu, 6 Jul 2017 12:52:24 +0000 (-0400) Subject: Fix lisp-comment-indent for single-semicolon case X-Git-Tag: emacs-26.0.90~519^2~6 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=386918f0b807116051facbe51a2bee342de37841;p=emacs.git Fix lisp-comment-indent for single-semicolon case * lisp/emacs-lisp/lisp-mode.el (lisp-comment-indent): Only check for open paren if we're looking at multiple comment characters. * test/lisp/emacs-lisp/lisp-mode-tests.el (lisp-comment-indent-1) (lisp-comment-indent-2): New tests. --- diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 985b7513a3b..fa25a0c3975 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -738,12 +738,14 @@ or to switch back to an existing one." (defun lisp-comment-indent () "Like `comment-indent-default', but don't put space after open paren." - (let ((pt (point))) - (skip-syntax-backward " ") - (if (eq (preceding-char) ?\() - (cons (current-column) (current-column)) - (goto-char pt) - (comment-indent-default)))) + (or (when (looking-at "\\s<\\s<") + (let ((pt (point))) + (skip-syntax-backward " ") + (if (eq (preceding-char) ?\() + (cons (current-column) (current-column)) + (goto-char pt) + nil))) + (comment-indent-default))) (define-obsolete-function-alias 'lisp-mode-auto-fill 'do-auto-fill "23.1") diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el index 582041cfc2d..cc196beea23 100644 --- a/test/lisp/emacs-lisp/lisp-mode-tests.el +++ b/test/lisp/emacs-lisp/lisp-mode-tests.el @@ -198,6 +198,32 @@ Expected initialization file: `%s'\" (indent-region (point-min) (point-max)) (should (equal (buffer-string) correct))))) +(ert-deftest lisp-comment-indent-1 () + (with-temp-buffer + (insert "\ +\(let ( ;sf + (x 3)) + 4)") + (let ((indent-tabs-mode nil) + (correct (buffer-string))) + (emacs-lisp-mode) + (goto-char (point-min)) + (comment-indent) + (should (equal (buffer-string) correct))))) + +(ert-deftest lisp-comment-indent-2 () + (with-temp-buffer + (insert "\ +\(let (;;sf + (x 3)) + 4)") + (let ((indent-tabs-mode nil) + (correct (buffer-string))) + (emacs-lisp-mode) + (goto-char (point-min)) + (comment-indent) + (should (equal (buffer-string) correct))))) + (provide 'lisp-mode-tests) ;;; lisp-mode-tests.el ends here