Comments (3)
I will solve this some day in a general, non ESS specific, way. For time
being, please add empty lines before and after the code.
On 29 July 2013 06:29, Peter Meilstrup [email protected] wrote:
Open an .Rmd file and type in
testing...
x <- function() { 1 }Position cursor in the function and type C-c C-c, C-c C-p, or such. It
tries to evaluate the lines with the backticks along with the lines
belonging to the function.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/6
.
from polymode.
This works for me:
(defun Rmd-setup ()
(setq paragraph-start "```\\|\\s-*$")
(setq paragraph-separate "```\\|\\s-*$"))
(add-hook 'poly-markdown+r-mode-hook 'Rmd-setup)
from polymode.
I encountered a related issue trying to evaluate functions from within fenced code blocks. The backticks in the fences, or apostrophes in the preceding markdown chunk, will make ESS think it is inside a string, and so refuse to evaluate the code. A possible approach to fixing this issue, and the one that @crowding raised, is the following advice:
EDITED Jan 27 - forgot the else
clause!
(defun pm-ess-limit-eval-to-chunk (orig-fun &rest args)
"Wrapper for ess-eval-functions.
Without this, apostrophes in the preceding text chunk cause
ess-mark-function, ess-send-function to fail, thinking they are inside a
string. Similarly, ess-eval-paragraph gets confused by the fence rows."
(interactive)
(let (res)
(if poly-markdown+r-mode
(save-restriction
(pm/narrow-to-span)
(setq res (apply orig-fun args)))
(setq res (apply orig-fun args)))
res))
(advice-add 'ess-beginning-of-function :around #'pm-ess-limit-eval-to-chunk)
(advice-add 'ess-eval-paragraph :around #'pm-ess-limit-eval-to-chunk)
Since this code will only modify the behaviour of the functions in question from within polymode, it should be safe to apply generally. However, there may be better solutions than global advice? If not, I can wrap this up in a pull request.
from polymode.
Related Issues (20)
- Debugger entered--Lisp error: (void-variable polymode-run-these-before-change-functions-in-other-buffers) HOT 4
- Detecting that I'm in an inner chunk, from a major mode hook HOT 2
- On entering emacs lisp source block, text at top of org file is underlined in yellow/red by flycheck HOT 1
- unable to install manually HOT 2
- Help with a (hopefully) simple polymode?
- Reproducible error: stuck in latex-mode
- Starting polymode with lsp, makes the cursor to jump to the end of buffer HOT 10
- can't find polymode via package-install? HOT 1
- electric-indent-mode
- How to run a function is indirect buffers with the same major mode only?
- Typescript-xml polymode
- Setting mode file local variable to polymode applies itself recursively infinitely until cancelled
- Background Adjustment when Background Unspecified
- polymode creates additional [web] buffer
- Interaction with nix-mode: font-lock broken HOT 4
- Chunks not following automatic Emacs switch to light/dark theme HOT 5
- Polymode, Poly-COMEEGA and COMEEGA (Collaborative Org Mode Enhanced Emacs Generalized Authorship)
- inner mode indentation not works on the first line after head mark
- org-mode links become invisible HOT 3
- Polymode does not work in org-edit-special
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polymode.