@@ -311,18 +311,10 @@ indentation style. See `ess-style-alist' for predefined styles."
311311 ; ; completion
312312 (add-hook 'comint-dynamic-complete-functions 'ess-complete-filename nil 'local )
313313 (delq t comint-dynamic-complete-functions)
314- (set (make-local-variable 'comint-completion-addsuffix )
315- (cons " /" " " ))
316- (add-hook 'hack-local-variables-hook #'ess--set-style-in-buffer nil t )
314+ (setq-local comint-completion-addsuffix (cons " /" " " ))
315+ (add-hook 'hack-local-variables-hook 'ess-set-style nil t )
317316 (add-hook 'ess-idle-timer-functions 'ess-synchronize-dirs nil 'local ))
318317
319- (defun ess--set-style-in-buffer ()
320- " Set `ess-style' taking into account file and directory local variables.
321- This is added to `hack-local-variables-hook' ."
322- (setq-local ess-style (or (alist-get 'ess-style file-local-variables-alist)
323- ess-style))
324- (ess-set-style ess-style t ))
325-
326318(defun ess--get-mode-line-indicator ()
327319 " Get `ess--mode-line-process-indicator' from process buffer.
328320Internal function to be used for dynamic mode-line dysplay in
@@ -430,31 +422,34 @@ current function."
430422
431423; ;; Formatting / indentation
432424
433- (defun ess-set-style (&optional style quiet )
425+ (defun ess-set-style (&optional style _quiet )
434426 " Set up the `ess-mode' style variables from the `ess-style' variable.
435427If STYLE argument is given, use that instead. It makes the ESS
436- indentation style variables buffer local. When non-nil, QUIET
437- suppresses messaging."
438- (interactive )
439- (let ((ess-styles (mapcar 'symbol-name (mapcar 'car ess-style-alist))))
440- (unless style
441- (setq style
442- (intern (ess-completing-read " Set ESS mode indentation style"
443- ess-styles nil t nil nil ess-style))))
444- (setq style (or style ess-style))
445- (make-local-variable 'ess-style )
446- (if (memq (symbol-name style) ess-styles)
447- (setq ess-style style)
448- (error (format " Bad ESS style: %s " style)))
449- (if (not quiet)
450- (message " ESS-style: %s " ess-style))
451- ; ; finally, set the indentation style variables making each one local
452- (mapc (lambda (ess-style-pair )
453- (make-local-variable (car ess-style-pair))
454- (set (car ess-style-pair)
455- (cdr ess-style-pair)))
456- (cdr (assq ess-style ess-style-alist)))
457- ess-style))
428+ indentation style variables buffer local. QUIET is for backward
429+ compatibility and is ignored."
430+ (interactive
431+ (list (let ((styles (mapcar (lambda (x ) (symbol-name (car x)))
432+ ess-style-alist)))
433+ (intern (ess-completing-read
434+ " Set ESS mode indentation style"
435+ styles nil t nil nil ess-style)))))
436+ (let* ((keep-local (null style))
437+ (style (or style ess-style))
438+ (style-alist (or (cdr (assq style ess-style-alist))
439+ (error (format " Bad ESS style: %s " style))))
440+ (vars (if keep-local
441+ ; ; Install, but Keep user's buffer-local settings.
442+ (cl-loop for (var . _) in (cdr (assq 'DEFAULT ess-style-alist))
443+ unless (local-variable-p var)
444+ collect var)
445+ (mapcar #'car style-alist))))
446+ (when (called-interactively-p 'any )
447+ (message " ESS-style: %s " style))
448+ (mapc (lambda (var )
449+ (make-local-variable var)
450+ (set var (cdr (assq var style-alist))))
451+ vars)
452+ style))
458453
459454(defun ess-indent-command (&optional whole-exp )
460455 " Indent current line as ESS code, or in some cases insert a tab character.
0 commit comments