Comments (7)
from yasnippet.
from yasnippet.
That branch looks quite aged, hmmm 🤔. I would be surprised if I were the only one asking about multiline-capability. Self-contained snippets (for easy sharing, which is an important thing from my point of view) otherwise tend to have a unnecessarily poor readability. At least if they do some (non-trivial?) work for the user.
from yasnippet.
from yasnippet.
Embedded where? Inside the snippet (i.e. in a
${...}
) or in the header?
Inside the snippet (in a${…}
).
It should be fairly easy to allow headers to span multiple lines. I'm not completely sure what format we could/should use. One natural option would be to do like RFC822, i.e. consider that a subsequent line that's more indented than the header to be part of the same header, so you could write: # name: my-snip # expand-env: ((a 1) (b 2) # (c 3) (d 4) (e 5)) # group: my-group # -- ... but that would break for those who like to align their colons, since something like: # name: my-snip # expand-env: ((a 1) (b 2) # (c 3) (d 4) (e 5)) # group: my-group # -- ... would treat the
group:
as being part of theexpand-env
header.
Three ideas:
- We anyway start with the snippet only after a line containing
# --
, when we have a large one. That means, we can do line-breaks before and don't need to start the next line with a#
in which case (but only before# --
) lines starting without#
are treated as belonging to the same header as the last one. - Lines starting with
#^
(or any other suitable additional symbol) belong to the header before. This looks at least to me, simple. (Inspiration from Rust, where you add a!
to the comment-prefix to indicate that it belongs to the super-elemenet instead of the subsequent element.) - If the line is further indented than the one above and starts with
$#[[:space:]]+
followed by a known header, then it belongs to the element before. This does not require additional syntax but perhaps may be a bit more complicated to implement.
from yasnippet.
from yasnippet.
The subsequent snippet lets you create an org-mode code-block and offers proposals for all modes that registered in a suitable list in emacs. Btw: org-mode should work and set the correct editing mode for all proposals by yasnippet.
# -*- mode: snippet -*-
# name: code-block
# key: #src
# --
#+CAPTION: ${1:Caption}
#+NAME: ${2:anchor}
#+BEGIN_SRC ${3:sh$(yas-choose-value (let* ((empty-choice (list "")) (source-ids-from-org-mode (seq-map 'symbol-name (seq-map 'car (progn (require 'ox-man) org-man-source-highlight-langs)))) (source-ids-from-alists (seq-filter (lambda (elt) (not (eq 'cons (type-of elt)))) (seq-map (lambda (sym) (replace-regexp-in-string "\\\\(-ts\\\\)?-mode" "" (symbol-name sym))) (seq-filter (lambda (elt) (not (eq 'cons (type-of elt)))) (seq-map 'cdr (append auto-mode-alist interpreter-mode-alist magic-mode-alist))))))) (cl-sort (delete-dups (append empty-choice source-ids-from-org-mode source-ids-from-alists)) 'string-lessp)))}
`yas-selected-text`$0
#+END_SRC
Actually my snippet does more, for other options after BEGIN_SRC
, but this is by far the largest thing among them.
from yasnippet.
Related Issues (20)
- csharp-mode bindings not working (sometimes) HOT 1
- please tag new release for Emacs 29 compat (affects MELPA stable and others) HOT 7
- Tests failing under Emacs 29+ HOT 13
- unwanted prompt when pressing TAB HOT 1
- self-defined function `expand-from-key-p`(which check current expanding come from key or binding) not work anymore after update to newest master. HOT 3
- update latex snippets for use with text selection
- Documentation webage 404s HOT 1
- yas--all-parents can fail to find all parents if called before snippet directory is loaded HOT 5
- Some functions don't work in yasnippet HOT 3
- Template variables do not work in template lines starting with # HOT 3
- delete-numberless-inner-snippet-issue-562 test failure (non-deterministic) HOT 6
- Error in condition evaluation: Symbol’s function definition is void: js2-node-type HOT 3
- elpy-snippet-init-assignments - "Symbol’s value as variable is void: start-point" HOT 1
- Suggestion: not preceded by space HOT 4
- special character
- elisp evaluation move cursor on new line
- elisp evaluation move cursor on new line in snippet body
- Suggestion for a repeat snippet feature. HOT 8
- Case sensitive major modes? HOT 1
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 yasnippet.