;; 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
(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)
(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))
)))
(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
(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)
;; (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)
(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)))
+(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.