[ESS] inferior-ess-own-frame

Benjamin Rogers Benj@m|n@Roger@ @end|ng |rom |p@@k@@gov
Wed Aug 9 14:58:42 CEST 2017

Sorry about not including the actual init.el file, and thank you to Rodney for letting me know to do so. The version I use is included below. It's Professor Paul Johnson's init.el file, with a few modifications I made such as comment eclipse functionality, setting C-s as the save command for a buffer, and removing warnings about opening large files. I can include any other information about the system that would be helpful in this case, and I've included the text that would pop up for  a bug report below the init.el file, in case that would help.


(global-set-key (kbd "M-p") 'ace-window)

;; Paul Johnson
;; 2015-10-01
;; This version? 2015-10-01?
;; I ran into some trouble swapping various versions of ESS in
;; my user directory, so I started tearing this apart. Cutting out
;; stuff I don't remember.
;; My init file alters user interaction with R via ESS. Most
;; importantly
;; 1. *R* should start in its own frame
;; 2. S-[Return] is hot key to send line to *R*. This replaces
;;    now default C-[Return].  I need this to protect CUA
;;    mode rectangle selection
;; 3. General Emacs settings discourage "frame splitting" that
;;    the usual Emacs users seem to like.
;; 4. Slight simplification of the menu under File. I don't see
;;    need for separate "create" and "open" choices. So I put them
;;    together
;; 5. See next paragraph about the MELPA package manager
;; See my companion lecture
;; "Emacs Has No Learning Curve"
;; http://pj.freefaculty.org/guides/Rcourse
;; 2015-03-02
;; Following allows use of Emacs24 package manager.
;; To use, run emacs, then do
;; M-x list-packages
;; To see everything available at that moment on melpa.
;; After that, seriously consider installing ess-smart-underscore.
;; M-x package-refresh-contents
(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list 'package-archives
                       '("melpa" . "http://melpa.milkbox.net/packages/") t)

(require 'package)
(add-to-list 'package-archives
             '("elpy" . "http://jorgenschaefer.github.io/packages/"))

;; Some python things I use, you may not need
;;(setq python-shell-interpreter "ipython3")

;;(autoload 'python-mode "python-mode" "Python Mode." t)
;;(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
;;(add-to-list 'interpreter-mode-alist '("python" . python-mode))


(require 'ess-site)
;; soft require: no error if package not found
(require 'ess-smart-underscore nil 'noerror)

(add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))

;; Org-mode with R doesn't work without this
;; http://orgmode.org/worg/org-contrib/babel/how-to-use-Org-Babel-for-R.html
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
   [default default default italic underline success warning error])
   ["#2e3436" "#a40000" "#4e9a06" "#c4a000" "#204a87" "#5c3566" "#729fcf" "#eeeeec"])
'(cua-auto-tabify-rectangles nil)
'(cua-mode t nil (cua-base))
'(cua-normal-cursor-color "snow")
'(cursor-type (quote bar))
'(custom-enabled-themes (quote (wombat)))
'(elpy-rpc-python-command "python3")
'(ess-prefer-higher-bit t)
'(inferior-ess-own-frame t)
'(org-babel-load-languages (quote ((emacs-lisp . t) (R . t))))
'(org-confirm-babel-evaluate nil)
'(show-paren-mode t))

(setq default-tab-width 4)

;; Section II. Keyboard and mouse customization
;; Mouse and cursor in the usual Mac/Windows way
(delete-selection-mode t)
;; http://stackoverflow.com/questions/13036155/how-to-to-combine-emacs-primary-clipboard-copy-and-paste-behavior-on-ms-windows
(setq select-active-regions t)
;; Trying to make mouse middle-click only paste from primary
;; X11 selection, not clipboard and kill ring:
(global-set-key [mouse-2] 'mouse-yank-primary)
;; highlight does not alter Kill ring:
(setq mouse-drag-copy-region nil)
;; windows style binding C-x, C-v, C-c, C-z:
(cua-mode t)
;; Don't tabify after rectangle commands:
(setq cua-auto-tabify-rectangles nil)

;; Section III. Programming conveniences:
;; light-up matching parens:
(show-paren-mode t)
;; turn on syntax highlighting:
(global-font-lock-mode t)
;; Auto fill is TRUE in text modes:
(setq text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))

;; Section IV. ESS Emacs Statistics

;; start R in current working directory, don't let R ask user:
(setq ess-ask-for-ess-directory nil)

;; Change shortcut "run this line" to use Shift-Return
;; Suggested by Vitalie Spinu 2013-09-30 to co-exist with Windows Emacs
(eval-after-load "ess-mode"
   (define-key ess-mode-map [(control return)] nil)
   (define-key ess-mode-map [(shift return)] 'ess-eval-region-or-line-and-step))

;; Help in frames? Consider
;; 1) create a new frame for each help instance
;; (setq ess-help-own-frame t)
;; or 2) If you want all help buffers to go into one frame do:
(setq ess-help-own-frame 'one)

;; I want the *R* process in its own frame
(require 'ess-site)
(setq inferior-ess-own-frame t)
(setq inferior-ess-same-window nil)

;; Section V. Frames oriented Emacs
;; Discourage Emacs from horizontal splitting:
;; http://www.gnu.org/software/emacs/elisp/html_node/Choosing-Window.html
;;(setq split-window-preferred-function nil)

;; (setq pop-up-windows nil)

;; Make files opened from the menu bar appear in their own
;; frames. Adapted from Emacs menu-bar.el
(defun menu-find-existing ()
  "Edit the existing file FILENAME."
  (let* ((mustmatch (not (and (fboundp 'x-uses-old-gtk-dialog)
         (filename (car (find-file-read-args "Find file: " mustmatch))))
    (if mustmatch
        (find-file-other-frame filename)
      (find-file filename))))
(define-key menu-bar-file-menu [new-file]
  '(menu-item "Open/Create" find-file-other-frame
                      :enable (menu-bar-non-minibuffer-window-p)
                      :help "Create a new file"))
(define-key menu-bar-file-menu [open-file]
  '(menu-item ,(purecopy "Open File...") menu-find-existing
              :enable (menu-bar-non-minibuffer-window-p)
              :help ,(purecopy "Read an existing file into an Emacs buffer")))

;; Open directory list in new frame.
(define-key menu-bar-file-menu [dired]
  '(menu-item "Open Directory..." dired-other-frame
                      :help "Read a directory; operate on its files (Dired)"
                      :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))

;; Section VI: Miscellaneous convenience
;; Remove Emacs "splash screen" http://fuhm.livejournal.com/
(defadvice command-line-normalize-file-name
  (before kill-stupid-startup-screen activate)
  (setq inhibit-startup-screen t))
(setq inhibit-splash-screen t)

;; Show file name in title bar
;; http://www.thetechrepo.com/main-articles/549
(setq frame-title-format "%b - Emacs")

;; Make Emacs scroll smoothly with down arrow key.
;; faq 5.45 http://www.gnu.org/s/emacs/emacs-faq.html#Modifying-pull_002ddown-menus
(setq scroll-conservatively most-positive-fixnum)

;; adjust the size of the frames, uncomment this, adjust values
;;(setq default-frame-alist '((width . 90) (height . 65)))

;; Remember password when connected to remote sites via Tramp
;; http://stackoverflow.com/questions/840279/passwords-in-emacs-tramp-mode-editing
;; Emacs "tramp" service (ssh connection) constantly
;; asks for the log in password without this
(setq password-cache-expiry nil)

;; Emacs shells work better
;; http://snarfed.org/why_i_run_shells_inside_emacs
(setq ansi-color-for-comint-mode 'filter)
(setq comint-prompt-read-only t)
(setq comint-scroll-to-bottom-on-input t)
(setq comint-scroll-to-bottom-on-output t)
(setq comint-move-point-for-output t)
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
(set-cursor-color "#ffffff")

;; A stata stanza from Brendan Halpin

;; Stata equivalent of ess-eval-region

(defun delimit-do (start end toggle &optional clear message)
  "Send the current region to the inferior ESS process, Stata do-editor style.
Creates a temporary file, \"do\"-es it, deletes it.
With prefix argument toggle the meaning of `ess-eval-visibly-p';
this does not apply when using the S-plus GUI, see `ess-eval-region-ddeclient'."
  (interactive "r\nP")
  (ess-force-buffer-current "Process to use: ")
  (message "Starting evaluation...")
  (setq message (or message "Eval region"))

    ;; don't send new lines (avoid screwing the debugger)
    (goto-char start)
    (skip-chars-forward "\n\t ")
    (setq start (point))

    (unless mark-active
      (ess-blink-region start end))

    ;; don't send new lines at the end (avoid screwing the debugger)
    (goto-char end)
    (skip-chars-backward "\n\t ")
    (setq end (point)))

  (let* (delimit
         (commands (buffer-substring-no-properties start end))
         (delimit-do-file (make-temp-file "delimit-do" nil ".do"))
         (proc (get-process ess-local-process-name))
         (visibly (if toggle (not ess-eval-visibly-p) ess-eval-visibly-p))
         (dev-p (process-get proc 'developer))
         (tb-p  (process-get proc 'tracebug)))
    ;; Go to the start of the section and look back for #delimit
    ;; if found set delimit unless the delimiter is not ";"
      (goto-char start)
      (setq delimit (re-search-backward "^#delimit +\\(.+\\)$" nil t))
      (if delimit
          (if (not (string-match ";" (match-string 1))) (setq delimit nil))))

      (if clear (insert "clear\n"))
      (if delimit (insert "#delimit ;\n"
                          "\n#delimit cr\n")
        (insert commands "\n"))
      (write-file delimit-do-file nil)
      (kill-buffer (current-buffer)))

     (get-ess-process ess-current-process-name)
     (format "do %s\nrm %s\n" delimit-do-file delimit-do-file))
  (if (and (fboundp 'deactivate-mark) ess-eval-deactivate-mark)
  ;; return value
  (list start end))

(defun comment-eclipse ()
  (let ((start (line-beginning-position))
        (end (line-end-position)))
    (when (or (not transient-mark-mode) (region-active-p))
      (setq start (save-excursion
                    (goto-char (region-beginning))
            end (save-excursion
                  (goto-char (region-end))
    (comment-or-uncomment-region start end)))

(global-set-key (kbd "M-;") 'comment-eclipse)
(global-set-key (kbd "C-;")'comment-eclipse)

;; make it so ctrl s saves
(global-set-key (kbd "C-s")'save-buffer)

;; stop emacs from asking if I want it to open a file
(setq large-file-warning-threshold nil)

;;; init.el ends here

[ess-site.el]: ess-customize-alist=nil
[ess-site.el _2_]: ess-customize-alist=nil
(R): ess-r-versions-create making M-x defuns for

Emacs  : GNU Emacs 25.2.1 (x86_64-w64-mingw32)
of 2017-04-24
Package: ess-mode 16.10 [Released git: e92ed78b8890]

current state:
ess-language nil
ess-dialect nil
ess-ask-for-ess-directory nil
ess-ask-about-transfile nil
ess-directory nil
ess-keep-dump-files "always"
ess-source-directory "C:\\Users\\brogers\\AppData\\Local\\Temp"
ess-use-ido t
ess-use-eldoc t
ess-use-tracebug t
ess-use-auto-complete t
ess-use-company t
ess-eval-visibly-p t
ess-can-eval-in-background t
ess-local-process-name nil

	[[alternative HTML version deleted]]

More information about the ESS-help mailing list