emacs-ess / ESS

Emacs Speaks Statistics: ESS
https://ess.r-project.org/
GNU General Public License v3.0
620 stars 162 forks source link

ess-r-font-lock-mode is not fontifying anything #1169

Closed steve-the-bayesian closed 2 years ago

steve-the-bayesian commented 2 years ago

Curious why ess is not fontifying R code. Screen Shot 2021-11-13 at 4 30 40 PM

ess version is 18.10.2

GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14) of 2020-03-26, modified by Debian

OS is Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal

content of .emacs follows:

;; Red Hat Linux default .emacs initialization file ; -- mode: emacs-lisp --

;; Set the load path for emacs list files (add-to-list 'load-path "~/elisp")

;; Add the path to the mactex distribution to emacs's path. Emacs is not ;; setting the path from .bashrc, so I need to set this here. (setenv "PATH" (concat (getenv "PATH") ":/Library/TeX/texbin/")) (setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin/")) (setq exec-path (append exec-path '("/Library/TeX/texbin/"))) (setq exec-path (append exec-path '("/usr/local/bin/")))

;; Added by Package.el. This must come before configurations of ;; installed packages. Don't delete this line. If you don't want it, ;; just comment it out by adding a semicolon to the start of the line. ;; You may delete these explanatory comments. (package-initialize)

;; (when (getenv "NX_CLIENT") ;; (setq x-super-keysym 'meta))

;; Set up the keyboard so the delete key on both the regular keyboard ;; and the keypad delete the character under the cursor and to the right ;; under X, instead of the default, backspace behavior. (global-set-key [delete] 'delete-char) (global-set-key [kp-delete] 'delete-char)

;; turn on font-lock mode (global-font-lock-mode t)

;; turn off the audible bell (setq ring-bell-function 'ignore)

;; Ignore case in file completion. (setq completion-ignore-case t)

;; Turn on column-number-mode. (setq column-number-mode t)

;; Turn on visual bell -- disable audible bell. (setq visible-bell t)

;; enable visual feedback on selections (setq-default transient-mark-mode t)

;; always end a file with a newline (setq require-final-newline t)

;; stop at the end of the file, not just add lines (setq next-line-add-newlines nil)

;; prevent the emacs splash screen (setq inhibit-splash-screen t)

;; Use spaces instead of tabs when indenting. (setq-default indent-tabs-mode nil)

;; source: xemacs 20.3 (defun count-words-region (start end) (interactive "r") (save-excursion (let ((n 0)) (goto-char start) (while (< (point) end) (if (forward-word 1) (setq n (1+ n)))) (message "Region has %d words" n) n)))

(defun split-three-ways () "Split the screen into three equal columns" (interactive) ;; (recenter 0)) (split-window-horizontally 101) (other-window 1) (split-window-horizontally 101) ;; (balance-windows) (other-window 2))

(global-set-key [f9] 'split-three-ways)

(add-hook 'before-save-hook 'delete-trailing-whitespace)

(super-save-mode +1)

;;;;;;;;;;;;;;; ;;; source: ;;; https://www.emacswiki.org/emacs/UnwrapLine (defun unwrap-lines () "Remove all newlines until we get to two consecutive ones. Or until we reach the end of the buffer. Great for unwrapping quotes before sending them on IRC." (interactive) (let ((start (point)) (end (copy-marker (or (search-forward "\n\n" nil t) (point-max)))) (fill-column (point-max))) (fill-region start end) (goto-char end) (newline) (goto-char start)))

;;=-=-=-=-=-=-=-=-= CEDET support =-=-=-=-=-=-=-=-= ;; Code was created by downloading from github, then ;; make EMACS=/usr/bin/emacs ;; See: ;; http://cedet.sourceforge.net/setup.shtml ;; and ;; http://alexott.net/en/writings/emacs-devenv/EmacsCedet.html ;; (load-file "~/code/cedet/lisp/cedet/cedet.el") ; (require 'cedet) ; (global-ede-mode 1) ; Enable the Project management system ; (semantic-load-enable-code-helpers) ; Enable prototype help and smart completion ; (global-srecode-minor-mode 1) ; Enable template insertion menu

;;=-=-=-=-=-=-=-=-=-= Support for clang-format =-=-=-=-=-=-=-=-=-=-=-=-=-=-= ;; This doesn't work, because clang-format not found, despite it being in the ;; exec-path.

;; (require 'clang-format) ;; (global-set-key (kbd "C-c i") 'clang-format-region) ;; (global-set-key (kbd "C-c u") 'clang-format-buffer) ;; (setq clang-format-style-option "llvm")

;;=-=-=-=-=-=-=-=-=-= Support for bazel BUILD files =-=-=-=-=-=-=-=-=-=-=-= (add-hook 'after-save-hook (lambda() (save-excursion (if (string-match "BUILD" (file-name-base (buffer-file-name))) (progn (shell-command (concat "/usr/local/bin/buildifier " (buffer-file-name))) (find-alternate-file (buffer-file-name)))))))

(defcustom buildifier-bin "buildifier" "Location of the buildifier binary." :type 'string :group 'buildifier)

(defcustom buildifier-path-regex "BUILD\|WORKSPACE\|BAZEL" "Regular expression describing base paths that need buildifier." :type 'string :group 'buildifier)

(defun buildifier () "Run buildifier on current buffer." (interactive) (when (and (string-match buildifier-path-regex (file-name-nondirectory (buffer-file-name))) (executable-find buildifier-bin)) (let ((p (point)) (tmp (make-temp-file "buildifier"))) (write-region nil nil tmp) (let ((result (with-temp-buffer (cons (call-process buildifier-bin tmp t nil) (buffer-string))))) (if (= (car result) 0) (save-excursion (erase-buffer) (insert (cdr result))) (warn "%s failed: %s" buildifier-bin (cdr result))) (goto-char p) (delete-file tmp nil)))))

(add-hook 'before-save-hook 'buildifier)

;;=-=-=-=-=-=-=-=-=-= ESS =-=-=-=-=-=-=-=-=-=-=-= ;; (add-to-list 'load-path "~/Library/EmacsPackages/ess-17.11/lisp/") ;; ;; I could not get ESS using the package manager. To get it I downloaded the ;; .tgz and then ;; tar -xvf ess-12.09-2.tgz ;; mv ess-12.09-2 /Applications/Emacs.app/Contents/Resources/site-lisp/ (require 'ess-site) (setq ess-default-style 'OWN)

;; To customize this style, C-h v for ess-own-style-list, and click 'customize'. (require 'ess-r-xref)

;; Turn off roxygen mode because it uses key bindings that I'd prefer not to be ;; bound, namely C-c C-o X, for a variety of values of X. (add-hook 'ess-mode-hook (lambda () (ess-roxy-mode -1)))

;; (defun ess-r-find-functions() ;; "Find all instances of <- function in a file." ;; (interactive) ;; (occur "<- function"))

;; (define-key ess-mode-map (kbd "C-c C-o") 'ess-r-find-functions)

;; (add-hook 'ess-r-mode-hook ;; (lambda () ;; (ess-set-style 'Rstudio-)))

(add-hook 'ess-r-mode-hook (lambda () (ess-set-style 'own)))

(define-key ess-mode-map (kbd "") 'ess-insert-assign) (define-key inferior-ess-mode-map (kbd "") 'ess-insert-assign)

;; evaluate a region defined in a .R file, and move the cursor to the ;; associated R process

;; ESS fix: since emacs 23, C-c M-r sends code but sometime does not ;; go to the end of the R session buffer (stays midway). This fixes ;; it. ;;(setq comint-scroll-to-bottom-on-input t) ;;(setq comint-scroll-to-bottom-on-output t) ;;(setq comint-move-point-for-output t) ;;=-=-=-=-=-=-=-=-=-=-=-= End of ESS =-=-=-=-=-=-=-=-=-=-=-=

;;=-=-=-=-=-=-=-=-=-= Python =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= (setenv "TERM" "xterm") (setq python-shell-interpreter "python3")

(require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) ;; (add-to-list 'package-archives ;; '("melpa-stable" . "https://stable.melpa.org/packages/")) (package-initialize) (elpy-enable) (setq elpy-rpc-backend "jedi")

(require 'ein)

;; Set the fill column to 79 (add-hook 'python-mode-hook (lambda () (interactive) (set-fill-column 79) ))

(define-key elpy-mode-map (kbd "M-.") 'elpy-goto-assignment)

;;=-=-=-=-=-=-=-=-=-= End Python =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

(global-set-key [f5] 'enlarge-window) (global-set-key [f6] 'shrink-window) (global-set-key [f7] 'enlarge-window-horizontally) (global-set-key [f8] 'shrink-window-horizontally) (global-set-key "\C-cl" 'goto-line)

;; Disable the mouse-buffer-menu, which can pop up unexpectedly when using a ;; laptop with a trackpad. (global-unset-key [C-down-mouse-1])

;; make \C-l work the way it worked in the good old days (global-set-key "\C-l" 'recenter) ;; (global-set-key "\C-L" 'recenter-top-bottom)

;; remove dangerous 'downcase-region' keybinding (global-set-key "\C-x\C-l" 'nil) ;; remove dangerous 'downcase-word' keybinding (global-set-key "\M-l" 'nil)

(global-set-key [end] 'end-of-buffer) (global-set-key [home] 'beginning-of-buffer)

; M-. should be the thing that works with TAGS files. ; (global-set-key "\M-." 'repeat)

(put 'upcase-region 'disabled nil) (put 'downcase-region 'disabled nil) (put 'downcase-region-or-word 'disabled nil) (put 'upcase-region-or-word 'disabled nil) (setq transient-mark-mode t)

;;=-=-=-=-=-=-=-=-=-=-= ISPELL =-=-=-=-=-=-=-=-=-=-= (setq-default ispell-program-name "aspell")

;;=-=-=-=-=-=-= Use a modified version of the Google C++ style =-=-=-=-=-=-=-=-= ;; Use gdb.el from ~/elisp, which enables support for lldb

(require 'gud)

;; (require 'hide-comnt)

;;=-=-=-=-=-=-= Use a modified version of the Google C++ style =-=-=-=-=-=-=-=-= (load-file "~/elisp/google-c-style.el") (add-hook 'c-mode-common-hook 'google-set-c-style) (add-hook 'c-mode-common-hook 'google-make-newline-indent)

;;; Edit .h files as C++ rather than C. (add-to-list 'auto-mode-alist '("\.h\'" . c++-mode))

(setq path-to-ctags "/usr/bin/ctags") ;; <- your ctags path here

(defun create-tags (dir-name) "Create tags file." (interactive "DDirectory: ") (shell-command (format "%s -e -R %s" path-to-ctags (directory-file-name dir-name))) )

;;; Jonas.Jarnestromki.ericsson.se A smarter ;;; find-tag that automagically reruns etags when it cant find a ;;; requested item and then makes a new try to locate it. ;;; Fri Mar 15 09:52:14 2002 (defadvice find-tag (around refresh-etags activate) "Rerun etags and reload tags if tag not found and redo find-tag. If buffer is modified, ask about save before running etags." (let ((extension (file-name-extension (buffer-file-name)))) (condition-case err ad-do-it (error (and (buffer-modified-p) (not (ding)) (y-or-n-p "Buffer is modified, save it? ") (save-buffer)) (er-refresh-etags extension) ad-do-it))))

(defun er-refresh-etags (&optional extension) "Run etags on all peer files in current dir and reload them silently." (interactive) (shell-command (format "etags *.%s" (or extension "el"))) (let ((tags-revert-without-query t)) ; don't query, revert silently (visit-tags-table default-directory nil)))

(require 'modern-cpp-font-lock) (modern-c++-font-lock-global-mode t)

;;=-=-=-=-=-=-=-=-=-=-= AUCTEX =-=-=-=-=-=-=-=-=-=-= ;; to install auctex using apt-get, ;; sudo apt-get install auctex ;; ;; to install auctex from source, download it from ;; http://www.gnu.org/software/auctex/ ;; ;; ./configure --with-lispdir=/home/sscott/elisp ;; --with-emacs=/notcygwin/emacs-21.3/bin/emacs.exe ;; make ;; make install ;; To customize auctex use M-x customize-group -> AUCTeX (require 'tex-site) (setq TeX-auto-save t) (setq TeX-parse-self t) ;; (setq-default TeX-master nil)

;; Turn on reftex support. (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode (setq reftex-plug-into-AUCTeX t) ;; Turn off the prompt that asks what type of reference you want.o (setq reftex-ref-macro-prompt nil) ;; reftex is distributed with GNU emacs ;; 'C-c =' gets the table of contents. Within TOC '?' gets help.

(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. '(Buffer-menu-name-width 40) '(LaTeX-indent-environment-list (quote (("verbatim" current-indentation) ("verbatim" current-indentation) ("displaymath") ("equation") ("equation") ("picture") ("tabbing")))) '(ansi-color-faces-vector [default default default italic underline success warning error]) '(ansi-color-names-vector ["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#e090d7" "#8cc4ff" "#eeeeec"]) '(column-number-mode t) '(custom-enabled-themes (quote (wheatgrass))) '(custom-safe-themes (quote ("c57f869cd71215d261663cf626e48f90481a94a6527e2171dd59bff85971726a" "4d5c6d2a670324156b1ee5d55eefdd783e4b037a171907d9982f4659e736b35b" default))) '(elpy-rpc-python-command "python3") '(ess-own-style-list (quote ((ess-indent-offset . 2) (ess-offset-arguments . open-delim) (ess-offset-arguments-newline . prev-call) (ess-offset-block . prev-line) (ess-offset-continued . straight) (ess-align-nested-calls "ifelse") (ess-align-arguments-in-calls "function[ ]*(") (ess-align-continuations-in-calls . t) (ess-align-blocks control-flow) (ess-indent-from-lhs arguments fun-decl-opening) (ess-indent-from-chain-start . t) (ess-indent-with-fancy-comments . t)))) '(ess-style (quote RStudio-)) '(fill-column 80) '(modern-c++-font-lock-global-mode t) '(ns-command-modifier (quote meta)) '(package-archives (quote (("gnu" . "http://elpa.gnu.org/packages/") ("melpa" . "http://melpa.org/packages/")))) '(package-selected-packages (quote (super-save rtags modern-cpp-font-lock ess ein elpy auctex))) '(python-fill-docstring-style (quote django)) '(read-buffer-completion-ignore-case t) '(read-file-name-completion-ignore-case t) '(show-paren-mode t) '(tool-bar-mode nil)) (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. '(default ((t (:family "DejaVu Sans Mono" :foundry "PfEd" :slant normal :weight normal :height 98 :width normal)))) '(font-latex-script-char-face ((t (:foreground "cornsilk")))) '(font-latex-warning-face ((t (:inherit bold :foreground "dark goldenrod")))))

lionel- commented 2 years ago

Can you post this on ess-help please?

lionel- commented 2 years ago

If you think there is a bug, please post a minimal reprex starting from a vanilla instance of Emacs so we can try to reproduce.