Commit 7fbabaf9 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* 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.
parent bbadc6e0
Pipeline #3109 failed with stage
in 57 minutes and 37 seconds
......@@ -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
(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-1 sh-font-lock-keywords-2)
nil nil
((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w")) nil
. 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
......@@ -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
(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)
......@@ -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)))
(add-hook 'post-self-insert-hook #'sh--assignment-collect nil t)
(message "Scanning buffer `%s' for variable assignments...done"
......@@ -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)
(if (re-search-forward (sh-feature sh-assignment-regexp)
(prog1 (point)
(beginning-of-line 1))
(match-string 1))))))
(defun sh--assignment-collect ()
(if (re-search-forward (sh-feature sh-assignment-regexp)
(prog1 (point)
(beginning-of-line 1))
(match-string 1)))))
(put 'sh-assignment 'delete-selection t)
(defun sh-maybe-here-document (arg)
"Insert self. Without prefix, following unquoted `<' inserts here document.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment