diff options
Diffstat (limited to 'lisp/progmodes')
-rw-r--r-- | lisp/progmodes/python.el | 8 | ||||
-rw-r--r-- | lisp/progmodes/sh-script.el | 46 |
2 files changed, 32 insertions, 22 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 14b65669c4b..ec5d8c55512 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4084,6 +4084,12 @@ JUSTIFY should be used (if applicable) as in `fill-paragraph'." (goto-char (line-end-position)))) t) +(defun python-do-auto-fill () + "Like `do-auto-fill', but bind `fill-indent-according-to-mode'." + ;; See Bug#36056. + (let ((fill-indent-according-to-mode t)) + (do-auto-fill))) + ;;; Skeletons @@ -5379,7 +5385,7 @@ REPORT-FN is Flymake's callback function." (set (make-local-variable 'paragraph-start) "\\s-*$") (set (make-local-variable 'fill-paragraph-function) #'python-fill-paragraph) - (set (make-local-variable 'fill-indent-according-to-mode) t) ; Bug#36056. + (set (make-local-variable 'normal-auto-fill-function) #'python-do-auto-fill) (set (make-local-variable 'beginning-of-defun-function) #'python-nav-beginning-of-defun) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index aad38b94d76..cbc0ac74f09 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,24 @@ 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 + (when (eq ?= (char-before)) + (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. |