From: Juanma Barranquero Date: Mon, 21 Oct 2002 09:06:56 +0000 (+0000) Subject: (sh-indent-for-then): Fix typo. X-Git-Tag: emacs-pretest-21.2.92~25 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b2f8933cf3454140cba2789b34e7269d917e8c11;p=emacs.git (sh-indent-for-then): Fix typo. --- diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 90a65a19f64..e434c6917be 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -43,35 +43,35 @@ ;; =========== ;; Indentation for rc and es modes is very limited, but for Bourne shells ;; and its derivatives it is quite customizable. -;; +;; ;; The following description applies to sh and derived shells (bash, ;; zsh, ...). -;; +;; ;; There are various customization variables which allow tailoring to ;; a wide variety of styles. Most of these variables are named ;; sh-indent-for-XXX and sh-indent-after-XXX. For example. ;; sh-indent-after-if controls the indenting of a line following ;; an if statement, and sh-indent-for-fi controls the indentation ;; of the line containing the fi. -;; +;; ;; You can set each to a numeric value, but it is often more convenient ;; to a symbol such as `+' which uses the value of variable `sh-basic-offset'. ;; By changing this one variable you can increase or decrease how much ;; indentation there is. Valid symbols: -;; +;; ;; + Indent right by sh-basic-offset ;; - Indent left by sh-basic-offset ;; ++ Indent right twice sh-basic-offset ;; -- Indent left twice sh-basic-offset ;; * Indent right half sh-basic-offset ;; / Indent left half sh-basic-offset. -;; +;; ;; There are 4 commands to help set the indentation variables: -;; +;; ;; `sh-show-indent' ;; This shows what variable controls the indentation of the current ;; line and its value. -;; +;; ;; `sh-set-indent' ;; This allows you to set the value of the variable controlling the ;; current line's indentation. You can enter a number or one of a @@ -79,13 +79,13 @@ ;; or its negative, or half it, or twice it, etc. If you've used ;; cc-mode this should be familiar. If you forget which symbols are ;; valid simply press C-h at the prompt. -;; +;; ;; `sh-learn-line-indent' ;; Simply make the line look the way you want it, then invoke this ;; command. It will set the variable to the value that makes the line ;; indent like that. If called with a prefix argument then it will set ;; the value to one of the symbols if applicable. -;; +;; ;; `sh-learn-buffer-indent' ;; This is the deluxe function! It "learns" the whole buffer (use ;; narrowing if you want it to process only part). It outputs to a @@ -98,7 +98,7 @@ ;; pattern; if they don't it will be set to nil. ;; Whether `sh-basic-offset' is set is determined by variable ;; `sh-learn-basic-offset'. -;; +;; ;; Unfortunately, `sh-learn-buffer-indent' can take a long time to run ;; (e.g. if there are large case statements). Perhaps it does not make ;; sense to run it on large buffers: if lots of lines have different @@ -106,7 +106,7 @@ ;; *indent* buffer; if there is a consistent style then running ;; `sh-learn-buffer-indent' on a small region of the buffer should ;; suffice. -;; +;; ;; Saving indentation values ;; ------------------------- ;; After you've learned the values in a buffer, how to you remember @@ -115,14 +115,14 @@ ;; the buffer. ;; You can do this automatically like this: ;; (add-hook 'sh-set-shell-hook 'sh-learn-buffer-indent) -;; +;; ;; However... `sh-learn-buffer-indent' is extremely slow, ;; especially on large-ish buffer. Also, if there are conflicts the ;; "last one wins" which may not produce the desired setting. -;; +;; ;; So...There is a minimal way of being able to save indentation values and ;; to reload them in another buffer or at another point in time. -;; +;; ;; Use `sh-name-style' to give a name to the indentation settings of ;; the current buffer. ;; Use `sh-load-style' to load indentation settings for the current @@ -130,30 +130,30 @@ ;; Use `sh-save-styles-to-buffer' to write all the styles to a buffer ;; in lisp code. You can then store it in a file and later use ;; `load-file' to load it. -;; +;; ;; Indentation variables - buffer local or global? ;; ---------------------------------------------- ;; I think that often having them buffer-local makes sense, ;; especially if one is using `sh-learn-buffer-indent'. However, if ;; a user sets values using customization, these changes won't appear ;; to work if the variables are already local! -;; +;; ;; To get round this, there is a variable `sh-make-vars-local' and 2 ;; functions: `sh-make-vars-local' and `sh-reset-indent-vars-to-global-values'. -;; +;; ;; If `sh-make-vars-local' is non-nil, then these variables become ;; buffer local when the mode is established. ;; If this is nil, then the variables are global. At any time you ;; can make them local with the command `sh-make-vars-local'. ;; Conversely, to update with the global values you can use the ;; command `sh-reset-indent-vars-to-global-values'. -;; +;; ;; This may be awkward, but the intent is to cover all cases. -;; +;; ;; Awkward things, pitfalls ;; ------------------------ ;; Indentation for a sh script is complicated for a number of reasons: -;; +;; ;; 1. You can't format by simply looking at symbols, you need to look ;; at keywords. [This is not the case for rc and es shells.] ;; 2. The character ")" is used both as a matched pair "(" ... ")" and @@ -165,7 +165,7 @@ ;; 4. A line may be continued using the "\". ;; 5. The character "#" (outside a string) normally starts a comment, ;; but it doesn't in the sequence "$#"! -;; +;; ;; To try and address points 2 3 and 5 I used a feature that cperl mode ;; uses, that of a text's syntax property. This, however, has 2 ;; disadvantages: @@ -175,14 +175,14 @@ ;; buffer is read-only buffer we have to cheat and bypass the read-only ;; status. This is for cases where the buffer started read-only buffer ;; but the user issued `toggle-read-only'. -;; +;; ;; Bugs ;; ---- ;; - Indenting many lines is slow. It currently does each line ;; independently, rather than saving state information. -;; +;; ;; - `sh-learn-buffer-indent' is extremely slow. -;; +;; ;; Richard Sharman June 1999. ;;; Code: @@ -1032,7 +1032,7 @@ does not affect then else elif or fi statements themselves." :group 'sh-indentation) (defcustom sh-indent-for-then '+ - "*How much to indent an then relative to an if." + "*How much to indent a then relative to an if." :type `(choice ,@ sh-number-or-symbol-list ) :group 'sh-indentation) @@ -1932,7 +1932,7 @@ STRING This is ignored for the purposes of calculating (setq have-result nil) )) ) ;; cond - + (unless have-result ;; Continuation lines are handled specially (if (sh-this-is-a-continuation) @@ -2025,19 +2025,19 @@ STRING This is ignored for the purposes of calculating (sh-debug "No prev line!") (sh-debug "result: %s align-point: %s" result align-point) ) - + (if align-point ;; was: (setq result (append result (list (list t align-point)))) (setq result (append (list (list t align-point)) result)) ) (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))) )) - + (if (eq result t) (setq result nil)) (sh-debug "result is: %s" result) @@ -2213,7 +2213,7 @@ we go to the end of the previous line and do not check for continuations." ;; Possible return values: ;; nil - nothing ;; a string - possibly a keyword - ;; + ;; (if (bolp) nil (let ((going t) @@ -2587,7 +2587,7 @@ unless optional argument ARG (the prefix when interactive) is non-nil." ((numberp (setq sval (sh-var-value var))) (setq ival (sh-calculate-indent info)) (setq diff (- curr-indent ival)) - + (sh-debug "curr-indent: %d ival: %d diff: %d var:%s sval %s" curr-indent ival diff var sval) (setq new-val (+ sval diff)) @@ -2664,7 +2664,7 @@ so that `occur-next' and `occur-prev' will work." (defvar sh-learned-buffer-hook nil "*An abnormal hook, called with an alist of learned variables.") ;;; Example of how to use sh-learned-buffer-hook -;; +;; ;; (defun what-i-learned (list) ;; (let ((p list)) ;; (save-excursion @@ -2677,7 +2677,7 @@ so that `occur-next' and `occur-prev' will work." ;; (setq p (cdr p))) ;; (insert ")\n") ;; ))) -;; +;; ;; (add-hook 'sh-learned-buffer-hook 'what-i-learned) @@ -2869,7 +2869,7 @@ This command can often take a long time to run." (format "Suggested sh-basic-offset: %d" suggested)) nil out-buffer)))) - + (setq learned-var-list (append (list (list 'sh-indent-comment comment-col (point-max))) learned-var-list))