Some while ago I was looking to update my emacs configuration and after
a lot of trials, I ended up starting with and then modifying slightly
the quite complicated setup available at 

https://github.com/seblemaguer/dotfiles 

(the emacs.d directory, not the other stuff; I started from an older
version of this)

It took a while to modify enough so it would work (and I don't really
work with python, but think it facilitates both quite easily).

Good luck

Markus


On Tue, 2019-10-29 at 11:58 -0500, Paul Johnson via ESS-help wrote:
> I have to write python code now.
> 
> I put in a bunch of python bells and whistles and now ESS and R
> sessions
> don't work the same.  I've got interference from flymake and
> something has
> entirely broken the "_" to create <-.
> 
> I keep editing init.el to enable the ESS parts or comment them out
> and turn
> on Python stuff, whole thing has become horribly confusing for me.
> 
> I need to understand how to write init.el as a sequence of files so
> that I
> can load the ESS part when I need to write R, or the python part if I
> work
> on that. Can you share your strategies for dealing with that?
> 
> my init.el now:
> 
> (require 'package)
> (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
>                     (not (gnutls-available-p))))
>        (proto (if no-ssl "http" "https")))
>   (when no-ssl
>     (warn "\
> Your version of Emacs does not support SSL connections,
> which is unsafe because it allows man-in-the-middle attacks.
> There are two things you can do about this warning:
> 1. Install an Emacs version that does support SSL and be safe.
> 2. Remove this warning from your init file so you won't see it
> again."))
>   ;; Comment/uncomment these two lines to enable/disable MELPA and
> MELPA
> Stable as desired
>   (add-to-list 'package-archives (cons "melpa" (concat proto "://
> melpa.org/packages/")) t)
>   ;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto
> "://
> stable.melpa.org/packages/")) t)
>   (when (< emacs-major-version 24)
>     ;; For important compatibility libraries like cl-lib
>     (add-to-list 'package-archives (cons "gnu" (concat proto "://
> elpa.gnu.org/packages/")))))
> ;; for stable packages, use this instead
> ;;add-to-list 'package-archives
> ;;             '("melpa-stable" . "https://stable.melpa.org/packages/
> ") t)
> 
> (package-initialize)
> 
> ;for the window-purpose package
> (purpose-mode)
> ; C-c, D: `purpose-toggle-window-buffer-dedicated`
> 
> ;; ; Python settings
> ;; ; see
> http://emacs.stackexchange.com/questions/24453/weird-shell-output-when-using-ipython-5
> ;; ;; ;; Some python things I use, you may not need
> (elpy-enable)
> ;; ;; recommended in elpy docs
> (setq python-shell-interpreter "jupyter"
>        python-shell-interpreter-args "console --simple-prompt"
>        python-shell-prompt-detect-failure-warning nil)
> (add-to-list 'python-shell-completion-native-disabled-interpreters
>              "jupyter")
> ;; ;
> https://stackoverflow.com/questions/25154809/how-can-i-stop-elpy-from-overriding-some-of-my-keybindings/25159354
> ;; ; 
> https://emacs.stackexchange.com/questions/46247/cannot-bind-m-s-left
> (eval-after-load "elpy"
>   '(progn
>      (define-key elpy-mode-map [(control return)] nil)
>      (define-key elpy-mode-map [(shift return)]
> 'elpy-shell-send-statement-and-step)
>      (define-key elpy-mode-map (kbd "\M-\t") nil)
>      (define-key elpy-mode-map (kbd "s-<tab>") 'elpy-company-backend)
>  )
> )
> (setq elpy-rpc-timeout 10)
> 
> 
> ;; 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
>  ;; 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.
>  '(ansi-color-names-vector
>    ["#2e3436" "#a40000" "#4e9a06" "#c4a000" "#204a87" "#5c3566"
> "#729fcf"
> "#eeeeec"])
>  '(column-number-mode t)
>  '(cua-auto-tabify-rectangles nil)
>  '(cua-mode t nil (cua-base))
>  '(custom-enabled-themes (quote (whiteboard)))
>  '(inferior-R-args "--no-restore-history --no-save")
>  '(package-selected-packages
>    (quote
>     (ivy window-purpose pyenv-mode py-autopep8 math-symbol-lists
> material-theme ein ess-smart-underscore htmlize polymode
> org-link-minor-mode markdown-mode julia-mode elpy dash)))
>  '(show-paren-mode t))
> 
> (setq-default indent-tabs-mode nil)
> (setq default-tab-width 4)
> 
> 
> ;; https://www.emacswiki.org/emacs/SmoothScrolling#toc1
> ;; scroll one line at a time (less "jumpy" than defaults)
>     (setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line
> at a
> time
>     (setq mouse-wheel-progressive-speed nil) ;; don't accelerate
> scrolling
>     (setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
>     (setq scroll-step 1) ;; keyboard scroll one line at a time
> 
> 
> 
> ;; 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
> 
> (require 'ess-site)
> ;; soft require: no error if package not found
> ;;(require 'ess-smart-underscore nil 'noerror)
> 
> ;;(require 'poly-R)
> ;;(require 'poly-markdown)
> 
> ;;(add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))
> ;; 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"
>  '(progn
>    (define-key ess-mode-map [(control return)] nil)
>    ;;(define-key ess-mode-map [(shift return)]
> 'ess-eval-region-or-line-and-step))
>    (define-key ess-mode-map [(shift return)]
> 'ess-eval-region-or-line-visibly-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
> (setq inferior-ess-own-frame t)
> (setq inferior-ess-same-window nil)
> 
> ;; Problem in Windows about menus not displaying
> ;; https://stat.ethz.ch/pipermail/ess-help/2012-September/008207.html
> ;;(if (eq system-type 'windows-nt)
>   (defun my-R-execute-options ()
> (ess-command "options(menu.graphics = FALSE)\n"))
> (add-hook 'ess-R-post-run-hook 'my-R-execute-options)
> ;;)
> 
> ;; Put # flush left
> ;; See gmail thread in ESS group, this from Ista
> (add-hook 'ess-mode-hook
>  (lambda()
>             ;; don't indent comments
>             (setq ess-indent-with-fancy-comments nil)
>             ;; turn on outline mode
>             (setq-local outline-regexp "[# ]+")
>             (outline-minor-mode t)))
> 
> ;; 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."
>   (interactive)
>   (let* ((mustmatch (not (and (fboundp 'x-uses-old-gtk-dialog)
>                               (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)
> 
> 
> 
> 
> ;; 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"))
> 
>   (save-excursion
>     ;; 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 ";"
>     (save-excursion
>       (goto-char start)
>       (setq delimit (re-search-backward "^#delimit +\\(.+\\)$" nil
> t))
>       (if delimit
>           (if (not (string-match ";" (match-string 1))) (setq delimit
> nil))))
> 
>     (with-temp-buffer
>       (if clear (insert "clear\n"))
>       (if delimit (insert "#delimit ;\n"
>                           commands
>                           "\n#delimit cr\n")
>         (insert commands "\n"))
>       (write-file delimit-do-file nil)
>       (kill-buffer (current-buffer)))
> 
>     (process-send-string
>      (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)
>       (deactivate-mark))
>   ;; return value
>   (list start end))
> 
> 
> 
> ; 20161115: Things I was using in Emacs25 to do
> ; org-mode documents
> ;http://vislab-ccom.unh.edu/~schwehr/rt/9-bash-scripting.html
> ;(require 'org-install)
> (org-babel-do-load-languages
>    'org-babel-load-languages
>    '(
>      (shell . t) ;; emacs-26.1
>      (R . t)
>      ;;(sh . t) ;; pre-emacs 26.1
>     )
> )
> 
> ;;
> https://www.reddit.com/r/emacs/comments/tbj09/using_shift_selection_in_orgmode_buffers_without/
> ;
> ;; (defadvice org-call-for-shift-select (before
> org-call-for-shift-select-cua activate)
> ;;   (if (and cua-mode
> ;;            org-support-shift-select
> ;;            (not (use-region-p)))
> ;;      (cua-set-mark)))
> ;; (require 'ox-md nil t)
> 
> 
> ; See: http://mescal.imag.fr/membres/arnaud.legrand/misc/init.php
> 
> ;(setq org-hide-leading-stars t)
> ;(setq org-alphabetical-lists t)
> ;(setq org-src-fontify-natively t)  ;; you want this to activate
> coloring
> in blocks
> ;(setq org-src-tab-acts-natively t) ;; you want this to have
> completion in
> blocks
> ;(setq org-hide-emphasis-markers t) ;; to hide the *,=, or / markers
> ;(setq org-pretty-entities t)       ;; to have \alpha, \to and others
> display as utf8 http://orgmode.org/manual/Special-symbols.html
> ;
> 
> 
> 
> ;   (require 'yasnippet)
> ;   (yas-global-mode 1)
> 
> 
> (load "auctex.el" nil t t)
> (load "preview-latex.el" nil t t)
> (custom-set-faces
>  ;; 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.
>  )
> 
> 
> 
> 
> 
> 
> 
-- 
Markus Jantti
Professor of Economics
Swedish Institute for Social Research
Stockholm University
 
> 
> 
-- 
Markus Jantti
Professor of Economics
Swedish Institute for Social Research
Stockholm University
 
______________________________________________
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Reply via email to