[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 7fbabaf: * lisp/progmodes/sh-script.el (sh-mode-map
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master 7fbabaf: * lisp/progmodes/sh-script.el (sh-mode-map): Don't bind `=` |
Date: |
Thu, 12 Sep 2019 14:26:46 -0400 (EDT) |
branch: master
commit 7fbabaf96ab55437b42e6365885c9c780726594c
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* lisp/progmodes/sh-script.el (sh-mode-map): Don't bind `=`
(sh-shell-initialize-variables): Use sh--assignment-collect on
post-self-insert-hook instead.
(sh--assignment-collect): New function, extracted from sh-assignment.
(sh-assignment): Use it and mark as obsolete.
---
lisp/progmodes/sh-script.el | 45 ++++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index aad38b9..230789e 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -112,7 +112,7 @@
;; would make this unnecessary; simply learn the values when you visit
;; the buffer.
;; You can do this automatically like this:
-;; (add-hook 'sh-set-shell-hook 'sh-learn-buffer-indent)
+;; (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
@@ -480,7 +480,6 @@ This is buffer-local in every such buffer.")
(define-key map "\C-c>" 'sh-learn-buffer-indent)
(define-key map "\C-c\C-\\" 'sh-backslash-region)
- (define-key map "=" 'sh-assignment)
(define-key map "\C-c+" 'sh-add)
(define-key map "\C-\M-x" 'sh-execute-region)
(define-key map "\C-c\C-x" 'executable-interpret)
@@ -1059,7 +1058,7 @@ subshells can nest."
(when (< startpos (line-beginning-position))
(put-text-property startpos (point) 'syntax-multiline t)
(add-hook 'syntax-propertize-extend-region-functions
- 'syntax-propertize-multiline nil t))
+ #'syntax-propertize-multiline nil t))
)))
@@ -1603,25 +1602,25 @@ with your script for an edit-interpret-debug cycle."
(setq-local local-abbrev-table sh-mode-abbrev-table)
(setq-local comint-dynamic-complete-functions
sh-dynamic-complete-functions)
- (add-hook 'completion-at-point-functions 'comint-completion-at-point nil t)
+ (add-hook 'completion-at-point-functions #'comint-completion-at-point nil t)
;; we can't look if previous line ended with `\'
(setq-local comint-prompt-regexp "^[ \t]*")
(setq-local imenu-case-fold-search nil)
(setq font-lock-defaults
- '((sh-font-lock-keywords
+ `((sh-font-lock-keywords
sh-font-lock-keywords-1 sh-font-lock-keywords-2)
nil nil
((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w")) nil
(font-lock-syntactic-face-function
- . sh-font-lock-syntactic-face-function)))
+ . ,#'sh-font-lock-syntactic-face-function)))
(setq-local syntax-propertize-function #'sh-syntax-propertize-function)
(add-hook 'syntax-propertize-extend-region-functions
#'syntax-propertize-multiline 'append 'local)
(setq-local skeleton-pair-alist '((?` _ ?`)))
- (setq-local skeleton-pair-filter-function 'sh-quoted-p)
+ (setq-local skeleton-pair-filter-function #'sh-quoted-p)
(setq-local skeleton-further-elements
'((< '(- (min sh-basic-offset (current-column))))))
- (setq-local skeleton-filter-function 'sh-feature)
+ (setq-local skeleton-filter-function #'sh-feature)
(setq-local skeleton-newline-indent-rigidly t)
(setq-local defun-prompt-regexp
(concat
@@ -2408,12 +2407,12 @@ whose value is the shell name (don't quote it)."
(message "setting up indent stuff")
;; sh-mode has already made indent-line-function local
;; but do it in case this is called before that.
- (setq-local indent-line-function 'sh-indent-line))
+ (setq-local indent-line-function #'sh-indent-line))
(if sh-make-vars-local
(sh-make-vars-local))
(message "Indentation setup for shell type %s" sh-shell))
(message "No indentation for this shell type.")
- (setq-local indent-line-function 'sh-basic-indent-line))
+ (setq-local indent-line-function #'sh-basic-indent-line))
(when font-lock-mode
(setq font-lock-set-defaults nil)
(font-lock-set-defaults)
@@ -3586,7 +3585,7 @@ so that `occur-next' and `occur-prev' will work."
;; (insert ")\n")
;; )))
;;
-;; (add-hook 'sh-learned-buffer-hook 'what-i-learned)
+;; (add-hook 'sh-learned-buffer-hook #'what-i-learned)
;; Originally this was sh-learn-region-indent (beg end)
@@ -4055,7 +4054,8 @@ Add these variables to `sh-shell-variables'."
(goto-char (point-min))
(setq sh-shell-variables-initialized t)
(while (search-forward "=" nil t)
- (sh-assignment 0)))
+ (sh--assignment-collect)))
+ (add-hook 'post-self-insert-hook #'sh--assignment-collect nil t)
(message "Scanning buffer `%s' for variable assignments...done"
(buffer-name)))
@@ -4328,20 +4328,23 @@ option followed by a colon `:' if the option accepts an
argument."
+(put 'sh-assignment 'delete-selection t)
(defun sh-assignment (arg)
"Remember preceding identifier for future completion and do self-insert."
(interactive "p")
+ (declare (obsolete nil "27.1"))
(self-insert-command arg)
- (if (<= arg 1)
- (sh-remember-variable
- (save-excursion
- (if (re-search-forward (sh-feature sh-assignment-regexp)
- (prog1 (point)
- (beginning-of-line 1))
- t)
- (match-string 1))))))
+ (sh--assignment-collect))
+
+(defun sh--assignment-collect ()
+ (sh-remember-variable
+ (save-excursion
+ (if (re-search-forward (sh-feature sh-assignment-regexp)
+ (prog1 (point)
+ (beginning-of-line 1))
+ t)
+ (match-string 1)))))
-(put 'sh-assignment 'delete-selection t)
(defun sh-maybe-here-document (arg)
"Insert self. Without prefix, following unquoted `<' inserts here document.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 7fbabaf: * lisp/progmodes/sh-script.el (sh-mode-map): Don't bind `=`,
Stefan Monnier <=