1660 |
(eq -1 (% (save-excursion (skip-chars-backward "\\\\")) 2))) |
(eq -1 (% (save-excursion (skip-chars-backward "\\\\")) 2))) |
1661 |
|
|
1662 |
;; Indentation stuff. |
;; Indentation stuff. |
|
(defun sh-must-be-shell-mode () |
|
|
"Signal an error if not in Shell-script mode." |
|
|
(unless (derived-mode-p 'sh-mode) |
|
|
(error "This buffer is not in Shell-script mode"))) |
|
|
|
|
1663 |
(defun sh-must-support-indent () |
(defun sh-must-support-indent () |
1664 |
"*Signal an error if the shell type for this buffer is not supported. |
"*Signal an error if the shell type for this buffer is not supported. |
1665 |
Also, the buffer must be in Shell-script mode." |
Also, the buffer must be in Shell-script mode." |
|
(sh-must-be-shell-mode) |
|
1666 |
(unless sh-indent-supported-here |
(unless sh-indent-supported-here |
1667 |
(error "This buffer's shell does not support indentation through Emacs"))) |
(error "This buffer's shell does not support indentation through Emacs"))) |
1668 |
|
|
1674 |
To revert all these variables to the global values, use |
To revert all these variables to the global values, use |
1675 |
command `sh-reset-indent-vars-to-global-values'." |
command `sh-reset-indent-vars-to-global-values'." |
1676 |
(interactive) |
(interactive) |
|
(sh-must-be-shell-mode) |
|
1677 |
(mapcar 'make-local-variable sh-var-list) |
(mapcar 'make-local-variable sh-var-list) |
1678 |
(message "Indentation variable are now local.")) |
(message "Indentation variable are now local.")) |
1679 |
|
|
1681 |
"Reset local indentation variables to the global values. |
"Reset local indentation variables to the global values. |
1682 |
Then, if variable `sh-make-vars-local' is non-nil, make them local." |
Then, if variable `sh-make-vars-local' is non-nil, make them local." |
1683 |
(interactive) |
(interactive) |
|
(sh-must-be-shell-mode) |
|
1684 |
(mapcar 'kill-local-variable sh-var-list) |
(mapcar 'kill-local-variable sh-var-list) |
1685 |
(if sh-make-vars-local |
(if sh-make-vars-local |
1686 |
(mapcar 'make-local-variable sh-var-list))) |
(mapcar 'make-local-variable sh-var-list))) |
2139 |
"Back to end of previous non-comment non-empty line. |
"Back to end of previous non-comment non-empty line. |
2140 |
Go to beginning of logical line unless END is non-nil, in which case |
Go to beginning of logical line unless END is non-nil, in which case |
2141 |
we go to the end of the previous line and do not check for continuations." |
we go to the end of the previous line and do not check for continuations." |
|
(sh-must-be-shell-mode) |
|
2142 |
(save-excursion |
(save-excursion |
2143 |
(beginning-of-line) |
(beginning-of-line) |
2144 |
(forward-comment (- (point-max))) |
(forward-comment (- (point-max))) |
2469 |
(defun sh-indent-line () |
(defun sh-indent-line () |
2470 |
"Indent the current line." |
"Indent the current line." |
2471 |
(interactive) |
(interactive) |
|
(sh-must-be-shell-mode) |
|
2472 |
(let ((indent (sh-calculate-indent)) shift-amt beg end |
(let ((indent (sh-calculate-indent)) shift-amt beg end |
2473 |
(pos (- (point-max) (point)))) |
(pos (- (point-max) (point)))) |
2474 |
(when indent |
(when indent |