1

in my .emacs file I have:

;; enable skeleton-pair insert globally
(setq skeleton-pair t)
;;(setq skeleton-pair-on-word t)
(global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "[") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\'") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\`") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "<") 'skeleton-pair-insert-maybe)

extracted directly from here ESS autocomplete. Everything related to ESS is:

;;=============================
;;R
;;==============================
;;Enable R
(add-to-list 'load-path "~/ess-15.03-1/lisp/")
(load "ess-site")
(setq ess-eval-visibly 'nil)
(setq ess-ask-for-ess-directory 'nil)
(add-hook 'ess-R-post-run-hook 'ess-execute-screen-options)
(define-key inferior-ess-mode-map "\C-cw" 'ess-execute-screen-options)

(eval-after-load "comint"    
  '(progn
     (define-key comint-mode-map [up]
       'comint-previous-matching-input-from-input)
     (define-key comint-mode-map [down]
       'comint-next-matching-input-from-input)
     ;; also recommended for ESS use --
     (setq comint-scroll-to-bottom-on-output 'others)
     (setq comint-scroll-show-maximum-output t)
     ;; somewhat extreme, almost disabling writing in *R*, *shell* buffers above promp
     (setq comint-scroll-to-bottom-on-input 'this)))

Auto-completion of the braces (or auto-closing them) will work with everything: .py files, .txt files, even when I am in the R console launched with ESS (M-x R). However, it will not complete the curly braces when the file is and R file (e.g. foo.R). All other skeleton-pair options work everywhere, the only one that does not is the curly braces.

I read here that some other people has problems with curly braces related with the definition of the ess-electric-brace at ess-mode.el. However, their problems are different than mine. It seems that they cannot close the braces. In my case, is simply that it will not auto-complete them, so I am not sure the solution will be the same.

I see that in ess-mode.el there is a line:

(define-key map "{"          'ess-electric-brace)

and there is not such a thing for ( or [ so I guess is related to that, but do not know how to change it.

Any suggestions?

  • I just commented that line and it seems to work. I am not sure this is a good practice (my intuition tells me is not), but it does work... – Javier Sep 18 '15 at 18:54
1

I also had this problem and created an issue on the project GitHub account. Here is what I got back:

That's because ESS is binding { to ess-electric-brace which stopped working at some point. This is historical and I think even precedes skeleton-pair. It should be working now. You can always fix such issues by unseting the keys in ess mode:

(define-key ess-mode-map (kbd "{") nil)
(define-key ess-mode-map (kbd "}") nil)

I added this to my .emacs file and everything works fine now. Hope this helps you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.