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

org-mode #+END_SRC strange behaviour #707

Closed
habamax opened this issue May 30, 2016 · 15 comments
Closed

org-mode #+END_SRC strange behaviour #707

habamax opened this issue May 30, 2016 · 15 comments

Comments

@habamax
Copy link

habamax commented May 30, 2016

I have implemented trivial snippet:

# -*- mode: snippet -*-
# name: org src
# key: src
# --
#+BEGIN_SRC $1
$0
#+END_SRC

After expanding the last C in END_SRC transforms into E.

image

If I add additional C to it like END_SRCC then it expands normally.

image

GNU Emacs 24.5.1 (i686-pc-mingw32) of 2015-04-11 on LEG570
yasnippet 20160517.1628 installed Yet another snippet extension for Emacs.

@npostavs
Copy link
Collaborator

Doesn't happen here. I have the identical Emacs version as you. Did you start from emacs -Q?

From the yasnippet checkout I ran emacs -Q -L . -l yasnippet -f yas-global-mode -f org-mode, then

  • C-u M-x yas-new-snippet
  • pasted your trivial snippet
  • C-c C-l to load it
  • C-x b to switch back to *scratch* (which is in org-mode)
  • typed src
  • hit <tab>
  • snippet expanded normally (I typed some garbage into $1):
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.

#+BEGIN_SRC sdad

#+END_SRC

GNU Emacs 24.5.1 (i686-pc-mingw32) of 2015-04-11 on LEG570
yasnippet 47dbe93 (2016-05-24 08:24:18)

@habamax
Copy link
Author

habamax commented May 30, 2016

Nope, I didn't.
The line you gave me loads emacs with errors: Cannot open load file: no such file or directory, yasnippet.

If I try emacs -Q then again I am not sure how to load yasnippet. (require 'yasnippet) doesn't work.

But. I have tried your steps with my config and It works! (I have only changed the key to srdc)
So the snippet from the file works strange, the same snippet loaded from buffer works just fine.

The file is named src and is in ~/.emacs.d/snippet/org-mode/ folder.

I have renamed it to src.txt just to be able to upload here:
src.txt

@habamax
Copy link
Author

habamax commented May 30, 2016

well, if I rename file to code with the same key src everything works.
Then if I rename file to src with the key src -- I get END_SRE.

@npostavs
Copy link
Collaborator

The line you gave me loads emacs with errors: Cannot open load file: no such file or directory, yasnippet.

It should work if you run from the directory where yasnippet is installed, which for you is probably something like ~/.emacs.d/elpa/yasnippet-20160517.1628/

So the snippet from the file works strange, the same snippet loaded from buffer works just fine.

Hmm, I tried with the src file in ~/.emacs.d/snippet/org-mode/ and also ~/src/yasnippet/snippets/org-mode/ but it works fine there too. Maybe you have another snippet in your collection with the same name? What happens if you M-x yas-visit-snippet-file RET org src RET?

well, if I rename file to code with the same key src everything works.

Are you keeping the #name: field the same in this case?

@habamax
Copy link
Author

habamax commented May 30, 2016

What happens if you M-x yas-visit-snippet-file RET org src RET?

I have 4 org snippets defined: org src, org quote, org verse, org title. All of them works except org src.
Anyway choosing org src I open file src.

Are you keeping the #name: field the same in this case?

Yes

Thanks for pointing out how to run emacs from the yasnippet dir. I get the same result as in first message.

I have run C:\prg\emacs\bin\emacs -Q -L . -l yasnippet -f yas-global-mode -f org-mode
and then just issued src<tab> and got END_SRE.

@habamax
Copy link
Author

habamax commented May 30, 2016

I don't know if it is windows specific issue or not -- I will check the same on a mac tomorrow.

What I have found so far:

  1. if the filename of that snippet starts with a letter s then I get END_SRE
  2. any other starting letter of a filename give normal result

I tried filenames source, string, sss -- bad result and ttt, code, wwww -- good result

@npostavs
Copy link
Collaborator

I don't know if it is windows specific issue or not

I'm testing with Windows and not seeing any problem.

I have run C:\prg\emacs\bin\emacs -Q -L . -l yasnippet -f yas-global-mode -f org-mode
and then just issued src<tab> and got END_SRE.

Hmm. Maybe if we add some tracing, can you try emacs -Q -L . -l yasnippet --eval "(mapc 'trace-function '(yas--parse-template yas--templates-for-key-at-point))" -f yas-global-mode -f org-mode, type src<tab> and post the output you get in *trace-output* buffer.

@habamax
Copy link
Author

habamax commented May 30, 2016

filename: ~/.emacs.d/snippet/org-mode/string

# -*- mode: snippet -*-
# name: org code
# key: code
# --
#ABRACADABRA $1

END SRC

after expand I get END SRE.
If there is something else instead of END or SRC then it is OK...

@habamax
Copy link
Author

habamax commented May 30, 2016

without expanding I can see immediately in trace-output

======================================================================
1 -> (yas--parse-template "c:/Users/usrusrusr/.emacs.d/snippets/org-mode/src")
1 <- yas--parse-template: ("src" "#BEGIN_SRC $1
$0
#END_SRE" "org src" nil nil nil "c:/Users/usrusrusr/.emacs.d/snippets/org-mode/src" nil nil)
======================================================================

`

@habamax
Copy link
Author

habamax commented May 30, 2016

Oh. That is a combination of 2 snippets.

I have deleted 3 other org snippets I have and it works.

Then I add another snippet quote which is basically the same:

# -*- mode: snippet -*-
# name: org quote
# key: quote
# --
#+BEGIN_QUOTE
$0
#+END_QUOTE

and when they are both in org-mode folder, then src is incorrect.

@npostavs
Copy link
Collaborator

and when they are both in org-mode folder, then src is incorrect.

Aha, yes, I see this too.

@habamax
Copy link
Author

habamax commented May 30, 2016

Thanks..

I was thinking there is smth wrong either with me or my laptop :)

@npostavs
Copy link
Collaborator

Reported this as Emacs bug #23659

@habamax
Copy link
Author

habamax commented May 31, 2016

I have checked it -- fixed.

PS I had to reinstall yasnippet as there was an error after update:

yas--subdirs: Opening directory: no such file or directory,      c:/Users/usrusrusr/.emacs.d/elpa/yasnippet-20160517.1628/snippets/org-mode

@npostavs
Copy link
Collaborator

npostavs commented Jun 1, 2016

PS I had to reinstall yasnippet as there was an error after update:

Ah, because package.el doesn't reload yasnippet.el. Restarting Emacs, or doing M-x load-library RET yasnippet RET should also work. The package.el in the Emacs pretesting versions (latest as of now is 25.0.94) reloads automatically.

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

2 participants