From 500dce5f4d2a08570177d9b1019fa922f07e8508 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 19 Jun 2014 21:05:40 -0400 Subject: [PATCH] * lisp/emacs-lisp/smie.el (smie--hanging-eolp-function): New var. (smie-indent--hanging-p): Use it. * lisp/progmodes/sh-script.el (sh-set-shell): Set it. Fixes: debbugs:17621 --- lisp/ChangeLog | 6 ++++++ lisp/emacs-lisp/smie.el | 14 ++++++++++---- lisp/progmodes/sh-script.el | 5 +++++ lisp/term/xterm.el | 4 ++-- test/indent/shell.sh | 6 +++++- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 51c7332a9a9..7fdc6478979 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2014-06-20 Stefan Monnier + + * emacs-lisp/smie.el (smie--hanging-eolp-function): New var. + (smie-indent--hanging-p): Use it. + * progmodes/sh-script.el (sh-set-shell): Set it (bug#17621). + 2014-06-20 Leo Liu * simple.el (read-quoted-char): Don't let help chars pop up help diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el index 3e40d37aacf..1a6011e712a 100644 --- a/lisp/emacs-lisp/smie.el +++ b/lisp/emacs-lisp/smie.el @@ -1155,6 +1155,15 @@ NUMBER offset by NUMBER, relative to a base token The functions whose name starts with \"smie-rule-\" are helper functions designed specifically for use in this function.") +(defvar smie--hanging-eolp-function + ;; FIXME: This is a quick hack for 24.4. Don't document it and replace with + ;; a well-defined function with a cleaner interface instead! + (lambda () + (skip-chars-forward " \t") + (or (eolp) + (and ;; (looking-at comment-start-skip) ;(bug#16041). + (forward-comment (point-max)))))) + (defalias 'smie-rule-hanging-p 'smie-indent--hanging-p) (defun smie-indent--hanging-p () "Return non-nil if the current token is \"hanging\". @@ -1168,10 +1177,7 @@ the beginning of a line." (not (eobp)) ;; Could be an open-paren. (forward-char 1)) - (skip-chars-forward " \t") - (or (eolp) - (and ;; (looking-at comment-start-skip) ;(bug#16041). - (forward-comment (point-max)))) + (funcall smie--hanging-eolp-function) (point)))))) (defalias 'smie-rule-bolp 'smie-indent--bolp) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index c407ba24e20..f248494eed1 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -2279,6 +2279,11 @@ Calls the value of `sh-set-shell-hook' if set." (let ((mksym (lambda (name) (intern (format "sh-smie-%s-%s" sh-indent-supported-here name))))) + (add-function :around (local 'smie--hanging-eolp-function) + (lambda (orig) + (if (looking-at "[ \t]*\\\\\n") + (goto-char (match-end 0)) + (funcall orig)))) (smie-setup (symbol-value (funcall mksym "grammar")) (funcall mksym "rules") :forward-token (funcall mksym "forward-token") diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index 5d4112b24fd..ba017e9938f 100644 --- a/lisp/term/xterm.el +++ b/lisp/term/xterm.el @@ -510,8 +510,8 @@ The relevant features are: ;; Gnome terminal 2.32.1 reports 1;2802;0 (setq version 200)) (when (equal (match-string 1 str) "83") - ;; OSX's Terminal.app (version 2.3 (309), which returns 83;40003;0) - ;; seems to also lack support for some of these (bug#17607). + ;; `screen' (which returns 83;40003;0) seems to also lack support for + ;; some of these (bug#17607). (setq version 240)) ;; If version is 242 or higher, assume the xterm supports ;; reporting the background color (TODO: maybe earlier diff --git a/test/indent/shell.sh b/test/indent/shell.sh index 74985a401d4..ed6bcf8da3a 100755 --- a/test/indent/shell.sh +++ b/test/indent/shell.sh @@ -25,7 +25,11 @@ esac { # bug#17621 foo1 && - foo2 && + foo2 && + bar + + foo1 && \ + foo2 && \ bar } -- 2.39.5