diff options
| author | Stefan Monnier | 2000-08-18 21:12:54 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-08-18 21:12:54 +0000 |
| commit | 8db2b9fbbcd31e00d412db744acf482080464fc6 (patch) | |
| tree | 3476f5ece78c360e5a139105c65c583074c313b8 | |
| parent | cdd0f857a60da3a08afb0ac61f3d316749408771 (diff) | |
| download | emacs-8db2b9fbbcd31e00d412db744acf482080464fc6.tar.gz emacs-8db2b9fbbcd31e00d412db744acf482080464fc6.zip | |
Big bag of typos.
| -rw-r--r-- | lisp/progmodes/sh-script.el | 204 |
1 files changed, 101 insertions, 103 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index b2d80a0181d..11922a117ea 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el | |||
| @@ -50,7 +50,7 @@ | |||
| 50 | ;; a wide variety of styles. Most of these variables are named | 50 | ;; a wide variety of styles. Most of these variables are named |
| 51 | ;; sh-indent-for-XXX and sh-indent-after-XXX. For example. | 51 | ;; sh-indent-for-XXX and sh-indent-after-XXX. For example. |
| 52 | ;; sh-indent-after-if controls the indenting of a line following | 52 | ;; sh-indent-after-if controls the indenting of a line following |
| 53 | ;; an if statement, and sh-indent-for-fi controls the indentation | 53 | ;; an if statement, and sh-indent-for-fi controls the indentation |
| 54 | ;; of the line containing the fi. | 54 | ;; of the line containing the fi. |
| 55 | ;; | 55 | ;; |
| 56 | ;; You can set each to a numeric value, but it is often more convenient | 56 | ;; You can set each to a numeric value, but it is often more convenient |
| @@ -116,7 +116,7 @@ | |||
| 116 | ; (add-hook 'sh-set-shell-hook 'sh-learn-buffer-indent) | 116 | ; (add-hook 'sh-set-shell-hook 'sh-learn-buffer-indent) |
| 117 | ;; | 117 | ;; |
| 118 | ;; However... `sh-learn-buffer-indent' is extremely slow, | 118 | ;; However... `sh-learn-buffer-indent' is extremely slow, |
| 119 | ;; especially on large-ish buffer. Also, if there are conflicts the | 119 | ;; especially on large-ish buffer. Also, if there are conflicts the |
| 120 | ;; "last one wins" which may not produce the desired setting. | 120 | ;; "last one wins" which may not produce the desired setting. |
| 121 | ;; | 121 | ;; |
| 122 | ;; So...There is a minimal way of being able to save indentation values and | 122 | ;; So...There is a minimal way of being able to save indentation values and |
| @@ -134,31 +134,31 @@ | |||
| 134 | ;; ---------------------------------------------- | 134 | ;; ---------------------------------------------- |
| 135 | ;; I think that often having them buffer-local makes sense, | 135 | ;; I think that often having them buffer-local makes sense, |
| 136 | ;; especially if one is using `sh-learn-buffer-indent'. However, if | 136 | ;; especially if one is using `sh-learn-buffer-indent'. However, if |
| 137 | ;; a user sets values using customization, these changes won't appear | 137 | ;; a user sets values using customization, these changes won't appear |
| 138 | ;; to work if the variables are already local! | 138 | ;; to work if the variables are already local! |
| 139 | ;; | 139 | ;; |
| 140 | ;; To get round this, there is a variable `sh-make-vars-local' and 2 | 140 | ;; To get round this, there is a variable `sh-make-vars-local' and 2 |
| 141 | ;; functions: `sh-make-vars-local' and `sh-reset-indent-vars-to-global-values'. | 141 | ;; functions: `sh-make-vars-local' and `sh-reset-indent-vars-to-global-values'. |
| 142 | ;; | 142 | ;; |
| 143 | ;; If `sh-make-vars-local' is non-nil, then these variables become | 143 | ;; If `sh-make-vars-local' is non-nil, then these variables become |
| 144 | ;; buffer local when the mode is established. | 144 | ;; buffer local when the mode is established. |
| 145 | ;; If this is nil, then the variables are global. At any time you | 145 | ;; If this is nil, then the variables are global. At any time you |
| 146 | ;; can make them local with the command `sh-make-vars-local'. | 146 | ;; can make them local with the command `sh-make-vars-local'. |
| 147 | ;; Conversely, to update with the global values you can use the | 147 | ;; Conversely, to update with the global values you can use the |
| 148 | ;; command `sh-reset-indent-vars-to-global-values'. | 148 | ;; command `sh-reset-indent-vars-to-global-values'. |
| 149 | ;; | 149 | ;; |
| 150 | ;; This may be awkward, but the intent is to cover all cases. | 150 | ;; This may be awkward, but the intent is to cover all cases. |
| 151 | ;; | 151 | ;; |
| 152 | ;; Awkward things, pitfalls | 152 | ;; Awkward things, pitfalls |
| 153 | ;; ------------------------ | 153 | ;; ------------------------ |
| 154 | ;; Indentation for a sh script is complicated for a number of reasons: | 154 | ;; Indentation for a sh script is complicated for a number of reasons: |
| 155 | ;; | 155 | ;; |
| 156 | ;; 1. You can't format by simply looking at symbols, you need to look | 156 | ;; 1. You can't format by simply looking at symbols, you need to look |
| 157 | ;; at keywords. [This is not the case for rc and es shells.] | 157 | ;; at keywords. [This is not the case for rc and es shells.] |
| 158 | ;; 2. The character ")" is used both as a matched pair "(" ... ")" and | 158 | ;; 2. The character ")" is used both as a matched pair "(" ... ")" and |
| 159 | ;; as a stand-alone symbol (in a case alternative). This makes | 159 | ;; as a stand-alone symbol (in a case alternative). This makes |
| 160 | ;; things quite tricky! | 160 | ;; things quite tricky! |
| 161 | ;; 3. Here-documents in a script should be treated "as is", and when | 161 | ;; 3. Here-documents in a script should be treated "as is", and when |
| 162 | ;; they terminate we want to revert to the indentation of the line | 162 | ;; they terminate we want to revert to the indentation of the line |
| 163 | ;; containing the "<<" symbol. | 163 | ;; containing the "<<" symbol. |
| 164 | ;; 4. A line may be continued using the "\". | 164 | ;; 4. A line may be continued using the "\". |
| @@ -166,7 +166,7 @@ | |||
| 166 | ;; but it doesn't in the sequence "$#"! | 166 | ;; but it doesn't in the sequence "$#"! |
| 167 | ;; | 167 | ;; |
| 168 | ;; To try and address points 2 3 and 5 I used a feature that cperl mode | 168 | ;; To try and address points 2 3 and 5 I used a feature that cperl mode |
| 169 | ;; uses, that of a text's syntax property. This, however, has 2 | 169 | ;; uses, that of a text's syntax property. This, however, has 2 |
| 170 | ;; disadvantages: | 170 | ;; disadvantages: |
| 171 | ;; 1. We need to scan the buffer to find which ")" symbols belong to a | 171 | ;; 1. We need to scan the buffer to find which ")" symbols belong to a |
| 172 | ;; case alternative, to find any here documents, and handle "$#". | 172 | ;; case alternative, to find any here documents, and handle "$#". |
| @@ -183,14 +183,14 @@ | |||
| 183 | ;; indent to. However, if font-lock mode is active when there is | 183 | ;; indent to. However, if font-lock mode is active when there is |
| 184 | ;; any change inside the here-document font-lock clears that | 184 | ;; any change inside the here-document font-lock clears that |
| 185 | ;; property. This causes several problems: lines after the here-doc | 185 | ;; property. This causes several problems: lines after the here-doc |
| 186 | ;; will not be re-indentation properly, words in the here-doc region | 186 | ;; will not be re-indented properly, words in the here-doc region |
| 187 | ;; may be fontified, and indentation may occur within the | 187 | ;; may be fontified, and indentation may occur within the |
| 188 | ;; here-document. | 188 | ;; here-document. |
| 189 | ;; I'm not sure how to fix this, perhaps using the point-entered | 189 | ;; I'm not sure how to fix this, perhaps using the point-entered |
| 190 | ;; property. Anyway, if you use font lock and change a | 190 | ;; property. Anyway, if you use font lock and change a |
| 191 | ;; here-document, I recommend using M-x sh-rescan-buffer after the | 191 | ;; here-document, I recommend using M-x sh-rescan-buffer after the |
| 192 | ;; changes are made. Similarly, when using higlight-changes-mode, | 192 | ;; changes are made. Similarly, when using highlight-changes-mode, |
| 193 | ;; changes inside a here-document may confuse shell indenting, but again | 193 | ;; changes inside a here-document may confuse shell indenting, but again |
| 194 | ;; using `sh-rescan-buffer' should fix them. | 194 | ;; using `sh-rescan-buffer' should fix them. |
| 195 | ;; | 195 | ;; |
| 196 | ;; - Indenting many lines is slow. It currently does each line | 196 | ;; - Indenting many lines is slow. It currently does each line |
| @@ -856,22 +856,20 @@ Anything else means: whenever we have a \"good guess\" as to the value." | |||
| 856 | :type '(choice | 856 | :type '(choice |
| 857 | (const :tag "Never" nil) | 857 | (const :tag "Never" nil) |
| 858 | (const :tag "Only if sure" t) | 858 | (const :tag "Only if sure" t) |
| 859 | (const :tag "If have a good guess" usually) | 859 | (const :tag "If have a good guess" usually)) |
| 860 | ) | ||
| 861 | :group 'sh-indentation) | 860 | :group 'sh-indentation) |
| 862 | 861 | ||
| 863 | (defcustom sh-popup-occur-buffer nil | 862 | (defcustom sh-popup-occur-buffer nil |
| 864 | "*Controls when `sh-learn-buffer-indent' poos the *indent* buffer. | 863 | "*Controls when `sh-learn-buffer-indent' pops the *indent* buffer. |
| 865 | If t it is always shown. If nil, it is shown only when there | 864 | If t it is always shown. If nil, it is shown only when there |
| 866 | are conflicts." | 865 | are conflicts." |
| 867 | :type '(choice | 866 | :type '(choice |
| 868 | (const :tag "Only when there are conflicts." nil) | 867 | (const :tag "Only when there are conflicts." nil) |
| 869 | (const :tag "Always" t) | 868 | (const :tag "Always" t)) |
| 870 | ) | ||
| 871 | :group 'sh-indentation) | 869 | :group 'sh-indentation) |
| 872 | 870 | ||
| 873 | (defcustom sh-blink t | 871 | (defcustom sh-blink t |
| 874 | "*If non-nil, `sh-show-indent' shows the line indentation is relative to. | 872 | "*If non-nil, `sh-show-indent' shows the line indentation is relative to. |
| 875 | The position on the line is not necessarily meaningful. | 873 | The position on the line is not necessarily meaningful. |
| 876 | In some cases the line will be the matching keyword, but this is not | 874 | In some cases the line will be the matching keyword, but this is not |
| 877 | always the case." | 875 | always the case." |
| @@ -881,17 +879,16 @@ always the case." | |||
| 881 | (defcustom sh-first-lines-indent 0 | 879 | (defcustom sh-first-lines-indent 0 |
| 882 | "*The indentation of the first non-blank non-comment line. | 880 | "*The indentation of the first non-blank non-comment line. |
| 883 | Usually 0 meaning first column. | 881 | Usually 0 meaning first column. |
| 884 | Can be set to a number, or to nil which means leave it as is." | 882 | Can be set to a number, or to nil which means leave it as is." |
| 885 | :type '(choice | 883 | :type '(choice |
| 886 | (const :tag "Leave as is" nil) | 884 | (const :tag "Leave as is" nil) |
| 887 | (integer :tag "Column number" | 885 | (integer :tag "Column number" |
| 888 | :menu-tag "Indent to this col (0 means first col)" ) | 886 | :menu-tag "Indent to this col (0 means first col)" )) |
| 889 | ) | ||
| 890 | :group 'sh-indentation) | 887 | :group 'sh-indentation) |
| 891 | 888 | ||
| 892 | 889 | ||
| 893 | (defcustom sh-basic-offset 4 | 890 | (defcustom sh-basic-offset 4 |
| 894 | "*The default indentation incrementation. | 891 | "*The default indentation increment. |
| 895 | This value is used for the + and - symbols in an indentation variable." | 892 | This value is used for the + and - symbols in an indentation variable." |
| 896 | :type 'integer | 893 | :type 'integer |
| 897 | :group 'sh-indentation) | 894 | :group 'sh-indentation) |
| @@ -899,9 +896,9 @@ This value is used for the + and - symbols in an indentation variable." | |||
| 899 | (defcustom sh-indent-comment nil | 896 | (defcustom sh-indent-comment nil |
| 900 | "*How a comment line is to be indented. | 897 | "*How a comment line is to be indented. |
| 901 | nil means leave it as it is; | 898 | nil means leave it as it is; |
| 902 | t means indent it as a normal line, aligning it to previous non-blank | 899 | t means indent it as a normal line, aligning it to previous non-blank |
| 903 | non-comment line; | 900 | non-comment line; |
| 904 | a number means align to that column, e.g. 0 means fist column." | 901 | a number means align to that column, e.g. 0 means fist column." |
| 905 | :type '(choice | 902 | :type '(choice |
| 906 | (const :tag "Leave as is." nil) | 903 | (const :tag "Leave as is." nil) |
| 907 | (const :tag "Indent as a normal line." t) | 904 | (const :tag "Indent as a normal line." t) |
| @@ -980,7 +977,7 @@ does not affect then else elif or fi statements themselves." | |||
| 980 | 977 | ||
| 981 | (defcustom sh-indent-for-do '* | 978 | (defcustom sh-indent-for-do '* |
| 982 | "*How much to indent a do statement. | 979 | "*How much to indent a do statement. |
| 983 | This is relative to the statement before the do, i.e. the | 980 | This is relative to the statement before the do, i.e. the |
| 984 | while until or for statement." | 981 | while until or for statement." |
| 985 | :type `(choice ,@ sh-number-or-symbol-list) | 982 | :type `(choice ,@ sh-number-or-symbol-list) |
| 986 | :group 'sh-indentation) | 983 | :group 'sh-indentation) |
| @@ -988,7 +985,7 @@ while until or for statement." | |||
| 988 | (defcustom sh-indent-after-do '* | 985 | (defcustom sh-indent-after-do '* |
| 989 | "*How much to indent a line after a do statement. | 986 | "*How much to indent a line after a do statement. |
| 990 | This is used when the do is the first word of the line. | 987 | This is used when the do is the first word of the line. |
| 991 | This is relative to the statement before the do, e.g. a | 988 | This is relative to the statement before the do, e.g. a |
| 992 | while for repeat or select statement." | 989 | while for repeat or select statement." |
| 993 | :type `(choice ,@ sh-number-or-symbol-list) | 990 | :type `(choice ,@ sh-number-or-symbol-list) |
| 994 | :group 'sh-indentation) | 991 | :group 'sh-indentation) |
| @@ -1090,13 +1087,13 @@ This is for the rc shell." | |||
| 1090 | 1087 | ||
| 1091 | (defun sh-mkword-regexpr (word) | 1088 | (defun sh-mkword-regexpr (word) |
| 1092 | "Make a regexp which matches WORD as a word. | 1089 | "Make a regexp which matches WORD as a word. |
| 1093 | This specifically excludes an occurance of WORD followed by | 1090 | This specifically excludes an occurrence of WORD followed by |
| 1094 | punctuation characters like '-'." | 1091 | punctuation characters like '-'." |
| 1095 | (concat word "\\([^-a-z0-9_]\\|$\\)")) | 1092 | (concat word "\\([^-a-z0-9_]\\|$\\)")) |
| 1096 | 1093 | ||
| 1097 | (defun sh-mkword-regexp (word) | 1094 | (defun sh-mkword-regexp (word) |
| 1098 | "Make a regexp which matches WORD as a word. | 1095 | "Make a regexp which matches WORD as a word. |
| 1099 | This specifically excludes an occurance of WORD followed by | 1096 | This specifically excludes an occurrence of WORD followed by |
| 1100 | or preceded by punctuation characters like '-'." | 1097 | or preceded by punctuation characters like '-'." |
| 1101 | (concat "\\(^\\|[^-a-z0-9_]\\)" word "\\([^-a-z0-9_]\\|$\\)")) | 1098 | (concat "\\(^\\|[^-a-z0-9_]\\)" word "\\([^-a-z0-9_]\\|$\\)")) |
| 1102 | 1099 | ||
| @@ -1147,12 +1144,12 @@ or preceded by punctuation characters like '-'." | |||
| 1147 | ) | 1144 | ) |
| 1148 | "A list of variables used by script mode to control indentation. | 1145 | "A list of variables used by script mode to control indentation. |
| 1149 | This list is used when switching between buffer-local and global | 1146 | This list is used when switching between buffer-local and global |
| 1150 | values of variables, and for the commands using indenation styles.") | 1147 | values of variables, and for the commands using indentation styles.") |
| 1151 | 1148 | ||
| 1152 | (defvar sh-make-vars-local t | 1149 | (defvar sh-make-vars-local t |
| 1153 | "*Controls whether indentation variables are local to the buffer. | 1150 | "*Controls whether indentation variables are local to the buffer. |
| 1154 | If non-nil, indentation variables are made local initially. | 1151 | If non-nil, indentation variables are made local initially. |
| 1155 | If nil, you can later make the variables local by invoking | 1152 | If nil, you can later make the variables local by invoking |
| 1156 | command `sh-make-vars-local'. | 1153 | command `sh-make-vars-local'. |
| 1157 | The default is t because I assume that in one Emacs session one is | 1154 | The default is t because I assume that in one Emacs session one is |
| 1158 | frequently editing existing scripts with different styles.") | 1155 | frequently editing existing scripts with different styles.") |
| @@ -1197,7 +1194,7 @@ For sh and rc shells indentation commands are: | |||
| 1197 | \\[sh-learn-line-indent] Change the indentation variable so this line | 1194 | \\[sh-learn-line-indent] Change the indentation variable so this line |
| 1198 | would indent to the way it currently is. | 1195 | would indent to the way it currently is. |
| 1199 | \\[sh-learn-buffer-indent] Set the indentation variables so the | 1196 | \\[sh-learn-buffer-indent] Set the indentation variables so the |
| 1200 | buffer indents as it currently is indendeted. | 1197 | buffer indents as it currently is indented. |
| 1201 | 1198 | ||
| 1202 | 1199 | ||
| 1203 | \\[backward-delete-char-untabify] Delete backward one position, even if it was a tab. | 1200 | \\[backward-delete-char-untabify] Delete backward one position, even if it was a tab. |
| @@ -1349,19 +1346,19 @@ This adds rules for comments and assignments." | |||
| 1349 | ;; This is used to set `sh-kw-alist' which is a list of sublists each | 1346 | ;; This is used to set `sh-kw-alist' which is a list of sublists each |
| 1350 | ;; having 3 elements: | 1347 | ;; having 3 elements: |
| 1351 | ;; a keyword | 1348 | ;; a keyword |
| 1352 | ;; a rule to check when the keyword apepars on "this" line | 1349 | ;; a rule to check when the keyword appears on "this" line |
| 1353 | ;; a rule to check when the keyword apepars on "the previous" line | 1350 | ;; a rule to check when the keyword appears on "the previous" line |
| 1354 | ;; The keyword is usually a string and is the first word on a line. | 1351 | ;; The keyword is usually a string and is the first word on a line. |
| 1355 | ;; If this keyword appears on the line whose indenation is to be | 1352 | ;; If this keyword appears on the line whose indentation is to be |
| 1356 | ;; calculated, the rule in element 2 is called. If this returns | 1353 | ;; calculated, the rule in element 2 is called. If this returns |
| 1357 | ;; non-zero, the resulting point (which may be changed by the rule) | 1354 | ;; non-zero, the resulting point (which may be changed by the rule) |
| 1358 | ;; is used as the default indentation. | 1355 | ;; is used as the default indentation. |
| 1359 | ;; If it returned false or the keyword was not found in the table, | 1356 | ;; If it returned false or the keyword was not found in the table, |
| 1360 | ;; then the keyword from the previous line is looked up and the rule | 1357 | ;; then the keyword from the previous line is looked up and the rule |
| 1361 | ;; in element 3 is called. In this case, however, | 1358 | ;; in element 3 is called. In this case, however, |
| 1362 | ;; `sh-get-indent-info' does not stop but may keepp going and test | 1359 | ;; `sh-get-indent-info' does not stop but may keep going and test |
| 1363 | ;; other keywords against rules in element 3. This is because the | 1360 | ;; other keywords against rules in element 3. This is because the |
| 1364 | ;; precending line could have, for example, an opening "if" and an | 1361 | ;; preceding line could have, for example, an opening "if" and an |
| 1365 | ;; opening "while" keyword and we need to add the indentation offsets | 1362 | ;; opening "while" keyword and we need to add the indentation offsets |
| 1366 | ;; for both. | 1363 | ;; for both. |
| 1367 | ;; | 1364 | ;; |
| @@ -1499,7 +1496,7 @@ Calls the value of `sh-set-shell-hook' if set." | |||
| 1499 | ;; but do it in case this is called before that. | 1496 | ;; but do it in case this is called before that. |
| 1500 | (make-local-variable 'indent-line-function) | 1497 | (make-local-variable 'indent-line-function) |
| 1501 | (setq indent-line-function 'sh-indent-line) | 1498 | (setq indent-line-function 'sh-indent-line) |
| 1502 | ;; This is very inefficient, but this at least makes indent-region work: | 1499 | ;; This is very inefficient, but this at least makes indent-region work: |
| 1503 | (make-local-variable 'indent-region-function) | 1500 | (make-local-variable 'indent-region-function) |
| 1504 | (setq indent-region-function nil) | 1501 | (setq indent-region-function nil) |
| 1505 | (if sh-make-vars-local | 1502 | (if sh-make-vars-local |
| @@ -1704,7 +1701,7 @@ region, clear header." | |||
| 1704 | 1701 | ||
| 1705 | (defun sh-must-support-indent () | 1702 | (defun sh-must-support-indent () |
| 1706 | "*Signal an error if the shell type for this buffer is not supported. | 1703 | "*Signal an error if the shell type for this buffer is not supported. |
| 1707 | Also, the buffer must be in Shell-script mode." | 1704 | Also, the buffer must be in Shell-script mode." |
| 1708 | (sh-must-be-shell-mode) | 1705 | (sh-must-be-shell-mode) |
| 1709 | (unless sh-indent-supported-here | 1706 | (unless sh-indent-supported-here |
| 1710 | (error "This buffer's shell type is not supported for this command"))) | 1707 | (error "This buffer's shell type is not supported for this command"))) |
| @@ -1714,7 +1711,7 @@ Also, the buffer must be in Shell-script mode." | |||
| 1714 | Normally they already are local. This command is provided in case | 1711 | Normally they already are local. This command is provided in case |
| 1715 | variable `sh-make-vars-local' has been set to nil. | 1712 | variable `sh-make-vars-local' has been set to nil. |
| 1716 | 1713 | ||
| 1717 | To revert all these variables to the global values, use | 1714 | To revert all these variables to the global values, use |
| 1718 | command `sh-reset-indent-vars-to-global-values'." | 1715 | command `sh-reset-indent-vars-to-global-values'." |
| 1719 | (interactive) | 1716 | (interactive) |
| 1720 | (sh-must-be-shell-mode) | 1717 | (sh-must-be-shell-mode) |
| @@ -1722,8 +1719,8 @@ command `sh-reset-indent-vars-to-global-values'." | |||
| 1722 | (message "Indentation variable are now local.")) | 1719 | (message "Indentation variable are now local.")) |
| 1723 | 1720 | ||
| 1724 | (defun sh-reset-indent-vars-to-global-values () | 1721 | (defun sh-reset-indent-vars-to-global-values () |
| 1725 | "Reset local indenatation variables to the global values. | 1722 | "Reset local indentation variables to the global values. |
| 1726 | Then, if variable `sh-make-vars-local' is non-nil, make them local." | 1723 | Then, if variable `sh-make-vars-local' is non-nil, make them local." |
| 1727 | (interactive) | 1724 | (interactive) |
| 1728 | (sh-must-be-shell-mode) | 1725 | (sh-must-be-shell-mode) |
| 1729 | (mapcar 'kill-local-variable sh-var-list) | 1726 | (mapcar 'kill-local-variable sh-var-list) |
| @@ -1744,10 +1741,10 @@ Then, if variable `sh-make-vars-local' is non-nil, make them local." | |||
| 1744 | (eq var 'sh-indent-comment)) | 1741 | (eq var 'sh-indent-comment)) |
| 1745 | (setq msg2 | 1742 | (setq msg2 |
| 1746 | (format "\n | 1743 | (format "\n |
| 1747 | You can enter a number (positive to increase indentenation, | 1744 | You can enter a number (positive to increase indentation, |
| 1748 | negative to decrease indentation, zero for no change to indentnation). | 1745 | negative to decrease indentation, zero for no change to indentation). |
| 1749 | 1746 | ||
| 1750 | Or, you can enter one of the following symbols which are relative to | 1747 | Or, you can enter one of the following symbols which are relative to |
| 1751 | the value of variable `sh-basic-offset' | 1748 | the value of variable `sh-basic-offset' |
| 1752 | which in this buffer is currently %s. | 1749 | which in this buffer is currently %s. |
| 1753 | 1750 | ||
| @@ -1796,7 +1793,7 @@ This handles nested if..fi pairs." | |||
| 1796 | 1793 | ||
| 1797 | ;; Functions named sh-handle-this-XXX are called when the keyword on the | 1794 | ;; Functions named sh-handle-this-XXX are called when the keyword on the |
| 1798 | ;; line whose indentation is being handled contain XXX; | 1795 | ;; line whose indentation is being handled contain XXX; |
| 1799 | ;; those named sh-handle-prev-XXX are when XXX appears on the prevoius line. | 1796 | ;; those named sh-handle-prev-XXX are when XXX appears on the previous line. |
| 1800 | 1797 | ||
| 1801 | (defun sh-handle-prev-if () | 1798 | (defun sh-handle-prev-if () |
| 1802 | (list '(+ sh-indent-after-if))) | 1799 | (list '(+ sh-indent-after-if))) |
| @@ -1872,7 +1869,7 @@ This handles nested if..fi pairs." | |||
| 1872 | ;; we shouldn't -- and can't find prev-case | 1869 | ;; we shouldn't -- and can't find prev-case |
| 1873 | (if (looking-at ".*\\bcase\\b") | 1870 | (if (looking-at ".*\\bcase\\b") |
| 1874 | (list '(+ sh-indent-for-case-label)) | 1871 | (list '(+ sh-indent-for-case-label)) |
| 1875 | (error "We don't see to be on a line with a case") ;; debug | 1872 | (error "We don't seem to be on a line with a case") ;; debug |
| 1876 | )) | 1873 | )) |
| 1877 | 1874 | ||
| 1878 | (defun sh-handle-this-esac () | 1875 | (defun sh-handle-this-esac () |
| @@ -1906,7 +1903,7 @@ This handles nested if..fi pairs." | |||
| 1906 | 1903 | ||
| 1907 | (defun sh-safe-backward-sexp () | 1904 | (defun sh-safe-backward-sexp () |
| 1908 | "Try and do a `backward-sexp', but do not error. | 1905 | "Try and do a `backward-sexp', but do not error. |
| 1909 | Return new point if successful, nil if an error occurred." | 1906 | Return new point if successful, nil if an error occurred." |
| 1910 | (condition-case nil | 1907 | (condition-case nil |
| 1911 | (progn | 1908 | (progn |
| 1912 | (backward-sexp 1) | 1909 | (backward-sexp 1) |
| @@ -1919,7 +1916,7 @@ Return new point if successful, nil if an error occurred." | |||
| 1919 | 1916 | ||
| 1920 | (defun sh-safe-forward-sexp () | 1917 | (defun sh-safe-forward-sexp () |
| 1921 | "Try and do a `forward-sexp', but do not error. | 1918 | "Try and do a `forward-sexp', but do not error. |
| 1922 | Return new point if successful, nil if an error occurred." | 1919 | Return new point if successful, nil if an error occurred." |
| 1923 | (condition-case nil | 1920 | (condition-case nil |
| 1924 | (progn | 1921 | (progn |
| 1925 | (forward-sexp 1) | 1922 | (forward-sexp 1) |
| @@ -1976,7 +1973,7 @@ Return new point if successful, nil if an error occurred." | |||
| 1976 | ;; for rc: | 1973 | ;; for rc: |
| 1977 | (defun sh-find-prev-switch () | 1974 | (defun sh-find-prev-switch () |
| 1978 | "Find the line for the switch keyword matching this line's case keyword." | 1975 | "Find the line for the switch keyword matching this line's case keyword." |
| 1979 | (re-search-backward "\\bswitch\\b" nil t)) | 1976 | (re-search-backward "\\<switch\\>" nil t)) |
| 1980 | 1977 | ||
| 1981 | (defun sh-handle-this-rc-case () | 1978 | (defun sh-handle-this-rc-case () |
| 1982 | (if (sh-find-prev-switch) | 1979 | (if (sh-find-prev-switch) |
| @@ -2002,19 +1999,19 @@ Return new point if successful, nil if an error occurred." | |||
| 2002 | "Return indent-info for this line. | 1999 | "Return indent-info for this line. |
| 2003 | This is a list. nil means the line is to be left as is. | 2000 | This is a list. nil means the line is to be left as is. |
| 2004 | Otherwise it contains one or more of the following sublists: | 2001 | Otherwise it contains one or more of the following sublists: |
| 2005 | \(t NUMBER\) NUMBER is the base location in the buffer that indendation is | 2002 | \(t NUMBER\) NUMBER is the base location in the buffer that indentation is |
| 2006 | relative to. If present, this is always the first of the | 2003 | relative to. If present, this is always the first of the |
| 2007 | sublists. The indentation of the line in question is | 2004 | sublists. The indentation of the line in question is |
| 2008 | derived from the indentation of this point, possibly | 2005 | derived from the indentation of this point, possibly |
| 2009 | modified by subsequent sublists. | 2006 | modified by subsequent sublists. |
| 2010 | \(+ VAR\) | 2007 | \(+ VAR\) |
| 2011 | \(- VAR\) Get the value of variable VAR and add to or subtract from | 2008 | \(- VAR\) Get the value of variable VAR and add to or subtract from |
| 2012 | the indentation calculated so far. | 2009 | the indentation calculated so far. |
| 2013 | \(= VAR\) Get the value of variable VAR and *replace* the | 2010 | \(= VAR\) Get the value of variable VAR and *replace* the |
| 2014 | indentation with itss value. This only occurs for | 2011 | indentation with its value. This only occurs for |
| 2015 | special variables such as `sh-indent-comment'. | 2012 | special variables such as `sh-indent-comment'. |
| 2016 | STRING This is ignored for the purposes of calculating | 2013 | STRING This is ignored for the purposes of calculating |
| 2017 | indentation, it is printed in certain cases to help show | 2014 | indentation, it is printed in certain cases to help show |
| 2018 | what the indentation is based on." | 2015 | what the indentation is based on." |
| 2019 | ;; See comments before `sh-kw'. | 2016 | ;; See comments before `sh-kw'. |
| 2020 | (save-excursion | 2017 | (save-excursion |
| @@ -2046,7 +2043,7 @@ STRING This is ignored for the purposes of calculating | |||
| 2046 | (setq result t);; return nil if 1st line! | 2043 | (setq result t);; return nil if 1st line! |
| 2047 | (setq result (list '(= sh-indent-comment))) | 2044 | (setq result (list '(= sh-indent-comment))) |
| 2048 | ;; we still need to get previous line in case | 2045 | ;; we still need to get previous line in case |
| 2049 | ;; sh-indent-comnent is t (indent as normal) | 2046 | ;; sh-indent-comment is t (indent as normal) |
| 2050 | (setq align-point (sh-prev-line nil)) | 2047 | (setq align-point (sh-prev-line nil)) |
| 2051 | (setq have-result nil) | 2048 | (setq have-result nil) |
| 2052 | )) | 2049 | )) |
| @@ -2077,7 +2074,7 @@ STRING This is ignored for the purposes of calculating | |||
| 2077 | (setq result (append result val)) | 2074 | (setq result (append result val)) |
| 2078 | (setq have-result t) | 2075 | (setq have-result t) |
| 2079 | ;; set prev-line to continue processing remainder | 2076 | ;; set prev-line to continue processing remainder |
| 2080 | ;; of this line as a previous l ine | 2077 | ;; of this line as a previous line |
| 2081 | (setq prev-line-end (point)) | 2078 | (setq prev-line-end (point)) |
| 2082 | )))) | 2079 | )))) |
| 2083 | 2080 | ||
| @@ -2216,23 +2213,23 @@ If INFO is supplied it is used, else it is calculated." | |||
| 2216 | 2213 | ||
| 2217 | ;; Finding the previous line isn't trivial. | 2214 | ;; Finding the previous line isn't trivial. |
| 2218 | ;; We must *always* go back one more and see if that is a continuation | 2215 | ;; We must *always* go back one more and see if that is a continuation |
| 2219 | ;; line -- it is the PREVIOUS line which is continued, not the one | 2216 | ;; line -- it is the PREVIOUS line which is continued, not the one |
| 2220 | ;; we are going to! | 2217 | ;; we are going to! |
| 2221 | ;; Also, we want to treat a whole "here document" as one big line, | 2218 | ;; Also, we want to treat a whole "here document" as one big line, |
| 2222 | ;; because we may want to a align to the beginning of it. | 2219 | ;; because we may want to a align to the beginning of it. |
| 2223 | ;; | 2220 | ;; |
| 2224 | ;; What we do: | 2221 | ;; What we do: |
| 2225 | ;; - go back a line, if empty repeat | 2222 | ;; - go back a line, if empty repeat |
| 2226 | ;; - (we are now at a previous non empty line) | 2223 | ;; - (we are now at a previous non empty line) |
| 2227 | ;; - save this | 2224 | ;; - save this |
| 2228 | ;; - if this is in a here-document, go to the beginning of it | 2225 | ;; - if this is in a here-document, go to the beginning of it |
| 2229 | ;; and save that | 2226 | ;; and save that |
| 2230 | ;; - go back one more physcial line and see if it is a continuation line | 2227 | ;; - go back one more physical line and see if it is a continuation line |
| 2231 | ;; - if yes, save it and repeat | 2228 | ;; - if yes, save it and repeat |
| 2232 | ;; - if no, go back to where we last saved. | 2229 | ;; - if no, go back to where we last saved. |
| 2233 | (defun sh-prev-line (&optional end) | 2230 | (defun sh-prev-line (&optional end) |
| 2234 | "Back to end of previous non-comment non-empty line. | 2231 | "Back to end of previous non-comment non-empty line. |
| 2235 | Go to beginning of logical line unless END is non-nil, in which case | 2232 | Go to beginning of logical line unless END is non-nil, in which case |
| 2236 | we go to the end of the previous line and do not check for continuations." | 2233 | we go to the end of the previous line and do not check for continuations." |
| 2237 | (sh-must-be-shell-mode) | 2234 | (sh-must-be-shell-mode) |
| 2238 | (let ((going t) | 2235 | (let ((going t) |
| @@ -2296,7 +2293,7 @@ we go to the end of the previous line and do not check for continuations." | |||
| 2296 | (defun sh-prev-stmt () | 2293 | (defun sh-prev-stmt () |
| 2297 | "Return the address of the previous stmt or nil." | 2294 | "Return the address of the previous stmt or nil." |
| 2298 | ;; This is used when we are trying to find a matching keyword. | 2295 | ;; This is used when we are trying to find a matching keyword. |
| 2299 | ;; Searching backward for the keyword would certainly be quicker, but | 2296 | ;; Searching backward for the keyword would certainly be quicker, but |
| 2300 | ;; it is hard to remove "false matches" -- such as if the keyword | 2297 | ;; it is hard to remove "false matches" -- such as if the keyword |
| 2301 | ;; appears in a string or quote. This way is slower, but (I think) safer. | 2298 | ;; appears in a string or quote. This way is slower, but (I think) safer. |
| 2302 | (interactive) | 2299 | (interactive) |
| @@ -2309,7 +2306,7 @@ we go to the end of the previous line and do not check for continuations." | |||
| 2309 | (while (and (not found) | 2306 | (while (and (not found) |
| 2310 | (not (bobp)) | 2307 | (not (bobp)) |
| 2311 | going) | 2308 | going) |
| 2312 | ;; Do a backward-sexp if possible, else backup bit by bit... | 2309 | ;; Do a backward-sexp if possible, else backup bit by bit... |
| 2313 | (if (sh-safe-backward-sexp) | 2310 | (if (sh-safe-backward-sexp) |
| 2314 | (progn | 2311 | (progn |
| 2315 | (if (looking-at sh-special-keywords) | 2312 | (if (looking-at sh-special-keywords) |
| @@ -2365,7 +2362,7 @@ we go to the end of the previous line and do not check for continuations." | |||
| 2365 | "Return the previous thing this logical line." | 2362 | "Return the previous thing this logical line." |
| 2366 | ;; This is called when `sh-get-indent-info' is working backwards on | 2363 | ;; This is called when `sh-get-indent-info' is working backwards on |
| 2367 | ;; the previous line(s) finding what keywords may be relevant for | 2364 | ;; the previous line(s) finding what keywords may be relevant for |
| 2368 | ;; indenting. It moves over sexps if possible, and will stop | 2365 | ;; indenting. It moves over sexps if possible, and will stop |
| 2369 | ;; on a ; and at the beginning of a line if it is not a continuation | 2366 | ;; on a ; and at the beginning of a line if it is not a continuation |
| 2370 | ;; line. | 2367 | ;; line. |
| 2371 | ;; | 2368 | ;; |
| @@ -2489,7 +2486,7 @@ Optional parameter DEPTH (usually 1) says how many to look for." | |||
| 2489 | (defun sh-var-value (var &optional ignore-error) | 2486 | (defun sh-var-value (var &optional ignore-error) |
| 2490 | "Return the value of variable VAR, interpreting symbols. | 2487 | "Return the value of variable VAR, interpreting symbols. |
| 2491 | It can also return t or nil. | 2488 | It can also return t or nil. |
| 2492 | If an illegal value is found, throw an error unless Optional argument | 2489 | If an illegal value is found, throw an error unless Optional argument |
| 2493 | IGNORE-ERROR is non-nil." | 2490 | IGNORE-ERROR is non-nil." |
| 2494 | (let ((val (symbol-value var))) | 2491 | (let ((val (symbol-value var))) |
| 2495 | (cond | 2492 | (cond |
| @@ -2514,14 +2511,14 @@ IGNORE-ERROR is non-nil." | |||
| 2514 | (t | 2511 | (t |
| 2515 | (if ignore-error | 2512 | (if ignore-error |
| 2516 | (progn | 2513 | (progn |
| 2517 | (message "Don't konw how to handle %s's value of %s" var val) | 2514 | (message "Don't know how to handle %s's value of %s" var val) |
| 2518 | 0) | 2515 | 0) |
| 2519 | (error "Don't know how to handle %s's value of %s" var val)) | 2516 | (error "Don't know how to handle %s's value of %s" var val)) |
| 2520 | )))) | 2517 | )))) |
| 2521 | 2518 | ||
| 2522 | (defun sh-set-var-value (var value &optional no-symbol) | 2519 | (defun sh-set-var-value (var value &optional no-symbol) |
| 2523 | "Set variable VAR to VALUE. | 2520 | "Set variable VAR to VALUE. |
| 2524 | Unless optional argument NO-SYMBOL is non-nil, then if VALUE is | 2521 | Unless optional argument NO-SYMBOL is non-nil, then if VALUE is |
| 2525 | can be represented by a symbol then do so." | 2522 | can be represented by a symbol then do so." |
| 2526 | (cond | 2523 | (cond |
| 2527 | (no-symbol | 2524 | (no-symbol |
| @@ -2716,14 +2713,14 @@ for a new value for it." | |||
| 2716 | var (symbol-value var) indent-val) | 2713 | var (symbol-value var) indent-val) |
| 2717 | (message "Variable: %s Value: %s would leave line as is." | 2714 | (message "Variable: %s Value: %s would leave line as is." |
| 2718 | var (symbol-value var))) | 2715 | var (symbol-value var))) |
| 2719 | ;; I'm not sure about this, indenting it now? | 2716 | ;; I'm not sure about this, indenting it now? |
| 2720 | ;; No. Because it would give the impression that an undo would | 2717 | ;; No. Because it would give the impression that an undo would |
| 2721 | ;; restore thing, but the value has been altered. | 2718 | ;; restore thing, but the value has been altered. |
| 2722 | ;; (sh-indent-line) | 2719 | ;; (sh-indent-line) |
| 2723 | ) | 2720 | ) |
| 2724 | (error | 2721 | (error |
| 2725 | (set var old-val) | 2722 | (set var old-val) |
| 2726 | (message "Bad value for %s, restoring to previous value %s" | 2723 | (message "Bad value for %s, restoring to previous value %s" |
| 2727 | var old-val) | 2724 | var old-val) |
| 2728 | (sit-for 1) | 2725 | (sit-for 1) |
| 2729 | nil)) | 2726 | nil)) |
| @@ -2758,7 +2755,7 @@ unless optional argument ARG (the prefix when interactive) is non-nil." | |||
| 2758 | (message (format "Cannot learn line - %s" var))) | 2755 | (message (format "Cannot learn line - %s" var))) |
| 2759 | ((eq var 'sh-indent-comment) | 2756 | ((eq var 'sh-indent-comment) |
| 2760 | ;; This is arbitrary... | 2757 | ;; This is arbitrary... |
| 2761 | ;; - if curr-indent is 0, set to curr-indent | 2758 | ;; - if curr-indent is 0, set to curr-indent |
| 2762 | ;; - else if it has the indentation of a "normal" line, | 2759 | ;; - else if it has the indentation of a "normal" line, |
| 2763 | ;; then set to t | 2760 | ;; then set to t |
| 2764 | ;; - else set to curr-indent. | 2761 | ;; - else set to curr-indent. |
| @@ -2809,7 +2806,7 @@ unless optional argument ARG (the prefix when interactive) is non-nil." | |||
| 2809 | "Insert MESSAGE referring to location POINT in current buffer into BUFFER. | 2806 | "Insert MESSAGE referring to location POINT in current buffer into BUFFER. |
| 2810 | Buffer BUFFER is in `occur-mode'. | 2807 | Buffer BUFFER is in `occur-mode'. |
| 2811 | If ADD-LINENUM is non-nil the message is preceded by the line number. | 2808 | If ADD-LINENUM is non-nil the message is preceded by the line number. |
| 2812 | If OCCUR-POINT is non-nil then the line is marked as a new occurence | 2809 | If OCCUR-POINT is non-nil then the line is marked as a new occurrence |
| 2813 | so that `occur-next' and `occur-prev' will work." | 2810 | so that `occur-next' and `occur-prev' will work." |
| 2814 | (let ((m1 (make-marker)) | 2811 | (let ((m1 (make-marker)) |
| 2815 | (main-buffer (current-buffer)) | 2812 | (main-buffer (current-buffer)) |
| @@ -2849,7 +2846,7 @@ so that `occur-next' and `occur-prev' will work." | |||
| 2849 | 2846 | ||
| 2850 | ;; Is this really worth having? | 2847 | ;; Is this really worth having? |
| 2851 | (defvar sh-learned-buffer-hook nil | 2848 | (defvar sh-learned-buffer-hook nil |
| 2852 | "*An abnormal hook, called with an alist of leared variables.") | 2849 | "*An abnormal hook, called with an alist of learned variables.") |
| 2853 | ;;; Example of how to use sh-learned-buffer-hook | 2850 | ;;; Example of how to use sh-learned-buffer-hook |
| 2854 | ;; | 2851 | ;; |
| 2855 | ;; (defun what-i-learned (list) | 2852 | ;; (defun what-i-learned (list) |
| @@ -2869,27 +2866,27 @@ so that `occur-next' and `occur-prev' will work." | |||
| 2869 | 2866 | ||
| 2870 | 2867 | ||
| 2871 | ;; Originally this was sh-learn-region-indent (beg end) | 2868 | ;; Originally this was sh-learn-region-indent (beg end) |
| 2872 | ;; However, in practise this was awkward so I changed it to | 2869 | ;; However, in practice this was awkward so I changed it to |
| 2873 | ;; use the whole buffer. Use narrowing if needbe. | 2870 | ;; use the whole buffer. Use narrowing if needbe. |
| 2874 | (defun sh-learn-buffer-indent (&optional arg) | 2871 | (defun sh-learn-buffer-indent (&optional arg) |
| 2875 | "Learn how to indent the buffer the way it currently is. | 2872 | "Learn how to indent the buffer the way it currently is. |
| 2876 | 2873 | ||
| 2877 | Output in buffer \"*indent*\" shows any lines which have conflicting | 2874 | Output in buffer \"*indent*\" shows any lines which have conflicting |
| 2878 | values of a variable, and the final value of all variables learnt. | 2875 | values of a variable, and the final value of all variables learned. |
| 2879 | This buffer is popped to automatically if there are any discrepencies. | 2876 | This buffer is popped to automatically if there are any discrepancies. |
| 2880 | 2877 | ||
| 2881 | If no prefix ARG is given, then variables are set to numbers. | 2878 | If no prefix ARG is given, then variables are set to numbers. |
| 2882 | If a prefix arg is given, then variables are set to symbols when | 2879 | If a prefix arg is given, then variables are set to symbols when |
| 2883 | applicable -- e.g. to symbol `+' if the value is that of the | 2880 | applicable -- e.g. to symbol `+' if the value is that of the |
| 2884 | basic indent. | 2881 | basic indent. |
| 2885 | If a positive numerical prefix is given, then `sh-basic-offset' | 2882 | If a positive numerical prefix is given, then `sh-basic-offset' |
| 2886 | is set to the prefix's numerical value. | 2883 | is set to the prefix's numerical value. |
| 2887 | Otherwise, sh-basic-offset may or may not be changed, according | 2884 | Otherwise, sh-basic-offset may or may not be changed, according |
| 2888 | to the value of variable `sh-learn-basic-offset'. | 2885 | to the value of variable `sh-learn-basic-offset'. |
| 2889 | 2886 | ||
| 2890 | Abnormal hook `sh-learned-buffer-hook' if non-nil is called when the | 2887 | Abnormal hook `sh-learned-buffer-hook' if non-nil is called when the |
| 2891 | function completes. The function is abnormal because it is called | 2888 | function completes. The function is abnormal because it is called |
| 2892 | with an alist of variables learnt. This feature may be changed or | 2889 | with an alist of variables learned. This feature may be changed or |
| 2893 | removed in the future. | 2890 | removed in the future. |
| 2894 | 2891 | ||
| 2895 | This command can often take a long time to run." | 2892 | This command can often take a long time to run." |
| @@ -2905,7 +2902,7 @@ This command can often take a long time to run." | |||
| 2905 | (max 17) | 2902 | (max 17) |
| 2906 | vec | 2903 | vec |
| 2907 | msg | 2904 | msg |
| 2908 | (comment-col nil) ;; number if all same, t if seen diff values | 2905 | (comment-col nil) ;; number if all same, t if seen diff values |
| 2909 | (comments-always-default t) ;; nil if we see one not default | 2906 | (comments-always-default t) ;; nil if we see one not default |
| 2910 | initial-msg | 2907 | initial-msg |
| 2911 | (specified-basic-offset (and arg (numberp arg) | 2908 | (specified-basic-offset (and arg (numberp arg) |
| @@ -2950,7 +2947,7 @@ This command can often take a long time to run." | |||
| 2950 | (unless (looking-at "\\s-*#");; don't learn from comments | 2947 | (unless (looking-at "\\s-*#");; don't learn from comments |
| 2951 | (if (setq previous-set-info (assoc var learned-var-list)) | 2948 | (if (setq previous-set-info (assoc var learned-var-list)) |
| 2952 | (progn | 2949 | (progn |
| 2953 | ;; it was already there, is it same value ? | 2950 | ;; it was already there, is it same value ? |
| 2954 | (unless (eq (symbol-value var) | 2951 | (unless (eq (symbol-value var) |
| 2955 | (nth 1 previous-set-info)) | 2952 | (nth 1 previous-set-info)) |
| 2956 | (sh-mark-line | 2953 | (sh-mark-line |
| @@ -3013,7 +3010,7 @@ This command can often take a long time to run." | |||
| 3013 | ((numberp comment-col) | 3010 | ((numberp comment-col) |
| 3014 | (setq msg (format "\nComments are in col %d." comment-col))) | 3011 | (setq msg (format "\nComments are in col %d." comment-col))) |
| 3015 | (t | 3012 | (t |
| 3016 | (setq msg "\nComments seem to be mixed, leaving them as is.\n") | 3013 | (setq msg "\nComments seem to be mixed, leaving them as is.\n") |
| 3017 | (setq comment-col nil) | 3014 | (setq comment-col nil) |
| 3018 | )) | 3015 | )) |
| 3019 | (sh-debug msg) | 3016 | (sh-debug msg) |
| @@ -3114,13 +3111,13 @@ This command can often take a long time to run." | |||
| 3114 | ))) | 3111 | ))) |
| 3115 | 3112 | ||
| 3116 | (defun sh-guess-basic-offset (vec) | 3113 | (defun sh-guess-basic-offset (vec) |
| 3117 | "See if we can determine a reasonbable value for `sh-basic-offset'. | 3114 | "See if we can determine a reasonable value for `sh-basic-offset'. |
| 3118 | This is experimental, heuristic and arbitrary! | 3115 | This is experimental, heuristic and arbitrary! |
| 3119 | Argument VEC is a vector of information collected by | 3116 | Argument VEC is a vector of information collected by |
| 3120 | `sh-learn-buffer-indent'. | 3117 | `sh-learn-buffer-indent'. |
| 3121 | Return values: | 3118 | Return values: |
| 3122 | number - there appears to be a good single value | 3119 | number - there appears to be a good single value |
| 3123 | list of numbers - no obvious one, here is a list of one or more | 3120 | list of numbers - no obvious one, here is a list of one or more |
| 3124 | reasonable choices | 3121 | reasonable choices |
| 3125 | nil - we couldn't find a reasonable one." | 3122 | nil - we couldn't find a reasonable one." |
| 3126 | (let* ((max (1- (length vec))) | 3123 | (let* ((max (1- (length vec))) |
| @@ -3186,11 +3183,11 @@ Return values: | |||
| 3186 | (defun sh-do-nothing (a b c) | 3183 | (defun sh-do-nothing (a b c) |
| 3187 | ;; checkdoc-params: (a b c) | 3184 | ;; checkdoc-params: (a b c) |
| 3188 | "A dummy function to prevent font-lock from re-fontifying a change. | 3185 | "A dummy function to prevent font-lock from re-fontifying a change. |
| 3189 | Otherwise, we fontify something and font-lock overwrites it." | 3186 | Otherwise, we fontify something and font-lock overwrites it." |
| 3190 | ) | 3187 | ) |
| 3191 | 3188 | ||
| 3192 | ;; The default font-lock-unfontify-region-function removes | 3189 | ;; The default font-lock-unfontify-region-function removes |
| 3193 | ;; syntax-table properties, and so removes our information. | 3190 | ;; syntax-table properties, and so removes our information. |
| 3194 | (defun sh-font-lock-unfontify-region-function (beg end) | 3191 | (defun sh-font-lock-unfontify-region-function (beg end) |
| 3195 | (let* ((modified (buffer-modified-p)) (buffer-undo-list t) | 3192 | (let* ((modified (buffer-modified-p)) (buffer-undo-list t) |
| 3196 | (inhibit-read-only t) (inhibit-point-motion-hooks t) | 3193 | (inhibit-read-only t) (inhibit-point-motion-hooks t) |
| @@ -3213,10 +3210,10 @@ Otherwise, we fontify something and font-lock overwrites it." | |||
| 3213 | 3210 | ||
| 3214 | (defun sh-check-paren-in-case () | 3211 | (defun sh-check-paren-in-case () |
| 3215 | "Make syntax class of case label's right parenthesis not close parenthesis. | 3212 | "Make syntax class of case label's right parenthesis not close parenthesis. |
| 3216 | If this parenthesis is a case alternative, set its syntax class to a word." | 3213 | If this parenthesis is a case alternative, set its syntax class to a word." |
| 3217 | (let ((start (point)) | 3214 | (let ((start (point)) |
| 3218 | state prev-line) | 3215 | state prev-line) |
| 3219 | ;; First test if this is a possible candidate, the first "(" or ")" | 3216 | ;; First test if this is a possible candidate, the first "(" or ")" |
| 3220 | ;; on the line; then, if go, check prev line is ;; or case. | 3217 | ;; on the line; then, if go, check prev line is ;; or case. |
| 3221 | (save-excursion | 3218 | (save-excursion |
| 3222 | (beginning-of-line) | 3219 | (beginning-of-line) |
| @@ -3365,7 +3362,7 @@ Called from scan-buff. If ok, return non-nil." | |||
| 3365 | ;; (message "end of search for esac at %d depth=%d" (point) depth) | 3362 | ;; (message "end of search for esac at %d depth=%d" (point) depth) |
| 3366 | (setq end (point)) | 3363 | (setq end (point)) |
| 3367 | (goto-char start) | 3364 | (goto-char start) |
| 3368 | ;; if we found the esac, then fix all appropriate ')'s in the region | 3365 | ;; if we found the esac, then fix all appropriate ')'s in the region |
| 3369 | (if (zerop depth) | 3366 | (if (zerop depth) |
| 3370 | (progn | 3367 | (progn |
| 3371 | (while (< (point) end) | 3368 | (while (< (point) end) |
| @@ -3389,6 +3386,7 @@ Called from scan-buff. If ok, return non-nil." | |||
| 3389 | )) | 3386 | )) |
| 3390 | 3387 | ||
| 3391 | 3388 | ||
| 3389 | ;; FIXME: This loses big time on very large files (such as CVS' sanity.sh). | ||
| 3392 | (defun sh-scan-buffer () | 3390 | (defun sh-scan-buffer () |
| 3393 | "Scan a sh buffer for case statements and here-documents. | 3391 | "Scan a sh buffer for case statements and here-documents. |
| 3394 | 3392 | ||
| @@ -3396,7 +3394,7 @@ For each case alternative found, mark its \")\" with a text property | |||
| 3396 | so that its syntax class is no longer a close parenthesis character. | 3394 | so that its syntax class is no longer a close parenthesis character. |
| 3397 | 3395 | ||
| 3398 | Each here-document is also marked so that it is effectively immune | 3396 | Each here-document is also marked so that it is effectively immune |
| 3399 | from indenation changes." | 3397 | from indentation changes." |
| 3400 | ;; Do not call this interactively, call `sh-rescan-buffer' instead. | 3398 | ;; Do not call this interactively, call `sh-rescan-buffer' instead. |
| 3401 | (sh-must-be-shell-mode) | 3399 | (sh-must-be-shell-mode) |
| 3402 | (let ((n 0) | 3400 | (let ((n 0) |
| @@ -3471,16 +3469,16 @@ from indenation changes." | |||
| 3471 | 3469 | ||
| 3472 | ;; ======================================================================== | 3470 | ;; ======================================================================== |
| 3473 | 3471 | ||
| 3474 | ;; Styles -- a quick and dirty way of saving the indenation settings. | 3472 | ;; Styles -- a quick and dirty way of saving the indentation settings. |
| 3475 | 3473 | ||
| 3476 | (defvar sh-styles-alist nil | 3474 | (defvar sh-styles-alist nil |
| 3477 | "A list of all known shell indentation styles.") | 3475 | "A list of all known shell indentation styles.") |
| 3478 | 3476 | ||
| 3479 | (defun sh-name-style (name &optional confirm-overwrite) | 3477 | (defun sh-name-style (name &optional confirm-overwrite) |
| 3480 | "Name the current indentation settings as a style called NAME. | 3478 | "Name the current indentation settings as a style called NAME. |
| 3481 | If this name exists, the command will prompt whether it should be | 3479 | If this name exists, the command will prompt whether it should be |
| 3482 | overwritten if | 3480 | overwritten if |
| 3483 | - - it was called interactively with a prefix argument, or | 3481 | - - it was called interactively with a prefix argument, or |
| 3484 | - - called non-interactively with optional CONFIRM-OVERWRITE non-nil." | 3482 | - - called non-interactively with optional CONFIRM-OVERWRITE non-nil." |
| 3485 | ;; (interactive "sName for this style: ") | 3483 | ;; (interactive "sName for this style: ") |
| 3486 | (interactive | 3484 | (interactive |