(sh-get-indent-info): Only indent a continuation line if SPC or TAB precedes \.
(sh-get-indent-info): Simplify. (sh-mark-init, sh-learn-buffer-indent, sh-add-completer): with-current-buffer.
This commit is contained in:
parent
8a08764f7a
commit
090475f391
2 changed files with 24 additions and 17 deletions
3
etc/NEWS
3
etc/NEWS
|
@ -2181,6 +2181,9 @@ line is left untouched.
|
|||
The function `c-toggle-syntactic-indentation' can be used to toggle
|
||||
syntactic indentation.
|
||||
|
||||
** In sh-script, a continuation line is only indented if the backslash was
|
||||
preceded by a SPC or a TAB.
|
||||
|
||||
---
|
||||
** Perl mode has a new variable `perl-indent-continued-arguments'.
|
||||
|
||||
|
|
|
@ -2033,11 +2033,20 @@ STRING This is ignored for the purposes of calculating
|
|||
;; Continuation lines are handled specially
|
||||
(if (sh-this-is-a-continuation)
|
||||
(progn
|
||||
;; We assume the line being continued is already
|
||||
;; properly indented...
|
||||
;; (setq prev-line-end (sh-prev-line))
|
||||
(setq align-point (sh-prev-line nil))
|
||||
(setq result (list '(+ sh-indent-for-continuation)))
|
||||
(setq result
|
||||
(if (save-excursion
|
||||
(beginning-of-line)
|
||||
(not (memq (char-before (- (point) 2)) '(?\s ?\t))))
|
||||
;; By convention, if the continuation \ is not
|
||||
;; preceded by a SPC or a TAB it means that the line
|
||||
;; is cut at a place where spaces cannot be freely
|
||||
;; added/removed. I.e. do not indent the line.
|
||||
(list '(= nil))
|
||||
;; We assume the line being continued is already
|
||||
;; properly indented...
|
||||
;; (setq prev-line-end (sh-prev-line))
|
||||
(setq align-point (sh-prev-line nil))
|
||||
(list '(+ sh-indent-for-continuation))))
|
||||
(setq have-result t))
|
||||
(beginning-of-line)
|
||||
(skip-chars-forward " \t")
|
||||
|
@ -2130,10 +2139,9 @@ STRING This is ignored for the purposes of calculating
|
|||
(sh-debug "result is now: %s" result)
|
||||
|
||||
(or result
|
||||
(if prev-line-end
|
||||
(setq result (list (list t prev-line-end)))
|
||||
(setq result (list (list '= 'sh-first-lines-indent)))
|
||||
))
|
||||
(setq result (list (if prev-line-end
|
||||
(list t prev-line-end)
|
||||
(list '= 'sh-first-lines-indent)))))
|
||||
|
||||
(if (eq result t)
|
||||
(setq result nil))
|
||||
|
@ -2695,11 +2703,9 @@ unless optional argument ARG (the prefix when interactive) is non-nil."
|
|||
|
||||
(defun sh-mark-init (buffer)
|
||||
"Initialize a BUFFER to be used by `sh-mark-line'."
|
||||
(save-excursion
|
||||
(set-buffer (get-buffer-create buffer))
|
||||
(with-current-buffer (get-buffer-create buffer)
|
||||
(erase-buffer)
|
||||
(occur-mode)
|
||||
))
|
||||
(occur-mode)))
|
||||
|
||||
|
||||
(defun sh-mark-line (message point buffer &optional add-linenum occur-point)
|
||||
|
@ -2972,8 +2978,7 @@ This command can often take a long time to run."
|
|||
(let ((var (car learned-var)))
|
||||
(sh-mark-line (format " %s %s" var (symbol-value var))
|
||||
(nth 2 learned-var) out-buffer)))
|
||||
(save-excursion
|
||||
(set-buffer out-buffer)
|
||||
(with-current-buffer out-buffer
|
||||
(goto-char (point-min))
|
||||
(insert
|
||||
(format "Indentation values for buffer %s.\n" name)
|
||||
|
@ -3244,8 +3249,7 @@ nil means to return the best completion of STRING, or nil if there is none.
|
|||
t means to return a list of all possible completions of STRING.
|
||||
`lambda' means to return t if STRING is a valid completion as it stands."
|
||||
(let ((sh-shell-variables
|
||||
(save-excursion
|
||||
(set-buffer sh-add-buffer)
|
||||
(with-current-buffer sh-add-buffer
|
||||
(or sh-shell-variables-initialized
|
||||
(sh-shell-initialize-variables))
|
||||
(nconc (mapcar (lambda (var)
|
||||
|
|
Loading…
Add table
Reference in a new issue