diff -cb MY-PATH/emacs/20080227/emacs/lisp/progmodes/sh-script-sicherung.el MY-PATH/emacs/20080227/emacs/lisp/progmodes/sh-script.el *** MY-PATH/emacs/20080227/emacs/lisp/progmodes/sh-script-sicherung.el 2008-02-28 13:07:01.000000000 +0100 --- MY-PATH/emacs/20080227/emacs/lisp/progmodes/sh-script.el 2008-02-28 13:22:10.000000000 +0100 *************** *** 2140,2146 **** n thing (point) rule val))) val)) - (defun sh-get-indent-info () "Return indent-info for this line. This is a list. nil means the line is to be left as is. --- 2140,2145 ---- *************** *** 2185,2202 **** ;; we still need to get previous line in case ;; sh-indent-comment is t (indent as normal) (setq align-point (sh-prev-line nil)) ! (setq have-result nil) ! )) ! ) ;; cond ! (unless have-result ;; Continuation lines are handled specially ! (if (sh-this-is-a-continuation) (progn (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 --- 2184,2200 ---- ;; we still need to get previous line in case ;; sh-indent-comment is t (indent as normal) (setq align-point (sh-prev-line nil)) ! (setq have-result nil)))) ;; cond (unless have-result ;; Continuation lines are handled specially ! (if (or (sh-this-is-a-continuation) ! (sh-short-if)) (progn (setq result ! (if (and (not (sh-short-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 *************** *** 2211,2217 **** (beginning-of-line) (skip-chars-forward " \t") (setq this-kw (sh-get-kw))) - ;; Handle "this" keyword: first word on the line we're ;; calculating indentation info for. (if this-kw --- 2209,2214 ---- *************** *** 2224,2235 **** (setq have-result t) ;; set prev-line to continue processing remainder ;; of this line as a previous line ! (setq prev-line-end (point)) ! )))) ! (unless have-result (setq prev-line-end (sh-prev-line 'end))) - (if prev-line-end (save-excursion ;; We start off at beginning of this line. --- 2221,2229 ---- (setq have-result t) ;; set prev-line to continue processing remainder ;; of this line as a previous line ! (setq prev-line-end (point)))))) (unless have-result (setq prev-line-end (sh-prev-line 'end))) (if prev-line-end (save-excursion ;; We start off at beginning of this line. *************** *** 2253,2268 **** (or (bobp) (forward-char -1)) ;; FIXME: This charset looks too much like a regexp. --Stef ! (skip-chars-forward "[a-z0-9]*?") ! ) ((string-match "[])}]" x) (setq x (sh-safe-forward-sexp -1)) (if x (progn (setq align-point (point)) (setq result (append result ! (list "aligned to opening paren"))) ! ))) ((string-match "[[({]" x) (sh-debug "Checking special thing: %s" x) (if (setq val (sh-check-rule 2 x)) --- 2247,2260 ---- (or (bobp) (forward-char -1)) ;; FIXME: This charset looks too much like a regexp. --Stef ! (skip-chars-forward "[a-z0-9]*?")) ((string-match "[])}]" x) (setq x (sh-safe-forward-sexp -1)) (if x (progn (setq align-point (point)) (setq result (append result ! (list "aligned to opening paren")))))) ((string-match "[[({]" x) (sh-debug "Checking special thing: %s" x) (if (setq val (sh-check-rule 2 x)) *************** *** 2284,2317 **** (unless (bolp) (forward-char -1))) (t ! (error "Don't know what to do with %s" x)) ! ) ! ) ;; while ! (sh-debug "result is %s" result) ! ) (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 (setq result (list (if prev-line-end (list t prev-line-end) (list '= 'sh-first-lines-indent))))) - (if (eq result t) (setq result nil)) (sh-debug "result is: %s" result) ! result ! ) ;; let )) - (defun sh-get-indent-var-for-line (&optional info) "Return the variable controlling indentation for this line. If there is not [just] one such variable, return a string --- 2276,2299 ---- (unless (bolp) (forward-char -1))) (t ! (error "Don't know what to do with %s" x)))) ;; while ! (sh-debug "result is %s" result)) (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 (setq result (list (if prev-line-end (list t prev-line-end) (list '= 'sh-first-lines-indent))))) (if (eq result t) (setq result nil)) (sh-debug "result is: %s" result) ! result) ;; let )) (defun sh-get-indent-var-for-line (&optional info) "Return the variable controlling indentation for this line. If there is not [just] one such variable, return a string *************** *** 2529,2534 **** --- 2511,2524 ---- (looking-at ".*\\\\$") (not (nth 4 (parse-partial-sexp (match-beginning 0) (match-end 0) nil nil nil t)))))) + (defun sh-short-if () + "Return non-nil if current line ends with a `\&\&' or `\|\|'." + (save-excursion + (and (zerop (forward-line -1)) + (or (looking-at ".*&&[ \t]*$") + (looking-at ".*||[ \t]*$")) + (not (nth 4 (parse-partial-sexp (match-beginning 0) (match-end 0) + nil nil nil t)))))) (defun sh-get-kw (&optional where and-move) "Return first word of line from WHERE. Diff finished. Thu Feb 28 13:29:52 2008