aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2010-05-14 17:21:12 -0400
committerStefan Monnier2010-05-14 17:21:12 -0400
commit5ccaa35996841a6b28de93e346f57a3ff7f6f640 (patch)
treeb71c62376cdc7fc33fca952b25455629173629e5
parent4e2db1fe4be382f540f175316f3608fe4a9a93ae (diff)
downloademacs-5ccaa35996841a6b28de93e346f57a3ff7f6f640.tar.gz
emacs-5ccaa35996841a6b28de93e346f57a3ff7f6f640.zip
* progmodes/sh-script.el (sh-mode-default-syntax-table): Remove.
(sh-mode-syntax-table): Give it a default value instead. (sh-header-marker): Make buffer-local. (sh-mode): Move make-local-variable to the corresponding setq. (sh-add-completer): Avoid gratuitously let-binding a buffer-local var. Use complete-with-action.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/sh-script.el124
2 files changed, 57 insertions, 74 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a80859f1a84..a2c7deece59 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
12010-05-14 Stefan Monnier <monnier@iro.umontreal.ca> 12010-05-14 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * progmodes/sh-script.el (sh-mode-default-syntax-table): Remove.
4 (sh-mode-syntax-table): Give it a default value instead.
5 (sh-header-marker): Make buffer-local.
6 (sh-mode): Move make-local-variable to the corresponding setq.
7 (sh-add-completer): Avoid gratuitously let-binding a buffer-local var.
8 Use complete-with-action.
9
3 * simple.el (prog-mode): New (abstract) major mode. 10 * simple.el (prog-mode): New (abstract) major mode.
4 * emacs-lisp/lisp-mode.el (emacs-lisp-mode, lisp-mode): Use it. 11 * emacs-lisp/lisp-mode.el (emacs-lisp-mode, lisp-mode): Use it.
5 * progmodes/sh-script.el (sh-mode): Remove redundant var assignment. 12 * progmodes/sh-script.el (sh-mode): Remove redundant var assignment.
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 478b0e33431..5f4028af89a 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -411,11 +411,7 @@ the car and cdr are the same symbol.")
411 (modify-syntax-entry (pop list) (pop list) table)) 411 (modify-syntax-entry (pop list) (pop list) table))
412 table) 412 table)
413 413
414(defvar sh-mode-syntax-table nil 414(defvar sh-mode-syntax-table
415 "The syntax table to use for Shell-Script mode.
416This is buffer-local in every such buffer.")
417
418(defvar sh-mode-default-syntax-table
419 (sh-mode-syntax-table () 415 (sh-mode-syntax-table ()
420 ?\# "<" 416 ?\# "<"
421 ?\n ">#" 417 ?\n ">#"
@@ -436,7 +432,8 @@ This is buffer-local in every such buffer.")
436 ?= "." 432 ?= "."
437 ?< "." 433 ?< "."
438 ?> ".") 434 ?> ".")
439 "Default syntax table for shell mode.") 435 "The syntax table to use for Shell-Script mode.
436This is buffer-local in every such buffer.")
440 437
441(defvar sh-mode-syntax-table-input 438(defvar sh-mode-syntax-table-input
442 '((sh . nil)) 439 '((sh . nil))
@@ -611,7 +608,7 @@ sign. See `sh-feature'."
611(defvar sh-header-marker nil 608(defvar sh-header-marker nil
612 "When non-nil is the end of header for prepending by \\[sh-execute-region]. 609 "When non-nil is the end of header for prepending by \\[sh-execute-region].
613That command is also used for setting this variable.") 610That command is also used for setting this variable.")
614 611(make-variable-buffer-local 'sh-header-marker)
615 612
616(defcustom sh-beginning-of-command 613(defcustom sh-beginning-of-command
617 "\\([;({`|&]\\|\\`\\|[^\\]\n\\)[ \t]*\\([/~[:alnum:]:]\\)" 614 "\\([;({`|&]\\|\\`\\|[^\\]\n\\)[ \t]*\\([/~[:alnum:]:]\\)"
@@ -1533,54 +1530,39 @@ indicate what shell it is use `sh-alias-alist' to translate.
1533 1530
1534If your shell gives error messages with line numbers, you can use \\[executable-interpret] 1531If your shell gives error messages with line numbers, you can use \\[executable-interpret]
1535with your script for an edit-interpret-debug cycle." 1532with your script for an edit-interpret-debug cycle."
1536 (make-local-variable 'skeleton-end-hook)
1537 (make-local-variable 'paragraph-start)
1538 (make-local-variable 'paragraph-separate)
1539 (make-local-variable 'comment-start)
1540 (make-local-variable 'comment-start-skip)
1541 (make-local-variable 'require-final-newline)
1542 (make-local-variable 'sh-header-marker)
1543 (make-local-variable 'sh-shell-file) 1533 (make-local-variable 'sh-shell-file)
1544 (make-local-variable 'sh-shell) 1534 (make-local-variable 'sh-shell)
1545 (make-local-variable 'skeleton-pair-alist) 1535
1546 (make-local-variable 'skeleton-pair-filter-function) 1536 (set (make-local-variable 'skeleton-pair-default-alist)
1547 (make-local-variable 'comint-dynamic-complete-functions) 1537 sh-skeleton-pair-default-alist)
1548 (make-local-variable 'comint-prompt-regexp) 1538 (set (make-local-variable 'skeleton-end-hook)
1549 (make-local-variable 'font-lock-defaults) 1539 (lambda () (or (eolp) (newline) (indent-relative))))
1550 (make-local-variable 'skeleton-filter-function) 1540
1551 (make-local-variable 'skeleton-newline-indent-rigidly) 1541 (set (make-local-variable 'paragraph-start) (concat page-delimiter "\\|$"))
1552 (make-local-variable 'sh-shell-variables) 1542 (set (make-local-variable 'paragraph-separate) paragraph-start)
1553 (make-local-variable 'sh-shell-variables-initialized) 1543 (set (make-local-variable 'comment-start) "# ")
1554 (make-local-variable 'imenu-generic-expression) 1544 (set (make-local-variable 'comment-start-skip) "#+[\t ]*")
1555 (make-local-variable 'sh-indent-supported-here) 1545 (set (make-local-variable 'local-abbrev-table) sh-mode-abbrev-table)
1556 (make-local-variable 'skeleton-pair-default-alist) 1546 (set (make-local-variable 'comint-dynamic-complete-functions)
1557 (setq skeleton-pair-default-alist sh-skeleton-pair-default-alist) 1547 sh-dynamic-complete-functions)
1558 (setq skeleton-end-hook (lambda () 1548 ;; we can't look if previous line ended with `\'
1559 (or (eolp) (newline) (indent-relative))) 1549 (set (make-local-variable 'comint-prompt-regexp) "^[ \t]*")
1560 paragraph-start (concat page-delimiter "\\|$") 1550 (set (make-local-variable 'imenu-case-fold-search) nil)
1561 paragraph-separate paragraph-start 1551 (set (make-local-variable 'font-lock-defaults)
1562 comment-start "# " 1552 `((sh-font-lock-keywords
1563 comment-start-skip "#+[\t ]*" 1553 sh-font-lock-keywords-1 sh-font-lock-keywords-2)
1564 local-abbrev-table sh-mode-abbrev-table 1554 nil nil
1565 comint-dynamic-complete-functions sh-dynamic-complete-functions 1555 ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w")) nil
1566 ;; we can't look if previous line ended with `\' 1556 (font-lock-syntactic-keywords . sh-font-lock-syntactic-keywords)
1567 comint-prompt-regexp "^[ \t]*" 1557 (font-lock-syntactic-face-function
1568 imenu-case-fold-search nil 1558 . sh-font-lock-syntactic-face-function)))
1569 font-lock-defaults 1559 (set (make-local-variable 'skeleton-pair-alist) '((?` _ ?`)))
1570 `((sh-font-lock-keywords 1560 (set (make-local-variable 'skeleton-pair-filter-function) 'sh-quoted-p)
1571 sh-font-lock-keywords-1 sh-font-lock-keywords-2) 1561 (set (make-local-variable 'skeleton-further-elements)
1572 nil nil 1562 '((< '(- (min sh-indentation (current-column))))))
1573 ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w")) nil 1563 (set (make-local-variable 'skeleton-filter-function) 'sh-feature)
1574 (font-lock-syntactic-keywords . sh-font-lock-syntactic-keywords) 1564 (set (make-local-variable 'skeleton-newline-indent-rigidly) t)
1575 (font-lock-syntactic-face-function 1565 (set (make-local-variable 'sh-indent-supported-here) nil)
1576 . sh-font-lock-syntactic-face-function))
1577 skeleton-pair-alist '((?` _ ?`))
1578 skeleton-pair-filter-function 'sh-quoted-p
1579 skeleton-further-elements '((< '(- (min sh-indentation
1580 (current-column)))))
1581 skeleton-filter-function 'sh-feature
1582 skeleton-newline-indent-rigidly t
1583 sh-indent-supported-here nil)
1584 (set (make-local-variable 'defun-prompt-regexp) 1566 (set (make-local-variable 'defun-prompt-regexp)
1585 (concat "^\\(function[ \t]\\|[[:alnum:]]+[ \t]+()[ \t]+\\)")) 1567 (concat "^\\(function[ \t]\\|[[:alnum:]]+[ \t]+()[ \t]+\\)"))
1586 ;; Parse or insert magic number for exec, and set all variables depending 1568 ;; Parse or insert magic number for exec, and set all variables depending
@@ -1736,21 +1718,20 @@ Calls the value of `sh-set-shell-hook' if set."
1736 no-query-flag insert-flag))) 1718 no-query-flag insert-flag)))
1737 (let ((tem (sh-feature sh-require-final-newline))) 1719 (let ((tem (sh-feature sh-require-final-newline)))
1738 (if (eq tem t) 1720 (if (eq tem t)
1739 (setq require-final-newline mode-require-final-newline))) 1721 (set (make-local-variable 'require-final-newline)
1740 (setq 1722 mode-require-final-newline)))
1741 mode-line-process (format "[%s]" sh-shell) 1723 (setq mode-line-process (format "[%s]" sh-shell))
1742 sh-shell-variables nil 1724 (set (make-local-variable 'sh-shell-variables) nil)
1743 sh-shell-variables-initialized nil 1725 (set (make-local-variable 'sh-shell-variables-initialized) nil)
1744 imenu-generic-expression (sh-feature sh-imenu-generic-expression)) 1726 (set (make-local-variable 'imenu-generic-expression)
1745 (make-local-variable 'sh-mode-syntax-table) 1727 (sh-feature sh-imenu-generic-expression))
1746 (let ((tem (sh-feature sh-mode-syntax-table-input))) 1728 (let ((tem (sh-feature sh-mode-syntax-table-input)))
1747 (setq sh-mode-syntax-table 1729 (when tem
1748 (if tem (apply 'sh-mode-syntax-table tem) 1730 (set (make-local-variable 'sh-mode-syntax-table)
1749 sh-mode-default-syntax-table))) 1731 (apply 'sh-mode-syntax-table tem))
1750 (set-syntax-table sh-mode-syntax-table) 1732 (set-syntax-table sh-mode-syntax-table)))
1751 (dolist (var (sh-feature sh-variables)) 1733 (dolist (var (sh-feature sh-variables))
1752 (sh-remember-variable var)) 1734 (sh-remember-variable var))
1753 (make-local-variable 'indent-line-function)
1754 (if (setq sh-indent-supported-here (sh-feature sh-indent-supported)) 1735 (if (setq sh-indent-supported-here (sh-feature sh-indent-supported))
1755 (progn 1736 (progn
1756 (message "Setting up indent for shell type %s" sh-shell) 1737 (message "Setting up indent for shell type %s" sh-shell)
@@ -1763,7 +1744,7 @@ Calls the value of `sh-set-shell-hook' if set."
1763 (message "setting up indent stuff") 1744 (message "setting up indent stuff")
1764 ;; sh-mode has already made indent-line-function local 1745 ;; sh-mode has already made indent-line-function local
1765 ;; but do it in case this is called before that. 1746 ;; but do it in case this is called before that.
1766 (setq indent-line-function 'sh-indent-line) 1747 (set (make-local-variable 'indent-line-function) 'sh-indent-line)
1767 (if sh-make-vars-local 1748 (if sh-make-vars-local
1768 (sh-make-vars-local)) 1749 (sh-make-vars-local))
1769 (message "Indentation setup for shell type %s" sh-shell)) 1750 (message "Indentation setup for shell type %s" sh-shell))
@@ -3462,20 +3443,15 @@ CODE can be nil, t or `lambda'.
3462nil means to return the best completion of STRING, or nil if there is none. 3443nil means to return the best completion of STRING, or nil if there is none.
3463t means to return a list of all possible completions of STRING. 3444t means to return a list of all possible completions of STRING.
3464`lambda' means to return t if STRING is a valid completion as it stands." 3445`lambda' means to return t if STRING is a valid completion as it stands."
3465 (let ((sh-shell-variables 3446 (let ((vars
3466 (with-current-buffer sh-add-buffer 3447 (with-current-buffer sh-add-buffer
3467 (or sh-shell-variables-initialized 3448 (or sh-shell-variables-initialized
3468 (sh-shell-initialize-variables)) 3449 (sh-shell-initialize-variables))
3469 (nconc (mapcar (lambda (var) 3450 (nconc (mapcar (lambda (var)
3470 (let ((name 3451 (substring var 0 (string-match "=" var)))
3471 (substring var 0 (string-match "=" var))))
3472 (cons name name)))
3473 process-environment) 3452 process-environment)
3474 sh-shell-variables)))) 3453 sh-shell-variables))))
3475 (case code 3454 (complete-with-action code vars string predicate)))
3476 ((nil) (try-completion string sh-shell-variables predicate))
3477 (lambda (test-completion string sh-shell-variables predicate))
3478 (t (all-completions string sh-shell-variables predicate)))))
3479 3455
3480(defun sh-add (var delta) 3456(defun sh-add (var delta)
3481 "Insert an addition of VAR and prefix DELTA for Bourne (type) shell." 3457 "Insert an addition of VAR and prefix DELTA for Bourne (type) shell."