• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/progmodes/

Lines Matching +defs:indent +defs:string

52 ;; sh-indent-for-XXX and sh-indent-after-XXX.  For example.
53 ;; sh-indent-after-if controls the indenting of a line following
54 ;; an if statement, and sh-indent-for-fi controls the indentation
71 ;; `sh-show-indent'
75 ;; `sh-set-indent'
83 ;; `sh-learn-line-indent'
86 ;; indent like that. If called with a prefix argument then it will set
89 ;; `sh-learn-buffer-indent'
92 ;; buffer *indent* any conflicts it finds, and all the variables it has
97 ;; `sh-indent-comment' will be set if all comments follow the same
102 ;; Unfortunately, `sh-learn-buffer-indent' can take a long time to run
106 ;; *indent* buffer; if there is a consistent style then running
107 ;; `sh-learn-buffer-indent' on a small region of the buffer should
113 ;; them? Originally I had hoped that `sh-learn-buffer-indent'
117 ;; (add-hook 'sh-set-shell-hook 'sh-learn-buffer-indent)
119 ;; However... `sh-learn-buffer-indent' is extremely slow,
137 ;; especially if one is using `sh-learn-buffer-indent'. However, if
142 ;; functions: `sh-make-vars-local' and `sh-reset-indent-vars-to-global-values'.
149 ;; command `sh-reset-indent-vars-to-global-values'.
166 ;; 5. The character "#" (outside a string) normally starts a comment,
184 ;; - `sh-learn-buffer-indent' is extremely slow.
204 (defvar font-lock-string-face)
300 :type 'string
318 "*Single argument string for the magic number. See `sh-feature'."
321 (string :tag "Arguments")
332 string
350 (if (string-match "\\.exe\\'" shell)
456 (define-key map "\C-c?" 'sh-show-indent)
457 (define-key map "\C-c=" 'sh-set-indent)
458 (define-key map "\C-c<" 'sh-learn-line-indent)
459 (define-key map "\C-c>" 'sh-learn-buffer-indent)
475 (define-key map [remap newline-and-indent] 'sh-newline-and-indent)
572 If the first character of this string is \"-\", this is taken as
585 :type 'string
663 (choice (repeat string)
685 (choice (repeat string)
722 (choice (repeat string)
834 (defface sh-escaped-newline '((t :inherit font-lock-string-face))
863 ;; Using font-lock-string-face here confuses sh-get-indent-info.
865 ("\\\\[^A-Za-z0-9]" 0 font-lock-string-face)
883 (defconst sh-st-punc (string-to-syntax "."))
884 (defconst sh-st-symbol (string-to-syntax "_"))
885 (defconst sh-here-doc-syntax (string-to-syntax "|")) ;; generic string
922 (not (sh-in-comment-or-string (match-beginning 0))))
932 (sh-in-comment-or-string (point)))))
945 (defun sh-font-lock-open-heredoc (start string)
953 (sh-in-comment-or-string start))
956 (let ((str (replace-regexp-in-string "['\"]" "" string)))
984 "Search for a subshell embedded in a string.
999 (bq (equal (match-string 1) "`")) ;; ` state flip-flop
1090 (match-beginning 0) (match-string 1)) nil t)
1092 (match-beginning 0) (match-string 4)
1106 (if (eq q ?\`) 'sh-quoted-exec font-lock-string-face)
1116 and command `sh-reset-indent-vars-to-global-values'."
1143 "*Controls when `sh-learn-buffer-indent' pops the `*indent*' buffer.
1152 "*If non-nil, `sh-show-indent' shows the line indentation is relative to.
1159 (defcustom sh-first-lines-indent 0
1176 (defcustom sh-indent-comment nil
1179 t means indent it as a normal line, aligning it to previous non-blank
1215 (defcustom sh-indent-for-else 0
1216 "*How much to indent an `else' relative to its `if'. Usually 0."
1218 (integer :menu-tag "A number (positive=>indent right)"
1226 (append '((integer :menu-tag "A number (positive=>indent right)"
1231 (defcustom sh-indent-for-fi 0
1232 "*How much to indent a `fi' relative to its `if'. Usually 0."
1236 (defcustom sh-indent-for-done 0
1237 "*How much to indent a `done' relative to its matching stmt. Usually 0."
1241 (defcustom sh-indent-after-else '+
1242 "*How much to indent a statement after an `else' statement."
1246 (defcustom sh-indent-after-if '+
1247 "*How much to indent a statement after an `if' statement.
1253 (defcustom sh-indent-for-then 0
1254 "*How much to indent a `then' relative to its `if'."
1258 (defcustom sh-indent-for-do 0
1259 "*How much to indent a `do' statement.
1265 (defcustom sh-indent-after-do '+
1266 "*How much to indent a line after a `do' statement.
1273 (defcustom sh-indent-after-loop-construct '+
1274 "*How much to indent a statement after a loop construct.
1278 If the `do' is on a line by itself, then `sh-indent-after-do' is used instead."
1283 (defcustom sh-indent-after-done 0
1284 "*How much to indent a statement after a `done' keyword.
1292 (defcustom sh-indent-for-case-label '+
1293 "*How much to indent a case label statement.
1298 (defcustom sh-indent-for-case-alt '++
1299 "*How much to indent statements after the case label.
1305 (defcustom sh-indent-for-continuation '+
1306 "*How much to indent for a continuation statement."
1310 (defcustom sh-indent-after-open '+
1311 "*How much to indent after a line with an opening parenthesis or brace.
1312 For an open paren after a function, `sh-indent-after-function' is used."
1316 (defcustom sh-indent-after-function '+
1317 "*How much to indent after a function line."
1323 (defcustom sh-indent-after-switch '+
1324 "*How much to indent a `case' statement relative to the `switch' statement.
1329 (defcustom sh-indent-after-case '+
1330 "*How much to indent a statement relative to the `case' statement.
1364 (defconst sh-indent-supported
1370 (defvar sh-indent-supported-here nil
1375 sh-basic-offset sh-first-lines-indent sh-indent-after-case
1376 sh-indent-after-do sh-indent-after-done
1377 sh-indent-after-else
1378 sh-indent-after-if
1379 sh-indent-after-loop-construct
1380 sh-indent-after-open
1381 sh-indent-comment
1382 sh-indent-for-case-alt
1383 sh-indent-for-case-label
1384 sh-indent-for-continuation
1385 sh-indent-for-do
1386 sh-indent-for-done
1387 sh-indent-for-else
1388 sh-indent-for-fi
1389 sh-indent-for-then
1436 \\[sh-show-indent] Show the variable controlling this line's indentation.
1437 \\[sh-set-indent] Set then variable controlling this line's indentation.
1438 \\[sh-learn-line-indent] Change the indentation variable so this line
1439 would indent to the way it currently is.
1440 \\[sh-learn-buffer-indent] Set the indentation variables so the
1445 \\[sh-newline-and-indent] Delete unquoted space and indent new line same as this one.
1481 (make-local-variable 'skeleton-newline-indent-rigidly)
1485 (make-local-variable 'sh-indent-supported-here)
1489 (or (eolp) (newline) (indent-relative)))
1512 skeleton-newline-indent-rigidly t
1513 sh-indent-supported-here nil)
1521 (match-string 2))
1525 ((string-match "\\.m?spec\\'" buffer-file-name)
1527 ((string-match "[.]sh\\>" buffer-file-name)
1529 ((string-match "[.]bash\\>" buffer-file-name)
1531 ((string-match "[.]ksh\\>" buffer-file-name)
1533 ((string-match "[.]csh\\>" buffer-file-name)
1595 ;; The keyword is usually a string and is the first word on a line.
1603 ;; `sh-get-indent-info' does not stop but may keep going and test
1640 "Set this buffer's shell to SHELL (a string).
1658 (if (string-match "\\.exe\\'" shell)
1683 (make-local-variable 'indent-line-function)
1684 (if (setq sh-indent-supported-here (sh-feature sh-indent-supported))
1686 (message "Setting up indent for shell type %s" sh-shell)
1693 (message "setting up indent stuff")
1694 ;; sh-mode has already made indent-line-function local
1696 (setq indent-line-function 'sh-indent-line)
1701 (setq indent-line-function 'sh-basic-indent-line))
1767 ;;EXPANSION may be either a string or a skeleton command."
1810 (defun sh-basic-indent-line ()
1826 (indent-to (if (eq this-command 'newline-and-indent)
1883 (defun sh-must-support-indent ()
1886 (unless sh-indent-supported-here
1895 command `sh-reset-indent-vars-to-global-values'."
1900 (defun sh-reset-indent-vars-to-global-values ()
1913 (defun sh-help-string-for-variable (var)
1914 "Construct a string for `sh-read-variable' when changing variable VAR ."
1917 (unless (memq var '(sh-first-lines-indent sh-indent-comment))
1940 (let ((minibuffer-help-form `(sh-help-string-for-variable
1952 (defun sh-in-comment-or-string (start)
1953 "Return non-nil if START is in a comment or string."
1971 (list '(+ sh-indent-after-if)))
1976 (list "aligned to if" '(+ sh-indent-for-else))
1982 (list '(+ sh-indent-after-if))
1987 (list "aligned to if" '(+ sh-indent-for-fi))
1993 ;; to get its indent. We may continue back from there.
1996 ;; we could return a comment (a string) but I can't think of a good one...
2003 (list '(+ sh-indent-for-then))
2009 (list '(+ sh-indent-after-if))
2022 (list '(+ sh-indent-after-function))
2023 (list '(+ sh-indent-after-open)))
2039 (list '(+ sh-indent-for-case-label))
2052 (list '(+ sh-indent-for-case-alt))))
2056 (list '(+ sh-indent-for-case-label))))
2076 (list "aligned to do stmt" '(+ sh-indent-for-done))))
2084 (list '(+ sh-indent-for-do))))
2096 (list '(+ sh-indent-after-loop-construct)))
2099 (list '(+ sh-indent-after-do)))
2111 (list '(+ sh-indent-after-switch))
2112 ;; (list '(+ sh-indent-for-case-label))
2116 (list '(+ sh-indent-after-case)))
2129 (defun sh-get-indent-info ()
2130 "Return indent-info for this line.
2143 special variables such as `sh-indent-comment'.
2160 ((or (and (boundp 'font-lock-string-face) (not (bobp))
2162 font-lock-string-face))
2169 (setq result (list '(= sh-indent-comment)))
2171 ;; sh-indent-comment is t (indent as normal)
2188 ;; added/removed. I.e. do not indent the line.
2194 (list '(+ sh-indent-for-continuation))))
2242 ((string-match "[])}]" x)
2250 ((string-match "[[({]" x)
2256 ((string-match "[\"'`]" x)
2261 (sh-debug "Checking string %s at %s" x (point))
2289 (list '= 'sh-first-lines-indent)))))
2299 (defun sh-get-indent-var-for-line (&optional info)
2301 If there is not [just] one such variable, return a string
2309 (setq info (sh-get-indent-info)))
2319 (error "sh-get-indent-var-for-line invalid elt: %s" elt))
2324 ;; A bit of a kludge - when we see the sh-indent-comment
2327 (if (eq var 'sh-indent-comment)
2334 (error "sh-get-indent-var-for-line invalid list elt: %s" elt)))
2391 ;; appears in a string or quote. This way is slower, but (I think) safer.
2455 ;; This is called when `sh-get-indent-info' is working backwards on
2464 ;; a string - possibly a keyword
2481 ;; c -- return a string
2482 (char-to-string c)
2622 (defun sh-calculate-indent (&optional info)
2629 (setq info (sh-get-indent-info)))
2654 ((eq val t) (setq ofs 0)) ;; indent as normal line
2662 (error "sh-calculate-indent invalid a a=%s b=%s" a b))))
2664 (error "sh-calculate-indent invalid elt: a=%s b=%s" a b))))
2666 (error "sh-calculate-indent invalid elt %s" elt)))
2681 (error "sh-calculate-indent: Help. base-value=%s ofs=%s"
2686 (defun sh-indent-line ()
2689 (let ((indent (sh-calculate-indent))
2691 (when indent
2694 (indent-line-to indent)
2711 (defun sh-show-indent (arg)
2720 (sh-must-support-indent)
2721 (let* ((info (sh-get-indent-info))
2722 (var (sh-get-indent-var-for-line info))
2723 (curr-indent (current-indentation))
2727 (setq val (sh-calculate-indent info))
2729 (if (eq curr-indent val)
2733 (format "%s (%s) would change indent from %d to: %d"
2734 var (symbol-value var) curr-indent val)
2741 (let ((info (sh-get-indent-info)))
2749 (defun sh-set-indent ()
2754 (sh-must-support-indent)
2755 (let* ((info (sh-get-indent-info))
2756 (var (sh-get-indent-var-for-line info))
2757 val old-val indent-val)
2759 (message "Cannot set indent - %s" var)
2765 (setq indent-val (sh-calculate-indent info))
2766 (if indent-val
2767 (message "Variable: %s Value: %s would indent to: %d"
2768 var (symbol-value var) indent-val)
2774 ;; (sh-indent-line)
2785 (defun sh-learn-line-indent (arg)
2786 "Learn how to indent a line as it currently is indented.
2789 then set it to a value which would indent the line the way it
2795 (sh-must-support-indent)
2802 (message "sh-learn-line-indent ignores empty lines.")
2803 (let* ((info (sh-get-indent-info))
2804 (var (sh-get-indent-var-for-line info))
2807 (curr-indent (current-indentation)))
2811 ((eq var 'sh-indent-comment)
2813 ;; - if curr-indent is 0, set to curr-indent
2816 ;; - else set to curr-indent.
2817 (setq sh-indent-comment
2818 (if (= curr-indent 0)
2820 (let* ((sh-indent-comment t)
2821 (val2 (sh-calculate-indent info)))
2822 (if (= val2 curr-indent)
2824 curr-indent))))
2828 (setq ival (sh-calculate-indent info))
2829 (setq diff (- curr-indent ival))
2831 (sh-debug "curr-indent: %d ival: %d diff: %d var:%s sval %s"
2832 curr-indent ival diff var sval)
2918 ;; Originally this was sh-learn-region-indent (beg end)
2921 (defun sh-learn-buffer-indent (&optional arg)
2922 "Learn how to indent the buffer the way it currently is.
2924 Output in buffer \"*indent*\" shows any lines which have conflicting
2931 basic indent.
2944 (sh-must-support-indent)
2948 (out-buffer "*indent*")
2980 (let* ((sh-indent-comment t) ;; info must return default indent
2981 (info (sh-get-indent-info))
2982 (var (sh-get-indent-var-for-line info))
2984 (curr-indent (current-indentation)))
2992 (setq ival (sh-calculate-indent))
2993 (setq diff (- curr-indent ival))
3023 "This line's indent value: %d" new-val)
3029 ((eq var 'sh-indent-comment)
3030 (unless (= curr-indent (sh-calculate-indent info))
3034 (or (eq comment-col curr-indent)
3036 (setq comment-col curr-indent))
3101 (mapconcat 'int-to-string suggested " "))
3107 (append (list (list 'sh-indent-comment comment-col (point-max)))
3109 (setq sh-indent-comment comment-col)
3146 `sh-learn-buffer-indent'.
3198 (mapconcat 'int-to-string result " ")))
3275 > "case " (read-string "pattern: ") ?: \n
3289 > "case " (read-string "pattern: ") \n
3336 "while( $" str " <= " (read-string "upper limit: ") " )" \n
3345 (read-string "upper limit: ")
3352 (read-string "upper limit: ")
3359 (read-string "upper limit: ")
3365 (read-string "upper limit: ")
3385 (defun sh-add-completer (string predicate code)
3402 (substring var 0 (string-match "=" var))))
3407 ((nil) (try-completion string sh-shell-variables predicate))
3408 (lambda (test-completion string sh-shell-variables predicate))
3409 (t (all-completions string sh-shell-variables predicate)))))
3425 (number-to-string (abs delta))
3593 Prompts for an options string which consists of letters for each recognized
3604 '(if (string-match " +" str)
3630 ( (prog1 (if v1 (char-to-string (car v1)))
3668 (match-string 1))))))
3681 (let ((tabs (if (string-match "\\`-" sh-here-document-word)
3682 (make-string (/ (current-indentation) tab-width) ?\t)
3684 (delim (replace-regexp-in-string "['\"]" ""
3694 (insert ?\n tabs (replace-regexp-in-string
3715 (defun sh-newline-and-indent ()
3716 "Strip unquoted whitespace, insert newline, and indent like current line."
3718 (indent-to (prog1 (current-indentation)
3797 (indent-to column (if sh-backslash-align nil 1)))
3798 (indent-to column (if sh-backslash-align nil 1))