emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Question Regarding Yasnippet With Org Mode (Emacs 27.2)
@ 2021-05-23  4:51 Samuel Banya
  2021-05-23 16:33 ` Greg Minshall
  2021-05-23 21:18 ` Sébastien Miquel
  0 siblings, 2 replies; 8+ messages in thread
From: Samuel Banya @ 2021-05-23  4:51 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 4081 bytes --]

I haven't been able to utilize the Yasnippet I've been using to override the newer one that Org-Mode created aka '<s' + TAB expansion, which does source blocks in lowercase, which I despise.

I placed my override Yasnippet template in '~/.emacs.d/snippets/org-mode/src'

Mine used to be just fine until I upgraded to Emacs 27.2.
*
*
*Here is the affected Yasnippet that I have placed in '~/.emacs.d/snippets/org-mode/src' whose aim is to just override the default non-Caps version of the same idea:*

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

Here is what I get when I attempt to do "<s TAB" in an Org Mode doc buffer within the modeline:
No such language mode: nil-mode

*What's weird about this is that another similar snippet I did for bash works just fine in comparison, though obviously the user doesn't have to specify the language being used so maybe that's why, this is present in '~/.emacs.d/snippets/org-mode/bashsrc':*

# -*- mode: snippet -*- # name: bashsrc # key: <b # -- #+BEGIN_SRC bash   $0 #+END_SRC

Has anyone else ran into this issue?

I'm guessing its some kind of Org Mode vs Yasnippet issue where Org-mode is expanding it too fast, when it should wait for user input hence the "$1" section.

*
*
*Here's the traceback:*

Debugger entered--Lisp error: (error "No such language mode: nil-mode")

signal(error ("No such language mode: nil-mode"))

error("No such language mode: %s" nil-mode)

org-edit-src-code()

org-babel-do-key-sequence-in-edit-buffer("\11")

org-indent-line()

indent-according-to-mode()

yas--indent-region(115547 115559 #s(yas--snippet :expand-env nil :fields (#s(yas--field :number 1 :start #<marker at 115546 in life.org> :end #<marker at 115546 in life.org> :parent-field nil :mirrors nil :transform nil :modified-p nil :next #s(yas--exit :marker #<marker at 115549 in life.org> :next nil))) :exit #s(yas--exit :marker #<marker at 115549 in life.org> :next nil) :id 3 :control-overlay nil :active-field nil :previous-active-field nil :force-exit nil))

yas--indent(#s(yas--snippet :expand-env nil :fields (#s(yas--field :number 1 :start #<marker at 115546 in life.org> :end #<marker at 115546 in life.org> :parent-field nil :mirrors nil :transform nil :modified-p nil :next #s(yas--exit :marker #<marker at 115549 in life.org> :next nil))) :exit #s(yas--exit :marker #<marker at 115549 in life.org> :next nil) :id 3 :control-overlay nil :active-field nil :previous-active-field nil :force-exit nil))

#f(compiled-function () #<bytecode 0xf63605>)()

funcall(#f(compiled-function () #<bytecode 0xf63605>))

(let nil (funcall '#f(compiled-function () #<bytecode 0xf63605>)))

eval((let nil (funcall '#f(compiled-function () #<bytecode 0xf63605>))))

yas--snippet-create("#+BEGIN_SRC $1\n $0\n#+END_SRC" nil 115534 115534)

yas-expand-snippet(#s(yas--template :key "<s" :content "#+BEGIN_SRC $1\n $0\n#+END_SRC" :name "src" :condition nil :expand-env nil :load-file "/home/sam/.emacs.d/snippets/org-mode/src" :save-file nil :keybinding nil :uuid "src" :menu-binding-pair ((menu-item "src" (lambda nil (interactive) (yas--expand-or-visit-from-menu 'org-mode "src")) :keys "<s =>")) :group nil :perm-group nil :table #s(yas--table :name "org-mode" :hash #<hash-table equal 2/65 0x17ba06d> :uuidhash #<hash-table equal 2/65 0x138c6e1> :parents nil :direct-keymap (keymap))) 115534 115536)

yas--expand-or-prompt-for-template((("src" . #s(yas--template :key "<s" :content "#+BEGIN_SRC $1\n $0\n#+END_SRC" :name "src" :condition nil :expand-env nil :load-file "/home/sam/.emacs.d/snippets/org-mode/src" :save-file nil :keybinding nil :uuid "src" :menu-binding-pair ((menu-item "src" (lambda nil (interactive) (yas--expand-or-visit-from-menu ... "src")) :keys "<s =>")) :group nil :perm-group nil :table #s(yas--table :name "org-mode" :hash #<hash-table equal 2/65 0x17ba06d> :uuidhash #<hash-table equal 2/65 0x138c6e1> :parents nil :direct-keymap (keymap))))) 115534 115536)

yas-expand()

funcall-interactively(yas-expand)

call-interactively(yas-expand nil nil)

command-execute(yas-expand)

Thanks.

[-- Attachment #2: Type: text/html, Size: 5297 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Question Regarding Yasnippet With Org Mode (Emacs 27.2)
  2021-05-23  4:51 Question Regarding Yasnippet With Org Mode (Emacs 27.2) Samuel Banya
@ 2021-05-23 16:33 ` Greg Minshall
  2021-05-24  1:09   ` Samuel Banya
  2021-05-23 21:18 ` Sébastien Miquel
  1 sibling, 1 reply; 8+ messages in thread
From: Greg Minshall @ 2021-05-23 16:33 UTC (permalink / raw)
  To: Samuel Banya; +Cc: emacs-orgmode

Samuel,

i think that by default, Org no longer listens to, e.g., =<s[TAB]=.
but, if you load =org-tempo=, it still does.  i wonder if you might see
if you are loading =org-tempo= (maybe [C-h v org-modules]), disable
that, and see if that clears away some of the underbrush.

(you can get something like the old behavior with =C-c C-,=.)

i use yasnippet to expand =<le[TAB]=.
----
# key: <le
# name: latex equation environment
# --
\begin{equation}
    $0
\end{equation}
----
and, that works for me.

if i re-format your snippet (maybe this was the original formatting?)
----
# name: src
# key: <s
# --
#+BEGIN_SRC $1
$0
#+END_SRC
----

and open an org file, =<s[TAB]=, it seems to work if i enter a language
name and then =[TAB]= to commit.  if i commit with =[RET]= instead, it
still *seems* to work (in terms of the buffer contents), but i get this
message
----
[yas] Committing snippets. Action would destroy a protection overlay.
----

i didn't run into any lisp errors.

in case any of that helps.

cheers, Greg


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Question Regarding Yasnippet With Org Mode (Emacs 27.2)
  2021-05-23  4:51 Question Regarding Yasnippet With Org Mode (Emacs 27.2) Samuel Banya
  2021-05-23 16:33 ` Greg Minshall
@ 2021-05-23 21:18 ` Sébastien Miquel
  2021-05-24  1:04   ` Samuel Banya
  1 sibling, 1 reply; 8+ messages in thread
From: Sébastien Miquel @ 2021-05-23 21:18 UTC (permalink / raw)
  To: Samuel Banya, emacs-orgmode

Hi Samuel,

> I'm guessing its some kind of Org Mode vs Yasnippet issue where 
> Org-mode is expanding it too fast, when it should wait for user input 
> hence the "$1" section.

I guess yasnippet tries to indent the inside of the block (see
=yas-indent-line=) before the lang part of the src block is specified.

In Emacs 27.2, the default value of =org-src-tab-acts-natively= was
changed to `t`. With this setting, trying to indent a src block with
no language results in this error.

-- 
Sébastien Miquel



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Question Regarding Yasnippet With Org Mode (Emacs 27.2)
  2021-05-23 21:18 ` Sébastien Miquel
@ 2021-05-24  1:04   ` Samuel Banya
  2021-05-24  5:51     ` Sébastien Miquel
  0 siblings, 1 reply; 8+ messages in thread
From: Samuel Banya @ 2021-05-24  1:04 UTC (permalink / raw)
  To: Sébastien Miquel, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1219 bytes --]

Hey Sébastien,

Thanks for this insight.

Do you think that maybe changing the setting you had mentioned before, 'org-src-tab-acts-natively' to false (aka nil or '0' (zero) value) via a change in my configuration would make this error not happen within Org-Mode in that case?

On a related note, I use Emacs Org Mode every day for my support job, and am super thankful it exists. I have never been more productive in the last 2 years switching to Emacs than I ever have been in my entire life, so just wanted to say thanks to the best piece of software on earth.

Thanks again,

Sam

On Sun, May 23, 2021, at 9:18 PM, Sébastien Miquel wrote:
> Hi Samuel,
> 
> > I'm guessing its some kind of Org Mode vs Yasnippet issue where 
> > Org-mode is expanding it too fast, when it should wait for user input 
> > hence the "$1" section.
> 
> I guess yasnippet tries to indent the inside of the block (see
> =yas-indent-line=) before the lang part of the src block is specified.
> 
> In Emacs 27.2, the default value of =org-src-tab-acts-natively= was
> changed to `t`. With this setting, trying to indent a src block with
> no language results in this error.
> 
> -- 
> Sébastien Miquel
> 
> 

[-- Attachment #2: Type: text/html, Size: 1793 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Question Regarding Yasnippet With Org Mode (Emacs 27.2)
  2021-05-23 16:33 ` Greg Minshall
@ 2021-05-24  1:09   ` Samuel Banya
  2021-05-24  3:03     ` Greg Minshall
  0 siblings, 1 reply; 8+ messages in thread
From: Samuel Banya @ 2021-05-24  1:09 UTC (permalink / raw)
  To: Greg Minshall; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1643 bytes --]

Hey there Greg,

Gotcha.

Just to confirm, you're saying I should add a "(require 'org-tempo)" in my Emacs config in that case?

Or are you saying that I should disable "org-modules" setting value by setting it to nil or '0' (zero)?

If that is the case, what would be the syntax to do this change?

Just wanted to ask since I'd be happy to make the changes my config to see if that would help, but needed to know what you meant for me to try out to fix the issue.

Thanks,

Sam

On Sun, May 23, 2021, at 4:33 PM, Greg Minshall wrote:
> Samuel,
> 
> i think that by default, Org no longer listens to, e.g., =<s[TAB]=.
> but, if you load =org-tempo=, it still does.  i wonder if you might see
> if you are loading =org-tempo= (maybe [C-h v org-modules]), disable
> that, and see if that clears away some of the underbrush.
> 
> (you can get something like the old behavior with =C-c C-,=.)
> 
> i use yasnippet to expand =<le[TAB]=.
> ----
> # key: <le
> # name: latex equation environment
> # --
> \begin{equation}
>     $0
> \end{equation}
> ----
> and, that works for me.
> 
> if i re-format your snippet (maybe this was the original formatting?)
> ----
> # name: src
> # key: <s
> # --
> #+BEGIN_SRC $1
> $0
> #+END_SRC
> ----
> 
> and open an org file, =<s[TAB]=, it seems to work if i enter a language
> name and then =[TAB]= to commit.  if i commit with =[RET]= instead, it
> still *seems* to work (in terms of the buffer contents), but i get this
> message
> ----
> [yas] Committing snippets. Action would destroy a protection overlay.
> ----
> 
> i didn't run into any lisp errors.
> 
> in case any of that helps.
> 
> cheers, Greg
> 

[-- Attachment #2: Type: text/html, Size: 2654 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Question Regarding Yasnippet With Org Mode (Emacs 27.2)
  2021-05-24  1:09   ` Samuel Banya
@ 2021-05-24  3:03     ` Greg Minshall
  0 siblings, 0 replies; 8+ messages in thread
From: Greg Minshall @ 2021-05-24  3:03 UTC (permalink / raw)
  To: Samuel Banya; +Cc: emacs-orgmode

hi, Sam,

i was thinking you might be happier, or at least experiment, *without*
=org-tempo=.  so, if you customize =org-modules=, and see =org-tempo=
enabled there, you might try disabling it.  (to move one more chance Org
is getting in the way of yasnippet.)

but, i don't know if this will help.  also, the advice from Sébastien
Miquel seems based on more actual knowledge.

cheers, Greg


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Question Regarding Yasnippet With Org Mode (Emacs 27.2)
  2021-05-24  1:04   ` Samuel Banya
@ 2021-05-24  5:51     ` Sébastien Miquel
  2021-05-29 21:12       ` Samuel Banya
  0 siblings, 1 reply; 8+ messages in thread
From: Sébastien Miquel @ 2021-05-24  5:51 UTC (permalink / raw)
  To: Samuel Banya, emacs-orgmode

Samuel Banya writes:
> Do you think that maybe changing the setting you had mentioned before, 
> 'org-src-tab-acts-natively' to false (aka nil or '0' (zero) value) via 
> a change in my configuration would make this error not happen within 
> Org-Mode in that case?

Yes, that should work. I have not tested it though.

Regards,

-- 
Sébastien Miquel



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Question Regarding Yasnippet With Org Mode (Emacs 27.2)
  2021-05-24  5:51     ` Sébastien Miquel
@ 2021-05-29 21:12       ` Samuel Banya
  0 siblings, 0 replies; 8+ messages in thread
From: Samuel Banya @ 2021-05-29 21:12 UTC (permalink / raw)
  To: Sébastien Miquel, Charles Berry

[-- Attachment #1: Type: text/plain, Size: 887 bytes --]

Just wanted to update this thread in that the following DID resolve my issue with my Yasnippet template which overrides the default "<s" template as I prefer "#+BEGIN_SRC" in CAPS instead of the newer lowercase variant:

#+BEGIN_SRC emacs-lisp
  (setq org-src-tab-acts-natively nil)
#+END_SRC

I include that section in my config, and it works as intended now :)

Thanks for the help on this, Org Mode rules like usual!

On Mon, May 24, 2021, at 5:51 AM, Sébastien Miquel wrote:
> Samuel Banya writes:
> > Do you think that maybe changing the setting you had mentioned before, 
> > 'org-src-tab-acts-natively' to false (aka nil or '0' (zero) value) via 
> > a change in my configuration would make this error not happen within 
> > Org-Mode in that case?
> 
> Yes, that should work. I have not tested it though.
> 
> Regards,
> 
> -- 
> Sébastien Miquel
> 
> 

[-- Attachment #2: Type: text/html, Size: 1429 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-29 21:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-23  4:51 Question Regarding Yasnippet With Org Mode (Emacs 27.2) Samuel Banya
2021-05-23 16:33 ` Greg Minshall
2021-05-24  1:09   ` Samuel Banya
2021-05-24  3:03     ` Greg Minshall
2021-05-23 21:18 ` Sébastien Miquel
2021-05-24  1:04   ` Samuel Banya
2021-05-24  5:51     ` Sébastien Miquel
2021-05-29 21:12       ` Samuel Banya

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).