Skip to content

Commit ecd2f43

Browse files
committed
Don't fontify backquoted symbols as strings in process buffer
1 parent 5e6bfa1 commit ecd2f43

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

doc/newfeat.texi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
Changes and New Features in 19.04 (unreleased):
55
@itemize @bullet
66

7+
@item ESS[R]: Backticked symbols in the process buffer are no
8+
longer fontified as strings.
9+
710
@item ESS[R]: @code{ess-command} now runs R code in a sandboxed environment.
811
Use @code{.ess.environment()} to inspect the current environment.
912

lisp/ess-r-mode.el

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ namespace.")
375375
'ess-operator-face)
376376
(if (cdr (assq 'ess-R-fl-keyword:%op% ess-R-font-lock-keywords))
377377
'ess-%op%-face
378-
'default)))
378+
nil)))
379379
((save-excursion
380380
(and (cdr (assq 'ess-R-fl-keyword:fun-defs ess-R-font-lock-keywords))
381381
(ess-goto-char string-end)
@@ -389,11 +389,19 @@ namespace.")
389389
(ess-looking-at "(")))
390390
ess-function-call-face)
391391
((eq (nth 3 state) ?`)
392-
'default)
392+
nil)
393393
(t
394394
font-lock-string-face)))
395395
font-lock-comment-face))
396396

397+
;; Don't fontify backquoted symbols as strings
398+
(defun inferior-ess-r-font-lock-syntactic-face-function (state)
399+
(if (nth 3 state)
400+
(if (eq (nth 3 state) ?`)
401+
nil
402+
font-lock-string-face)
403+
font-lock-comment-face))
404+
397405
(defvar ess-r--non-fn-kwds
398406
'("in" "else" "break" "next" "repeat"))
399407

@@ -2387,6 +2395,7 @@ state.")
23872395
:group 'ess-proc
23882396
(ess-setq-vars-local ess-r-customize-alist)
23892397
(setq-local ess-font-lock-keywords 'inferior-ess-r-font-lock-keywords)
2398+
(setq-local font-lock-syntactic-face-function #'ess-r-font-lock-syntactic-face-function)
23902399
(setq-local comint-process-echoes (eql ess-eval-visibly t))
23912400
(setq-local comint-prompt-regexp inferior-S-prompt)
23922401
(setq-local syntax-propertize-function ess-r--syntax-propertize-function)

test/ess-test-r-mode.el

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
;;; ess-test-r-mode.el --- ESS tests for R mode -*- lexical-binding: t; -*-
2+
;;
3+
;; This file is free software; you can redistribute it and/or modify
4+
;; it under the terms of the GNU General Public License as published by
5+
;; the Free Software Foundation; either version 2, or (at your option)
6+
;; any later version.
7+
;;
8+
;; This file is distributed in the hope that it will be useful,
9+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
;; GNU General Public License for more details.
12+
;;
13+
;; A copy of the GNU General Public License is available at
14+
;; https://www.r-project.org/Licenses/
15+
;;
16+
;;; Commentary:
17+
;;
18+
19+
(etest-deftest-r test-ess-inferior-r-backticked ()
20+
"Backticked symbols are not fontified as strings."
21+
:case "¶`f¶oo¶`"
22+
:eval (progn
23+
(setq-local font-lock-syntactic-face-function
24+
'inferior-ess-r-font-lock-syntactic-face-function)
25+
(font-lock-ensure)
26+
(should (not (face-at-point)))))

test/run-tests

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@
3232
(when (member "--org" argv)
3333
(load (expand-file-name "ess-test-org.el" ess-test-path) nil t))
3434
(when (member "--r-core" argv)
35-
(load (expand-file-name "ess-test-rd.el" ess-test-path) nil t)
36-
(load (expand-file-name "ess-test-r.el" ess-test-path) nil t)
37-
(load (expand-file-name "ess-test-r-package.el" ess-test-path) nil t)
3835
(load (expand-file-name "ess-test-r-eval.el" ess-test-path) nil t)
36+
(load (expand-file-name "ess-test-r-mode.el" ess-test-path) nil t)
37+
(load (expand-file-name "ess-test-r-package.el" ess-test-path) nil t)
3938
(load (expand-file-name "ess-test-r-syntax.el" ess-test-path) nil t))
39+
(load (expand-file-name "ess-test-r.el" ess-test-path) nil t)
40+
(load (expand-file-name "ess-test-rd.el" ess-test-path) nil t)
4041
(when (member "--r-indent" argv)
4142
(load (expand-file-name "ess-test-indentation.el" ess-test-path) nil t))
4243
(when (member "--r-pkg" argv)

0 commit comments

Comments
 (0)