0

I use polymode when editing Rmarkdown files in Emacs 26.1 and have the following problem. I visit a new file, test.Rmd, and type the following at the top of the file (this creates a yaml chunk):

---         ;; self-insert-command * 3
RET         ;; markdown-enter-key
---         ;; self-insert-command * 3
C-a         ;; move-beginning-of-line
RET         ;; markdown-enter-key
C-p         ;; previous-line
123         ;; self-insert-command * 3
C-n         ;; next-line
C-e         ;; move-end-of-line
RET         ;; markdown-enter-key
123         ;; self-insert-command * 3
RET         ;; markdown-enter-key

The result is that the text inside the chunk displays and is entered right to left, which is backwards; outside the chunk it is entered left to right, as expected. This is what I see and this is also how the file is saved:

---
321
---
123

I first encountered this with Emacs 26.2 under Ubuntu 18.04, but I was able to reproduce it with a fresh install of Emacs 26.1 in Ubuntu 19.04. Here is the complete .emacs:

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives
         '("melpa-stable" . "http://melpa-stable.milkbox.net/packages/") t)
(when (< emacs-major-version 24)
  ;; For important compatibility libraries like cl-lib
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
(custom-set-variables
 '(package-selected-packages (quote (poly-R poly-markdown poly-noweb polymode))))

(autoload 'markdown-mode "markdown-mode"
  "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(require 'poly-R)
(require 'poly-markdown)
(add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))
(add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))
(add-to-list 'auto-mode-alist '("\\.md" . poly-markdown-mode))

And here are the contents of the elpa directory:

archives
gnupg
markdown-mode-2.3
poly-markdown-0.1.5
polymode-0.1.5
poly-noweb-0.1.5
poly-R-0.1.5

This also happens with the latest available versions of these packages and it also sometimes happens with R chunks.

  • This sounds like it might be a bug. Depending on what you learn from answers and comments here, you might want to file a bug report: M-x report-emacs-bug. – Drew May 3 at 17:34
  • @Drew: I did file an issue in the polymode repository on github, with a link to this post. My guess is that the emacs developers would turf this to the polymode developers, which seems reasonable to me as a first step. – Robert McDonald May 3 at 17:59
  • The issue in github is github.com/polymode/polymode/issues/226 – Robert McDonald May 3 at 20:17
0

This behavior is a bug that has been addressed in polymode-20190507, which is available in melpa. For more details see https://github.com/polymode/polymode/issues/226.

The polymode developer thinks it's an Emacs bug (related to newline) but has incorporated a workaround in polymode.

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.