Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

electric-quote-mode support #165

Closed
jacksonrayhamilton opened this issue Sep 18, 2016 · 10 comments
Closed

electric-quote-mode support #165

jacksonrayhamilton opened this issue Sep 18, 2016 · 10 comments

Comments

@jacksonrayhamilton
Copy link

I tried using Emacs 25's new electric-quote-mode with this mode, but my quote characters don't seem to be transformed.

I opened a .md file in this mode and enabled electric-quote-mode, and typed:

`And I said,' 
``Hello World!''

I expected it to become:

‘And I said,’
“Hello World!”

If I open a .c file and type the same thing into a comment, the quote characters are transformed. So it seems to be an issue with this mode.

The docs for electric-quote-mode say,

This occurs only in comments, strings, and text paragraphs . . .

Maybe markdown-mode paragraphs are not being considered proper "paragraphs" by Emacs?

@legends2k
Copy link

legends2k commented Nov 14, 2016

I'm affected by this too. However, this mightn't be easy since ` is used for inline code spans in Markdown; incorporating this will have wrinkles in the workflow.

@jrblevin
Copy link
Owner

I didn't know about electric-quote-mode, but it would be nice to support. The major problem would be the conflict with the ` character, which is important in Markdown for inline code and code blocks. I'm not sure how to easily distinguish between the two intents: starting a code fragment or opening a quotation.

I did, however, manage to figure out why electric-quote-mode refuses to operate in markdown-mode: there is a condition in electric-quote-post-self-insert-function that checks to see if comment-start is non-nil. markdown-mode does define a comment syntax (HTML comments), as opposed to text-mode, which has no comment syntax. Because of that, electric-quote-mode only wants to operate inside of comments and strings (as would be entirely appropriate for most programming modes). So, if you start a comment in markdown-mode with <!-- then electric-quote-mode will work as expected.

Due to the way electric-quote-mode is implemented, I don't see a way around this other than re-implementing the behavior in markdown-mode, but then there is the ` conflict to deal with.

@jacksonrayhamilton
Copy link
Author

there is a condition in electric-quote-post-self-insert-function that checks to see if comment-start is non-nil

It sounds like electric-quote-mode is "duck-typing" "text" vs "programming" modes based on the existence of comment syntax. Maybe electric-quote-mode should be updated so that we can hint to it that our mode is sort of a "hybrid text and programming mode" and should support both types of transformations.

To deal with the backtick conflict, maybe electric-quote-mode should be able to retroactively transform the quotes only if it sees that a backtick and an apostrophe match. The markdown syntax for inline code spans are matching backticks, so they could be differentiated at that point.

@phst
Copy link
Contributor

phst commented May 10, 2017

FYI, a while ago I've filed https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24709 against Emacs that also touches on some of these points.

@phst
Copy link
Contributor

phst commented Jun 28, 2017

The original issue should be fixable by setting comment-use-syntax to nil (#213). That doesn't fix the clash between electric quote and code start for the backtick, though.

@jrblevin
Copy link
Owner

I see that if comment-use-syntax was nil, that would fix the issue. However, markdown-mode does use the syntax table for comments and so setting it to nil would be incorrect. I think we're back to this being an issue with the assumptions of electric-quote-mode about modes that define comment syntax.

@phst
Copy link
Contributor

phst commented Jul 2, 2017

You're right; probably electric-quote-mode should just treat text-mode as a stronger signal than comment syntax.

@phst
Copy link
Contributor

phst commented Jul 9, 2017

I've now pushed a series of patches to Emacs to improve compatibility. Specifically, electric-quote-mode now checks text-mode first, and there's a special hook electric-quote-inhibit-functions to selectively inhibit electric quoting, which could be used for code spans and blocks.

@jrblevin
Copy link
Owner

This is great; thanks for your work on both Emacs and markdown-mode on this front. I just merged #220.

@jrblevin
Copy link
Owner

I verified that electric-quote-mode is working as expected with markdown-mode using a recent Emacs 26 pretest build, thanks to the patches by @phst, so I'll close this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants