Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Moving one char backward when expanding the snippet
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  18 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dror Atariah  
View profile  
 More options Jul 12 2012, 10:10 am
From: Dror Atariah <dror...@gmail.com>
Date: Thu, 12 Jul 2012 07:10:13 -0700 (PDT)
Local: Thurs, Jul 12 2012 10:10 am
Subject: Moving one char backward when expanding the snippet

I'm trying to write a snippet which will expand to "\footnote{}" in LaTeX.
The problem is the final code should look like:
*Hello World\footnote{The footnote}*
*
*
The goal is to be able to type the following:
*w o r d SPC f o o t TAB*
which will expand to:
*word\footnote{}*
I manage to get the following result:
*word \footnote{}*
*Note the space after 'word' which must not be there.*
*
*
I'm trying to use the *backward-char* function in the following way:
*`(backward-char 1)`\footnote{$1}$2*
but this doesn't work... I keep getting the space after the last word.

How can I avoid this? What is the right way to go?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joao  
View profile  
 More options Jul 12 2012, 2:23 pm
From: Joao <joaotav...@gmail.com>
Date: Thu, 12 Jul 2012 11:23:51 -0700 (PDT)
Local: Thurs, Jul 12 2012 2:23 pm
Subject: Re: Moving one char backward when expanding the snippet

This is interesting and *might* be a use for the issue described in
https://github.com/capitaomorte/yasnippet/issues/28. I've added your email
to the issue and you can track it's implementation there/solution there.

Thanks,
João


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dror Atariah  
View profile  
 More options Jul 12 2012, 3:27 pm
From: Dror Atariah <dror...@gmail.com>
Date: Thu, 12 Jul 2012 12:27:05 -0700 (PDT)
Local: Thurs, Jul 12 2012 3:27 pm
Subject: Re: Moving one char backward when expanding the snippet

So you're saying that my code is correct but there's some feature/bug which
doesn't make it happen as expected? I have to say I didn't understand much
from the link you added, as I am a newbie to lisp...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
João Távora  
View profile  
 More options Jul 12 2012, 6:48 pm
From: João Távora <joaotav...@gmail.com>
Date: Thu, 12 Jul 2012 23:48:05 +0100
Local: Thurs, Jul 12 2012 6:48 pm
Subject: Re: Moving one char backward when expanding the snippet
Hi,

On Thu, Jul 12, 2012 at 8:27 PM, Dror Atariah <dror...@gmail.com> wrote:
> So you're saying that my code is correct but there's some feature/bug which
> doesn't make it happen as expected? I have to say I didn't understand much
> from the link you added, as I am a newbie to lisp...

More or less, but you're right I didn't make myself very clear. I
*was* saying that the behaviour you request might not be currently
supported by yasnippet in its current state and that the feature
requested in https://github.com/capitaomorte/yasnippet/issues/28
would, in principle, allow you to write a little addition to your
snippet that makes it work like you intend it to.

But I have analysed this a bit more and remembered that yasnippet
*can* already solve your problem if you write your snippet as a
snippet-command. Try this

# -*- mode: snippet -*-
# name: latex footnote
# key: foot
# type: command
# --
(skip-syntax-backward " ")
(yas/expand-snippet "\\footnote{${1:the footnote test}}")

--
João Távora

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dror Atariah  
View profile  
 More options Jul 13 2012, 2:49 am
From: Dror Atariah <dror...@gmail.com>
Date: Thu, 12 Jul 2012 23:49:36 -0700 (PDT)
Local: Fri, Jul 13 2012 2:49 am
Subject: Re: Moving one char backward when expanding the snippet

Good morning,

> But I have analysed this a bit more and remembered that yasnippet
> *can* already solve your problem if you write your snippet as a
> snippet-command. Try this

> # -*- mode: snippet -*-
> # name: latex footnote
> # key: foot
> # type: command
> # --
> (skip-syntax-backward " ")
> (yas/expand-snippet "\\footnote{${1:the footnote test}}")

This doesn't work - it just expands to the plain text in the code above and
seems like it doesn't evaluate the lisp code.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
João Távora  
View profile  
 More options Jul 13 2012, 3:26 am
From: João Távora <joaotav...@gmail.com>
Date: Fri, 13 Jul 2012 08:26:49 +0100
Local: Fri, Jul 13 2012 3:26 am
Subject: Re: Moving one char backward when expanding the snippet
You have to have a relatively recent version of yasnippet, i.e. 0.6
will *no* work. Which  are you using?

If you're using a recent version, how exactly did you install the
snippet and attempt to expand the I provided?

--
João Távora

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dror Atariah  
View profile  
 More options Jul 13 2012, 4:26 am
From: Dror Atariah <dror...@gmail.com>
Date: Fri, 13 Jul 2012 01:26:20 -0700 (PDT)
Local: Fri, Jul 13 2012 4:26 am
Subject: Re: Moving one char backward when expanding the snippet

I'm using Aquamacs, and clicking YASnippet->About yields: "yasnippet
(version 0.6.1b). If I understand correctly, the next version is 0.6.1c?
would it make a difference?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
João Távora  
View profile  
 More options Jul 13 2012, 5:43 am
From: João Távora <joaotav...@gmail.com>
Date: Fri, 13 Jul 2012 10:43:22 +0100
Local: Fri, Jul 13 2012 5:43 am
Subject: Re: Moving one char backward when expanding the snippet
No, it wouldn't. You need to either wait for the official 0.7 or visit
http://github.com/capitaomorte/yasnippet and follow instructions there
to install the most recent version.

--
João Távora

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dror Atariah  
View profile  
 More options Jul 13 2012, 8:36 am
From: Dror Atariah <dror...@gmail.com>
Date: Fri, 13 Jul 2012 05:36:29 -0700 (PDT)
Local: Fri, Jul 13 2012 8:36 am
Subject: Re: Moving one char backward when expanding the snippet

I installed the newest version and your snippet doesn't work at all...
"foot[TAB]" does nothing.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
João Távora  
View profile  
 More options Jul 13 2012, 9:53 am
From: João Távora <joaotav...@gmail.com>
Date: Fri, 13 Jul 2012 14:53:49 +0100
Local: Fri, Jul 13 2012 9:53 am
Subject: Re: Moving one char backward when expanding the snippet
I can't help you with such a poor description. Please provide a
complete description of your problem, detailing all the steps you
performed. Use a "reproduction recipe", if possible, starting with a
clean "emacs -Q" run.

Thanks!
João

On Fri, Jul 13, 2012 at 1:36 PM, Dror Atariah <dror...@gmail.com> wrote:
> I installed the newest version and your snippet doesn't work at all...
> "foot[TAB]" does nothing.

> --
> You received this message because you are subscribed to the Google Groups
> "smart-snippet and YASnippet" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/smart-snippet/-/WorU5zW6RRcJ.

> To post to this group, send email to smart-snippet@googlegroups.com.
> To unsubscribe from this group, send email to
> smart-snippet+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/smart-snippet?hl=en.

--
João Távora

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dror Atariah  
View profile  
 More options Jul 13 2012, 10:49 am
From: Dror Atariah <dror...@gmail.com>
Date: Fri, 13 Jul 2012 07:49:21 -0700 (PDT)
Local: Fri, Jul 13 2012 10:49 am
Subject: Re: Moving one char backward when expanding the snippet

Sorry, I'll try to describe what I did, although I think it is rather the
straightest you get.

   1. First, I'll mention this again, I'm using 'Aquamacs' on Mac OS X.
   2. I downloaded the latest version from the repository into my
   '~/Library/elisp' directory.
   3. Copied my snippets to the new version (I know I can probably somehow
   leave the snippets somewhere else, I tried to do it quickly).
   4. Closed and opened 'Aquamacs' and tested YASNIPPET. Everything OK so
   far.
   5. Tried to run the snippet in question (after copy pasting your code to
   a new snippet. Saving it along with the other snippets and
   'yas/reload-all'. Nothing happen. That is 'foo foot[TAB]' yields 'foo
   foot'.

On Friday, July 13, 2012 3:53:49 PM UTC+2, Joao wrote:

> I can't help you with such a poor description. Please provide a
> complete description of your problem, detailing all the steps you
> performed. Use a "reproduction recipe", if possible, starting with a
> clean "emacs -Q" run.

I don't know what 'emacs -Q' does, and I couldn't find 'Aquamacs'
equivalent. Sorry...

Is it better now?

Thanks a lot!
Dror


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
João Távora  
View profile  
 More options Jul 13 2012, 12:28 pm
From: João Távora <joaotav...@gmail.com>
Date: Fri, 13 Jul 2012 17:28:34 +0100
Local: Fri, Jul 13 2012 12:28 pm
Subject: Re: Moving one char backward when expanding the snippet
I still can't be sure from your description  that you're using the new
yasnippet. I need something i can reproduce **without** Aquamacs,
which I don't support and have little idea how it works.

I would need something like

1. Downloaded yasnippet from <url> using <git, wget, browser>
2. Unzipped the <file> onto <location> (or "git cloned onto <location>")
3. Started a very light Emacs (the -Q parameter is used to remove any
customizations you have) and typed into the *scratch* buffer
   (add-to-list 'load-path "<location>")
   (require 'yasnippet)
   (yas/global-mode 1)
4. Placed a new snippet with "# key: <some-key>" from file <file> in
~/.emacs.d/snippets/<some-mode> or <location2>/<some-mode>
5. Opened a <some-mode> buffer
6. Typed the snippet key <some-key>
7. Typed TAB

Anyway

1. Use "M-x yas/version" and tell me what version it outputs
2. Whichever way you were using to define new snippets, use it, but
instead of writing your old snippet, write the one I gave you. Don't
modify the snippet directives, just make sure they iclude the new "#
type: command" directive.
3. Try using "M-x yas/new-snippet" to write the snippet when you're
done just type "C-c C-c", follow instructions in the minibuffer. No
need to use `yas/reload-all` at all.

Hope this helps,
João

--
João Távora

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dror Atariah  
View profile  
 More options Jul 13 2012, 3:40 pm
From: Dror Atariah <dror...@gmail.com>
Date: Fri, 13 Jul 2012 12:40:39 -0700 (PDT)
Local: Fri, Jul 13 2012 3:40 pm
Subject: Re: Moving one char backward when expanding the snippet

Good evening,

> I would need something like

I'll try again

1. Downloaded yasnippet from <url> using <git, wget, browser>


I used the git option.  

> 2. Unzipped the <file> onto <location> (or "git cloned onto <location>")

I checked it out into "~/Library/elisp/yasnippet"

> 3. Started a very light Emacs (the -Q parameter is used to remove any
> customizations you have) and typed into the *scratch* buffer
>    (add-to-list 'load-path "<location>")
>    (require 'yasnippet)
>    (yas/global-mode 1)

In *scratch* I ran:
---
 (add-to-list 'load-path "~/Library/elisp/yasnippet")
   (require 'yasnippet)
   (yas/global-mode 1)
---
after removing my .emacs file - I hope this is as good as -Q... And
evaluated using "M-x eval-buffer"

> 4. Placed a new snippet with "# key: <some-key>" from file <file> in
> ~/.emacs.d/snippets/<some-mode> or <location2>/<some-mode>

I didn't understand this part... Sorry - I used the already defined
snippets that I manually copied from the old location to
~/Library/elisp/yasnippet/snippets/

> 5. Opened a <some-mode> buffer

Open a new buffer, and "M-x latex-mode" it.

> 6. Typed the snippet key <some-key>

Tested one of the old snippets which worked fine. Then, trying the new one,
i.e. "f foot[TAB]" => "f foot"...

> 7. Typed TAB

> Anyway

> 1. Use "M-x yas/version" and tell me what version it outputs

This doesn't work for me... In the YASnippet menu I have "About" which
returns "version 0.7.0 beta"

> 2. Whichever way you were using to define new snippets, use it, but
> instead of writing your old snippet, write the one I gave you. Don't
> modify the snippet directives, just make sure they iclude the new "#
> type: command" directive.

I copied and passed your code, so the "# type: command" is there...

> 3. Try using "M-x yas/new-snippet" to write the snippet when you're
> done just type "C-c C-c", follow instructions in the minibuffer. No
> need to use `yas/reload-all` at all.

I never used it before, so I don't know what to do here....

I hope this clears the situation a bit....

Thanks for you efforts!
Dror


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
João Távora  
View profile  
 More options Jul 13 2012, 5:00 pm
From: João Távora <joaotav...@gmail.com>
Date: Fri, 13 Jul 2012 22:00:09 +0100
Local: Fri, Jul 13 2012 5:00 pm
Subject: Re: Moving one char backward when expanding the snippet
Hi again,

Thank you for following my advice, I now have a much better view
(and you're right it was `yas/about` not `yas/version`)

But I still can't explain it. I need this info:

* What files live in your
~/Library/elisp/yasnippet/snippets/latex-mode directory?

* Do other snippets in this directory work correctly? Do they work
  after you modify them?

* What are the first few lines of output of `M-x describe-variable RET
  yas/snippet-dirs`?

* What yas-related messages (the ones that start with "[yas]") popup
  in the "*Messages*" buffer when you (1) use (yas/global-mdoe 1) (2)
  use `yas/reload-all`?

* What is the output of `M-x describe-snippet-tables` in the
  `latex-mode` buffer?

* Also: can you send me the exact file where you stored my snippet in?
  Did you create it with emacs? It might have some kind of CRLF line
  endings or other artifacts that are preventing the snippet from loading.

* Are you doing "M-x yas/reload-all" or evaluating "(yas/reload-all)"?

To use `M-x yas/new-snippet` just try it out. It is used to help you
create and load new snippets. What exactly don't you understand about
it? This feedback is valuable to me.

Thank you,
João

--
João Távora

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dror Atariah  
View profile  
 More options Jul 13 2012, 5:22 pm
From: Dror Atariah <dror...@gmail.com>
Date: Fri, 13 Jul 2012 14:22:47 -0700 (PDT)
Local: Fri, Jul 13 2012 5:22 pm
Subject: Re: Moving one char backward when expanding the snippet

> Thank you for following my advice, I now have a much better view
> (and you're right it was `yas/about` not `yas/version`)

Thank you for your time!

> * What files live in your
> ~/Library/elisp/yasnippet/snippets/latex-mode directory?

My LaTeX snippets:
COPYING                  block.yasnippet          fig.yasnippet          
 lim.yasnippet            sub.yasnippet
README                   case.yasnippet           footnote.yasnippet      
math.yasnippet           subfig.yasnippet
align.yasnippet          cha.yasnippet            formalFUletter.yasnippet
matrix.yasnippet         substar.yasnippet
align_star.yasnippet     chastar.yasnippet        frac.yasnippet          
minipage.yasnippet       sum.yasnippet
article.yasnippet        coord.yasnippet          frame.yasnippet        
 par.yasnippet            table.yasnippet
beamer.yasnippet         coprod.yasnippet         graphics.yasnippet      
para.yasnippet           tikzalone.yasnippet
begin                    desc.yasnippet           href.yasnippet          
prod.yasnippet           url.yasnippet
begin.yasnippet          doc.yasnippet            inlinemath.yasnippet    
sec.yasnippet            use.yasnippet
bib.yasnippet            emp.yasinppet            int.yasnippet          
 secstar.yasnippet        verb.yasnippet
big.yasnippet            enum.yasnippet           it.yasnippet            
set.yasnippet
bigop.yasnippet          eq.yasnippet             item.yasnippet          
ssub.yasnippet
binom.yasnippet          eqs.yasnippet            letter.yasnippet        
ssubstar.yasnippet

* Do other snippets in this directory work correctly? Do they work

>   after you modify them?

Yes X2 :)

* What are the first few lines of output of `M-x describe-variable RET

>   yas/snippet-dirs`?

---
yas/snippet-dirs is a variable defined in `yasnippet.el'.
Its value is ("~/Library/elisp/yasnippet/snippets")
---

* What yas-related messages (the ones that start with "[yas]") popup

>   in the "*Messages*" buffer when you (1) use (yas/global-mdoe 1) (2)
>   use `yas/reload-all`?

Here's the output of the reload:
---
[yas] Loaded ~/Library/elisp/yasnippet/snippets
[yas] Reloaded everything....
---
and here's the message after (yas/glocal-mode 1) evaluation:
---
eval-buffer: Symbol's function definition is void: yas/global-mdoe
---

* What is the output of `M-x describe-snippet-tables` in the

>   `latex-mode` buffer?

I don't have this option...

* Also: can you send me the exact file where you stored my snippet in?

>   Did you create it with emacs? It might have some kind of CRLF line
>   endings or other artifacts that are preventing the snippet from loading.

 You asked it - you got it

* Are you doing "M-x yas/reload-all" or evaluating "(yas/reload-all)"?


The M-x option

To use `M-x yas/new-snippet` just try it out. It is used to help you

> create and load new snippets. What exactly don't you understand about
> it? This feedback is valuable to me.

I'd like to have it one thing at a time :)

Good night!

  footnote.yasnippet
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
João Távora  
View profile  
 More options Jul 13 2012, 6:19 pm
From: João Távora <joaotav...@gmail.com>
Date: Fri, 13 Jul 2012 23:19:49 +0100
Local: Fri, Jul 13 2012 6:19 pm
Subject: Re: Moving one char backward when expanding the snippet

The snippet file you sent me had DOS file endings. Try again with the
one I am sending you.

If that doesn't help, navigate to the snippet file with emacs and
press "C-c C-c".

Also, I meant `yas/describe-snippet-tables` and `yas/global-mode`
**not** `describe-snippet-tables` and `yas/global-mdoe`. It's late and
I'm quite tired.

Hope it works if not we'll have to resume on monday.
João

--
João Távora

  footnote.yasnippet
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dror Atariah  
View profile  
 More options Jul 14 2012, 2:09 pm
From: Dror Atariah <dror...@gmail.com>
Date: Sat, 14 Jul 2012 11:09:59 -0700 (PDT)
Local: Sat, Jul 14 2012 2:09 pm
Subject: Re: Moving one char backward when expanding the snippet

Dear João,

The snippet file you sent me had DOS file endings. Try again with the

> one I am sending you.

Solved the problem!!!! :) Can you explain what went wrong? How did you
troubleshoot it?

If that doesn't help, navigate to the snippet file with emacs and

> press "C-c C-c".

Didn't try this one

Also, I meant `yas/describe-snippet-tables` and `yas/global-mode`

> **not** `describe-snippet-tables` and `yas/global-mdoe`. It's late and
> I'm quite tired.

 I couldn't find "yas/describe-snippet-tables", only "yas/describe-tables".
But any way, as I wrote it works!!!

Thank you so much and have a nice Sunday
Dror


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
João Távora  
View profile  
 More options Jul 14 2012, 2:27 pm
From: João Távora <joaotav...@gmail.com>
Date: Sat, 14 Jul 2012 19:27:02 +0100
Local: Sat, Jul 14 2012 2:27 pm
Subject: Re: Moving one char backward when expanding the snippet
Great!

I also thought DOS file endings were supported, I've had some trouble
with it in the past, will investigate again, though...

João

--
João Távora

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »