mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
Compare commits
No commits in common. "master" and "0.8.0" have entirely different histories.
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,7 +1,6 @@
|
||||
authors.txt
|
||||
doc/gh-pages
|
||||
doc/*.html
|
||||
doc/html-revision
|
||||
pkg/
|
||||
extras/imported/**
|
||||
!extras/imported/*/.yas-setup.el
|
||||
@ -9,7 +8,3 @@ extras/imported/**
|
||||
*.elc
|
||||
ert-x.*
|
||||
ert.*
|
||||
|
||||
# ELPA-generated files
|
||||
/yasnippet-autoloads.el
|
||||
/yasnippet-pkg.el
|
||||
|
9
.gitmodules
vendored
9
.gitmodules
vendored
@ -0,0 +1,9 @@
|
||||
[submodule "extras/bundles/ruby-tmbundle"]
|
||||
path = extras/bundles/ruby-tmbundle
|
||||
url = http://github.com/drnic/ruby-tmbundle.git
|
||||
[submodule "extras/bundles/html-tmbundle"]
|
||||
path = extras/bundles/html-tmbundle
|
||||
url = http://github.com/drnic/html-tmbundle.git
|
||||
[submodule "extras/bundles/rails-tmbundle"]
|
||||
path = extras/bundles/rails-tmbundle
|
||||
url = http://github.com/drnic/ruby-on-rails-tmbundle.git
|
49
.travis.yml
49
.travis.yml
@ -1,49 +0,0 @@
|
||||
language: generic
|
||||
os: linux
|
||||
dist: xenial
|
||||
|
||||
git:
|
||||
submodules: false
|
||||
|
||||
env:
|
||||
global:
|
||||
- Wlexical=t
|
||||
- Werror=t
|
||||
- tests_Werror=t # For yasnippet-tests.el
|
||||
jobs:
|
||||
- EMACS_VERSION=23.4
|
||||
# 24.3 gives a bunch of 'value returned from (car value-N) is
|
||||
# unused' warnings.
|
||||
- EMACS_VERSION=24.3 tests_Werror=nil
|
||||
- EMACS_VERSION=24.5
|
||||
- EMACS_VERSION=25.3
|
||||
- EMACS_VERSION=26.3
|
||||
- EMACS_VERSION=27-prerelease
|
||||
|
||||
|
||||
install:
|
||||
- curl -LO https://github.com/npostavs/emacs-travis/releases/download/bins/emacs-bin-${EMACS_VERSION}.tar.gz
|
||||
- tar -xaf emacs-bin-${EMACS_VERSION}.tar.gz -C /
|
||||
# Configure $PATH: Emacs installed to /tmp/emacs
|
||||
- export PATH=/tmp/emacs/bin:${PATH}
|
||||
- if ! emacs -Q --batch --eval "(require 'cl-lib)" ; then
|
||||
curl -Lo cl-lib.el http://elpa.gnu.org/packages/cl-lib-0.6.1.el ;
|
||||
export warnings="'(not cl-functions)" ;
|
||||
fi
|
||||
- if ! emacs -Q --batch --eval "(require 'ert)" ; then
|
||||
curl -LO https://raw.githubusercontent.com/ohler/ert/c619b56c5bc6a866e33787489545b87d79973205/lisp/emacs-lisp/ert.el &&
|
||||
curl -LO https://raw.githubusercontent.com/ohler/ert/c619b56c5bc6a866e33787489545b87d79973205/lisp/emacs-lisp/ert-x.el ;
|
||||
fi
|
||||
- emacs --version
|
||||
|
||||
script:
|
||||
- rake yasnippet.elc
|
||||
- rake yasnippet-debug.elc
|
||||
- rake yasnippet-tests.elc Werror=$tests_Werror
|
||||
- rake tests
|
||||
|
||||
notifications:
|
||||
email:
|
||||
# Default is change, but that includes a new branch's 1st success.
|
||||
on_success: never
|
||||
on_failure: always # The default.
|
@ -1,37 +0,0 @@
|
||||
# Submitting Bug Reports or Patches
|
||||
|
||||
As a GNU ELPA package, bugs or patches may be submitted to the main
|
||||
Emacs bug list, bug-gnu-emacs@gnu.org. Alternatively, you may use the
|
||||
[Github issue tracker][issues].
|
||||
|
||||
Please read [Important note regarding bug reporting][bugnote].
|
||||
|
||||
# Contributing to Yasnippet
|
||||
|
||||
## Copyright Assignment
|
||||
|
||||
Yasnippet is part of GNU ELPA, so it falls under the same copyright
|
||||
assignment policy as the rest of Emacs (see "Copyright Assignment" in
|
||||
https://www.gnu.org/software/emacs/CONTRIBUTE). A copyright assignment
|
||||
for Emacs also covers Yasnippet.
|
||||
|
||||
## Commit message format
|
||||
|
||||
The commit message format roughly follows Emacs conventions. There is
|
||||
no separate Changelog file.
|
||||
|
||||
Capitalize the first sentence, no period at the end
|
||||
|
||||
Please make sure the summary line can be understood without having
|
||||
to lookup bug numbers. It may be followed by a paragraph with a
|
||||
longer explanation. The changelog style entry goes at the end of
|
||||
the message.
|
||||
* foo.el (a-function): Terse summary of per-function changes. Use
|
||||
double spacing between sentences (set `sentence-end-double-space'
|
||||
to t).
|
||||
|
||||
For trivial changes, a message consisting of just the changelog entry
|
||||
(e.g., `* foo.el (a-function): Fix docstring typo.`) is fine.
|
||||
|
||||
[bugnote]: https://github.com/joaotavora/yasnippet#important-note-regarding-bug-reporting
|
||||
[issues]: https://github.com/joaotavora/yasnippet/issues
|
46
Makefile
46
Makefile
@ -1,46 +0,0 @@
|
||||
### Makefile for Yasnippet (stolen from Eglot)
|
||||
# Variables
|
||||
#
|
||||
EMACS?=emacs
|
||||
SELECTOR?=t
|
||||
ERROR_ON_WARN=nil
|
||||
|
||||
LOAD_PATH=-L .
|
||||
|
||||
ELFILES := yasnippet.el yasnippet-tests.el
|
||||
ELCFILES := $(ELFILES:.el=.elc)
|
||||
|
||||
BYTECOMP_ERROR_ON_WARN := \
|
||||
--eval '(setq byte-compile-error-on-warn $(ERROR_ON_WARN))'
|
||||
|
||||
all: compile
|
||||
|
||||
%.elc: %.el
|
||||
$(EMACS) -Q $(BYTECOMP_ERROR_ON_WARN) $(LOAD_PATH) \
|
||||
--batch -f batch-byte-compile $<
|
||||
|
||||
compile: $(ELCFILES)
|
||||
|
||||
# Automated tests
|
||||
#
|
||||
yasnippet-check: compile
|
||||
$(EMACS) -Q --batch \
|
||||
$(LOAD_PATH) \
|
||||
-l yasnippet \
|
||||
-l yasnippet-tests \
|
||||
--eval '(setq ert-batch-backtrace-right-margin 200)' \
|
||||
--eval '(ert-run-tests-batch-and-exit (quote $(SELECTOR)))'
|
||||
|
||||
interactive: compile
|
||||
$(EMACS) -Q \
|
||||
$(LOAD_PATH) \
|
||||
-l yasnippet \
|
||||
-l yasnippet-tests \
|
||||
|
||||
check: yasnippet-check
|
||||
|
||||
# Cleanup
|
||||
#
|
||||
clean:
|
||||
find . -iname '*.elc' -exec rm {} \;
|
||||
.PHONY: all compile clean check
|
574
NEWS
574
NEWS
@ -1,574 +0,0 @@
|
||||
Yasnippet NEWS -- history of user-visible changes.
|
||||
|
||||
Copyright (C) 2017-2025 Free Software Foundation, Inc.
|
||||
See the end of the file for license conditions.
|
||||
|
||||
Changes since 0.14.0:
|
||||
|
||||
- Silence warning about missing lexical-binding cookie.
|
||||
- Bug fixes and code cleanups.
|
||||
- Accept ${N} as another syntax for $N (issue #1012).
|
||||
- Understand the new AUCTeX modes hierarchy (issue #1193).
|
||||
- Try and use `major-mode-remap-alist` to find the right snippets for
|
||||
Tree Sitter modes (issue #1169).
|
||||
|
||||
* 0.14.0 (Dec 22, 2019)
|
||||
|
||||
** Changes
|
||||
|
||||
*** New 'yas-auto-next' macro, automatically moves to next field.
|
||||
See Github #937.
|
||||
|
||||
*** Yasnippet now officially requires Emacs 23 or greater.
|
||||
See Github #940.
|
||||
|
||||
*** Snippets for 'fundamental-mode' are available in all modes.
|
||||
See Github #949, and #936.
|
||||
|
||||
*** New function for snippets, 'yas-completing-read'.
|
||||
See Github #934.
|
||||
|
||||
*** New function 'yas-maybe-expand-abbrev-key-filter'.
|
||||
This can be used for making conditional keybindings for snippets.
|
||||
Promoted from 'yas--maybe-expand-key-filter'. See Github #943.
|
||||
|
||||
*** DEL can now be used to clear fields, similar <delete>.
|
||||
It is bound to the new conditional command 'yas-maybe-clear-field', which may
|
||||
be bound to other keys as well. See Github #960 and #957.
|
||||
|
||||
*** Snippet field movement commands may now trigger eldoc.
|
||||
See Github #952.
|
||||
|
||||
*** New variable 'yas-keymap-disable-hook'.
|
||||
Can be used (e.g., for company-mode) to temporarily disable
|
||||
'yas-keymap' bindings, or any binding made by the new function
|
||||
'yas-filtered-definition'. See Github #987.
|
||||
|
||||
*** New variable 'yas-inhibit-overlay-modification-protection'.
|
||||
This allows a snippet to remain active, even if some commands make
|
||||
modifications outside the expected area (i.e., the active snippet
|
||||
field).
|
||||
|
||||
*** 'yas-minor-mode' is no longer enabled in temp buffers.
|
||||
That is, buffers whose name starts with a space. This setting may be
|
||||
undone by removing 'yas-temp-buffer-p' from
|
||||
'yas-dont-activate-functions'. See Github #985.
|
||||
|
||||
*** Accept unescaped '{', for LSP compatibility.
|
||||
See Github #979.
|
||||
|
||||
** Fixed bugs
|
||||
|
||||
*** 'yas-not-string-or-comment-condition' no longer relies on 'this-command'.
|
||||
This lets it work correctly with conditional key-bindings. See Github
|
||||
#973, #991.
|
||||
|
||||
*** Fix snippet expansion in org src buffers.
|
||||
Note that this still doesn't work in text-mode blocks.
|
||||
See Github #976, #989.
|
||||
|
||||
*** Fix snippet insertion for keyless snippets.
|
||||
See Github #1014.
|
||||
|
||||
*** Fix errors with company-mode completion within snippet fields.
|
||||
See Github #995.
|
||||
|
||||
*** Fix errors with cc-mode.
|
||||
See Github #962.
|
||||
|
||||
*** Fix problems with lsp-mode.
|
||||
**** Improve performance in overlay heavy buffers (Github #926).
|
||||
**** Fix double call of 'before/after-change-functions' (Github #966).
|
||||
|
||||
*** Fix errors with nested snippet expansion.
|
||||
See Github #961, #1002.
|
||||
|
||||
*** Stop yas-field-highlight-face inheriting from bogus 'quote' face.
|
||||
|
||||
|
||||
* 0.13.0 (May 13, 2018)
|
||||
|
||||
** Changes
|
||||
|
||||
*** Snippets for Yasnippet must now be installed separately. The
|
||||
submodule linking to yasnippet-snippets was removed, as were the
|
||||
"classic" snippets that came with the GNU ELPA package. The latter
|
||||
can now be installed via the 'yasnippet-classic-snippets' package from
|
||||
GNU ELPA.
|
||||
See Github #848, #858, #834, #775.
|
||||
|
||||
*** 'snippet-mode' no longer derives from 'text-mode'.
|
||||
It will derive from 'prog-mode' where available (Emacs 24.1 and newer)
|
||||
or 'fundamental-mode' otherwise. See Github #826.
|
||||
|
||||
*** The default value of 'yas-key-syntaxes' is changed
|
||||
Longer snippet abbrev keys are now preferred over shorter ones.
|
||||
See Github #805.
|
||||
|
||||
*** New snippets are now created for the current major mode by default
|
||||
Previously, extra activated modes could be guessed first.
|
||||
See Github #875.
|
||||
|
||||
*** Yasnippet supports 'unload-feature' via 'yasnippet-unload-function'
|
||||
See Github #753, #891.
|
||||
|
||||
*** New command 'yas-skip-and-clear-field' conditionally bound to 'C-d'
|
||||
replaces obsoleted 'yas-skip-and-clear-or-delete-char'. The new
|
||||
function may be bound to any key via the conditional binding value
|
||||
'yas-maybe-skip-and-clear-field', instead of hardcoding the
|
||||
'delete-char' fallback action. See Github #408, #892.
|
||||
|
||||
*** 'yas-lookup-snippet' now returns a struct
|
||||
This allows 'yas-expand-snippet' to take looked up snippet's
|
||||
environment into account. 'yas-expand-snippet' handles both
|
||||
structured snippets, and plain text snippet bodies.
|
||||
See Github #897.
|
||||
|
||||
** Fixed bugs
|
||||
|
||||
*** Avoid crashing due to Emacs Bug#30931
|
||||
This prevents yasnippet's routines from triggering the bug, although
|
||||
it is still possible to trigger it independently.
|
||||
|
||||
*** Don't enable undo when it's disabled
|
||||
|
||||
*** yas-also-auto-indent-first-line is once again respected
|
||||
Yasnippet was behaving as if it was always t for single line snippets.
|
||||
See Github #912.
|
||||
|
||||
*** Fixed handling of fixed indent with fields at beginning of line
|
||||
See Github #906, #908.
|
||||
|
||||
*** Fixed incorrect snippets leaving "bad memory"
|
||||
and possibly corrupting future expansions.
|
||||
See Github #800.
|
||||
|
||||
*** 'global-whitespace-mode' now functions in new snippet buffers.
|
||||
To fix this, the buffer name for new snippet buffers is now '+new
|
||||
snippet+' instead of '*new snippet*'. See Github #842.
|
||||
|
||||
*** Nest snippet expansion may clear default field text
|
||||
See Github #844.
|
||||
|
||||
*** Fixed undo list corruption snippet expand+indent.
|
||||
See Github #869.
|
||||
|
||||
*** The '# --' marker in snippets now allows trailing whitespace.
|
||||
See Github #862.
|
||||
|
||||
*** Fixed handling of nested simple $n fields
|
||||
See Github #824, #894.
|
||||
|
||||
|
||||
* 0.12.2 (Aug 28, 2017)
|
||||
|
||||
** The new option 'yas-also-auto-indent-empty-lines' allows restoring
|
||||
the old indent behavior. See Github #850, #710, #685, #679.
|
||||
|
||||
** Keybinding triggered snippets once again deactivate the mark.
|
||||
See Github #840.
|
||||
|
||||
|
||||
* 0.12.1 (Jul 23, 2017)
|
||||
|
||||
This is a quick bugfix release.
|
||||
|
||||
** Compilation errors in yasnippet-tests.el and yasnippet-debug.el are fixed.
|
||||
|
||||
** A snippet-local setting of 'yas-indent-line' is now respected
|
||||
during indentation triggered by auto-fill as well. See Github #838.
|
||||
|
||||
|
||||
* 0.12.0 (Jul 17, 2017)
|
||||
|
||||
** Changes and New Features
|
||||
|
||||
*** Snippets can now expand in strings & comments by default again.
|
||||
'yas-buffer-local-condition' is now a defcustom See Github #774.
|
||||
|
||||
*** 'yas-after-exit-snippet-hook' can now be bound in 'expand-env' of
|
||||
snippets. See Github #28, #702, #779, #786.
|
||||
|
||||
*** Snippets under directories in 'yas-snippet-dirs' are now in
|
||||
snippet-mode automatically.
|
||||
|
||||
*** Snippets can now be expanded in org source blocks, if
|
||||
'org-src-tab-acts-natively' and 'org-src-fontify-natively' are set.
|
||||
See Github #761.
|
||||
|
||||
*** 'yas-fallback-behavior' is now obsolete, 'yas-expand' is now bound
|
||||
conditionally with an extended menu item, 'yas-maybe-expand'.
|
||||
Therefore users wanting to bind 'yas-expand' to a different key, SPC
|
||||
for example, should do
|
||||
|
||||
(define-key yas-minor-mode-map (kbd "SPC") yas-maybe-expand)
|
||||
|
||||
See Github #760, #808.
|
||||
|
||||
*** The documentation build output is now reproducible. The timestamp
|
||||
now depends on the commit date, or the environment variable
|
||||
SOURCE_DATE_EPOCH is that is set.
|
||||
|
||||
*** 'yas-indent-line' and 'expand-env' are now respected during mirror
|
||||
updates. See Github #743.
|
||||
|
||||
*** New function 'yas-active-snippets'. Renamed from
|
||||
'yas--snippets-at-point', which remains as an obsolete alias. See
|
||||
Github #727.
|
||||
|
||||
*** New custom option 'yas-overlay-priority'. This is can be used to
|
||||
give the snippet navigation keymaps higher priority than keymaps from
|
||||
overlays created by other packages, like 'auto-complete'. See Github
|
||||
#828.
|
||||
|
||||
** Fixed bugs
|
||||
|
||||
*** Snippets having ${0:soon-to-be-deleted} with no other fields now
|
||||
correctly put the field 0 text in the active region after exiting.
|
||||
See Github #653.
|
||||
|
||||
*** Fix undo of snippet insertion which also triggers indentation.
|
||||
See Github #821.
|
||||
|
||||
*** Fixed a bug causing whitespace loss between mirrors.
|
||||
|
||||
*** Fixed several bugs causing problems when combining Yasnippet with
|
||||
other modes and packages, like 'auto-fill-mode', 'c++-mode',
|
||||
'rust-mode', and 'lentic'.
|
||||
|
||||
**** Fix another bug with auto-fill-mode.
|
||||
See Github #784, #794.
|
||||
|
||||
**** Fix a bug in parsing of snippet fields for modes that use the
|
||||
'syntax-table' text property, 'c++-mode' is one example of this. See
|
||||
Github #815.
|
||||
|
||||
**** 'syntax-propertize-function' is now restored before indenting the
|
||||
snippet. This improves compatibility with modes which rely on it for
|
||||
indentation, like 'rust-mode'. See Github #782, #818.
|
||||
|
||||
**** Avoid trying to delete a snippet which is already deleted. This
|
||||
prevents an error when using 'rust-mode's 'rust-format-buffer'
|
||||
command.
|
||||
|
||||
**** Ensure inhibit-modification-hooks is nil while modifying buffer.
|
||||
This fixes problems for packages relying on modification hooks, like
|
||||
'lentic'. See Github #756, #712.
|
||||
|
||||
|
||||
* 0.11.0 (Oct 26, 2016)
|
||||
** Changes and New Features
|
||||
|
||||
*** Modifying buffer in backquoted expressions is deprecated!
|
||||
Backquoted expressions should only return a string that will be
|
||||
inserted. Snippets which modify the buffer as a side-effect will now
|
||||
trigger a warning.
|
||||
|
||||
*** The verbosity levels for messages have been adjusted.
|
||||
While the default verbosity level was increased by 1 (it was only
|
||||
lower before due to a bug), several messages now only print at the
|
||||
level 4, so the overall effect should be less messages by default.
|
||||
|
||||
*** Saving and loading snippets has been streamlined. Saving the
|
||||
snippet to a file will now automatically load it. Additionally, the
|
||||
buffer will be renamed from "*new snippet*" to whatever the snippet is
|
||||
named. See also Github #718, #733, and #734.
|
||||
|
||||
*** `yas-escape-text' no longer signals an error when given nil.
|
||||
|
||||
*** `yas-describe-tables' is split into simpler commands.
|
||||
**** `yas-describe-tables' takes a prefix arg to show non-active tables.
|
||||
**** New command `yas-describe-tables-by-namehash' shows table by namehash.
|
||||
|
||||
*** Use the region contents as the snippet body of new snippets.
|
||||
|
||||
*** The dependency on `cl' is removed.
|
||||
Yasnippet now only requires `cl-lib'.
|
||||
|
||||
** Fixed Bugs
|
||||
|
||||
*** Fix field navigation (tabbing) in the backwards direction.
|
||||
See Github #722
|
||||
|
||||
*** Add support for deprecated yas/ symbols in `yas-define-menu'.
|
||||
It was left out by accident. This support is conditional on
|
||||
`yas-alias-to-yas/prefix-p', just like other obsolete yas/ bindings.
|
||||
|
||||
*** Fix overriding of snippet by a new snippet with same uuid.
|
||||
See Github #714.
|
||||
|
||||
*** Fix handling of snippets with 2 mirros on the same line.
|
||||
See Github #712.
|
||||
|
||||
|
||||
* 0.10.0 (June 11th, 2016)
|
||||
|
||||
** Changes and New Features
|
||||
|
||||
*** Yasnippet now prints far fewer message by default.
|
||||
See Github #682, #683.
|
||||
|
||||
*** `yas-wrap-around-region' can be set to a register.
|
||||
The register's content will be used. This is like the old `cua'
|
||||
option, but can be used with any register and doesn't require enabling
|
||||
cua-mode.
|
||||
|
||||
*** Clearing of snippet fields is now decided by the command's effect.
|
||||
The `delete-selection' property is no longer consulted. See Github #662.
|
||||
|
||||
*** Empty lines in snippet expansion are no longer indented.
|
||||
See Github #679.
|
||||
|
||||
*** All lines from mirror output are now indented.
|
||||
See Github #665.
|
||||
|
||||
*** New variable yas-alias-to-yas/prefix-p
|
||||
See Github #696, #699.
|
||||
|
||||
*** New function yas-next-field-will-exit-p
|
||||
See Github #561.
|
||||
|
||||
*** `snippet-mode' is now autoloaded.
|
||||
|
||||
** Fixed Bugs
|
||||
|
||||
*** Fix incompatibility with Emacs 25 and haskell-mode.
|
||||
This should also help other modes with a non-nil syntax-propertize
|
||||
function. See Github #687.
|
||||
|
||||
*** Text property changes no longer disable snippets.
|
||||
This prevents cc-mode based modes from causing premature exit of
|
||||
snippets. See Github #677.
|
||||
|
||||
*** Fields are now transformed correctly after `yas-next-field'.
|
||||
See Github #381.
|
||||
|
||||
*** The $> construct is now escaped correctly, and documented.
|
||||
See Github #640.
|
||||
|
||||
*** Avoid corruption of snippet content when loading from files.
|
||||
See Github #707 and Emacs bug #23659.
|
||||
|
||||
*** `yas-wrap-around-region' now works for snippets with fields
|
||||
farther down the buffer than $0. See Github #636.
|
||||
|
||||
*** The active region is deleted when using `yas-expand'.
|
||||
This makes it consistent with `yas-insert-snippet'. See Github #523.
|
||||
|
||||
*** Fix mirror+autofill interaction.
|
||||
See Github #643 and http://emacs.stackexchange.com/q/19206/5296.
|
||||
|
||||
*** Snippet insertion no longer adds irrelevant strings to kill ring.
|
||||
See Github #675.
|
||||
|
||||
|
||||
* 0.9.1 (April 3rd, 2016)
|
||||
|
||||
** Changes and New Features
|
||||
|
||||
*** Noam Postavsky is now the official yasnippet maintainer.
|
||||
|
||||
*** `yas-visit-snippet-file' now works for compiled snippets (see Github #597).
|
||||
|
||||
*** New function `yas-lookup-snippet' (see Github #595, #596).
|
||||
|
||||
*** .emacs.d/snippets directory is now created automatically.
|
||||
If that value is present in `yas-snippet-dirs' (see Github #648).
|
||||
|
||||
*** Default value for `yas-snippet-dirs' now uses `user-emacs-directory'
|
||||
instead of hardcoding "~/emacs.d" (see Github #632).
|
||||
|
||||
*** `yas-visit-snippet-file' no longer overrides `yas-prompt-functions',
|
||||
see Github #576.
|
||||
|
||||
*** The defaults for prompting have changed.
|
||||
`yas-x-prompt' is no longer present in the default value of
|
||||
`yas-prompt-functions'.
|
||||
|
||||
The new function `yas-maybe-ido-prompt' (which performs ido prompting
|
||||
if `ido-mode' is enabled) replaces `yas-ido-prompt' (which always
|
||||
performs ido prompting). Previously the behaviour was dependent on
|
||||
the Emacs version being used.
|
||||
|
||||
*** The default value of `yas-buffer-local-condition' now works for `yas-insert-snippet' too.
|
||||
See Github #305.
|
||||
|
||||
*** The default value of `yas-new-snippet-default' no longer inserts `require-final-newline: nil'.
|
||||
It was redundant, since `mode: snippet' already accomplishes the same.
|
||||
`binding: ${4:direct-keybinding}}' is also removed, as it is hardly
|
||||
ever wanted.
|
||||
|
||||
*** Snippet fields are only cleared by commands with `delete-selection' property,
|
||||
See Github #515, #644.
|
||||
|
||||
*** `yas-initialize' (and backward compat alias `yas/initialize') are restored,
|
||||
but marked obsolete, use (yas-global-mode +1) instead. See Github
|
||||
#546, #569.
|
||||
|
||||
*** `yas-key-syntaxes' is much more powerful and accepts functions.
|
||||
Enables use cases when discovering keys based on buffer syntax is not
|
||||
good enough. See issue #497.
|
||||
|
||||
*** Documentation rewritten in org-mode and updated.
|
||||
A tremendous effort by Noam Postavsky. Hopefully easier to maintain
|
||||
and navigate. Available at <http://joaotavora.github.io/yasnippet>.
|
||||
|
||||
*** Snippets are now maintained in their own repo.
|
||||
Snippets live in Andrea Crotti's
|
||||
<https://github.com/andreacrotti/yasnippet-snippets>. See README.md
|
||||
for more details.
|
||||
|
||||
*** Textmate snippet importer moved to separate `yasmate' repo.
|
||||
URL is <https://github.com/joaotavora/yasmate>. See README.md for
|
||||
more details.
|
||||
|
||||
*** `yas-snippet-dirs' now allows symbols as aliases to directories.
|
||||
The added level of indirection should allow more esoteric
|
||||
configurations (see Github #495).
|
||||
|
||||
*** `yas-reload-all' can now jit-load when called interactively.
|
||||
|
||||
*** New `yas-after-reload-hook' run after `yas-reload-all'.
|
||||
See <https://github.com/pezra/rspec-mode/pull/75> for the discussion
|
||||
leading up to this change.
|
||||
|
||||
*** New functions `yas-activate-extra-mode' and `yas-deactivate-extra-mode'.
|
||||
These are preferable to setting `yas-extra-modes' directly in the mode
|
||||
hook (see issue #420 for more information).
|
||||
|
||||
*** New variable `yas-new-snippet-default'.
|
||||
The default snippet suggested on `yas-new-snippet' can now be
|
||||
customized.
|
||||
|
||||
** Fixed bugs
|
||||
|
||||
*** `yas-expand' now sets `this-command' when falling back to another command.
|
||||
Previously it was setting `this-original-command', which does not
|
||||
match the documented semantics. See Github #587.
|
||||
|
||||
*** Github #537: Be lenient to extensions operating on snippet fields.
|
||||
|
||||
*** Github #619: Parents of extra modes are now activated too.
|
||||
|
||||
*** Github #549: `yas-verbosity' is now applied to `load' calls too.
|
||||
|
||||
*** Github #607; avoid obscure Emacs bug triggered by overlays in *Messages* buffer.
|
||||
It was triggered by yasnippet+flycheck+highlight-parentheses. See
|
||||
also <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21824>
|
||||
|
||||
*** Github #617; fix x prompt when snippet inserts many lines.
|
||||
|
||||
*** Github #618; avoid breakage if `scan-sexp' modifies match data.
|
||||
Which it does in Emacs 25.
|
||||
|
||||
*** Github #562: Deleting inner numberless snippet caused an error.
|
||||
|
||||
*** Github #418, #536: Fix navigation to zero-length fields at snippet end.
|
||||
|
||||
*** Github #527, #525 and #526: Attempt to prevent "fallback loops"
|
||||
when interactiing with other extensions that use similar fallback
|
||||
mechanisms.
|
||||
|
||||
|
||||
* 0.8.0 (August 2012)
|
||||
|
||||
** Changes and New Features
|
||||
|
||||
*** All YASnippet symbols now prefixed with `yas-'. Keep old `yas/' versions as aliases.
|
||||
|
||||
*** Yasnippet is now Free Software Foundation's copyright.
|
||||
|
||||
*** `yas-dont-activate' can be a list of functions.
|
||||
|
||||
*** Snippets are loaded just-in-time .
|
||||
Thanks to Matthew Fidler for a lot of input with the implementation.
|
||||
|
||||
*** yasnippet-bundle.el is no longer available.
|
||||
Use `yas-compile-directory' instead if you need the speed advantage.
|
||||
|
||||
*** New functions `yas-compile-directory' and `yas-recompile-all'.
|
||||
This feature is still undocumented. Generate a
|
||||
.yas-compiled-snippets.el file in the directory passed where snippets
|
||||
are compiled into emacs-lisp code.
|
||||
|
||||
*** New `yas-verbosity' variable.
|
||||
|
||||
*** Interactively calling `yas-exit-snippet' exits most recently inserted snippet.
|
||||
|
||||
*** Using filenames as snippet triggers is deprecated.
|
||||
|
||||
*** Default value of `yas-show-menu-p' is `abbreviate'.
|
||||
|
||||
*** `yas-visit-snippet' ignores `yas-prompt-functions'.
|
||||
|
||||
*** `yas-buffer-local-condition' restricted to trigger-key expansions by default.
|
||||
|
||||
*** `yas-load-snippet-buffer' (`C-c C-c') in `snippet-mode' has been much improved.
|
||||
|
||||
*** New variable `yas-expand-only-for-last-commands', thanks Erik Postma.
|
||||
|
||||
*** New variable `yas-extra-modes' aliases old `yas/mode-symbol'.
|
||||
|
||||
*** New `yas-describe-tables' command.
|
||||
|
||||
*** New `yas-define-condition-cache' macro.
|
||||
This defines an optimised function for placing in a `# condition:'
|
||||
directive that will run at most once per snippet-expansion attempt.
|
||||
|
||||
*** Mirrors can occur inside fields.
|
||||
|
||||
*** New `# type: command' directive.
|
||||
This feature is still largely undocumented.
|
||||
|
||||
*** A hidden .yas-setup.el is loaded if found in a snippet directory.
|
||||
|
||||
*** `yas-wrap-around-region' can now also be `cua' (undocumented feature).
|
||||
|
||||
*** Make menu groups automatically using new .yas-make-groups file.
|
||||
|
||||
*** Per-snippet keybindings using `# keybinding:' directive.
|
||||
|
||||
*** More friendly `yas-expand-snippet' calling convention.
|
||||
This breaks backward compatibility.
|
||||
|
||||
*** The `# env:' directive is now `# expand-env:'.
|
||||
|
||||
*** Setup multiple parent modes using new .yas-parents file.
|
||||
|
||||
** Fixed bugs
|
||||
|
||||
*** Github #281: jit-load snippets in the correct order.
|
||||
|
||||
*** Github #245: primary field transformations work inside nested fields.
|
||||
|
||||
*** Github #242: stop using the deprecated `assoc' library.
|
||||
|
||||
*** Github #233: show direct snippet keybindings in the menu.
|
||||
|
||||
*** Github #194, Googlecode 192: Compatibility with `fci-mode'.
|
||||
|
||||
*** Github #147, Googlecode 145: Snippets comments were getting inserted.
|
||||
|
||||
*** Github #141, Googlecode 139: searching buffer in embedded elisp works slightly better.
|
||||
Issue is still open for analysis, though
|
||||
|
||||
*** Github #95, Googlecode 193: no more stack overflow in org-mode.
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
|
||||
Local variables:
|
||||
coding: utf-8
|
||||
mode: outline
|
||||
paragraph-separate: "[ ]*$"
|
||||
end:
|
191
README.mdown
191
README.mdown
@ -1,26 +1,29 @@
|
||||
[](https://travis-ci.org/joaotavora/yasnippet)
|
||||
|
||||
# Intro
|
||||
|
||||
**YASnippet** is a template system for Emacs. It allows you to
|
||||
type an abbreviation and automatically expand it into function
|
||||
templates. Bundled language templates include: C, C++, C#, Perl,
|
||||
Python, Ruby, SQL, LaTeX, HTML, CSS and more. The snippet syntax
|
||||
is inspired from [TextMate's][textmate-snippets] syntax, you can
|
||||
even [import](#import) most TextMate templates to
|
||||
YASnippet. Watch [a demo on YouTube][youtube-demo].
|
||||
**YASnippet** is a template system for Emacs. It allows you to type an
|
||||
abbreviation and automatically expand it into function
|
||||
templates. Bundled language templates includes: C, C++, C#, Perl,
|
||||
Python, Ruby,
|
||||
|
||||
SQL, LaTeX, HTML, CSS and more. The snippet syntax is inspired from
|
||||
[TextMate's][textmate-snippets] syntax, you can even
|
||||
[import][import-docs] most TextMate templates to YASnippet. Watch
|
||||
[a demo on YouTube][youtube-demo] or download a
|
||||
[higher resolution version][high-res-demo]
|
||||
|
||||
[textmate-snippets]: http://manual.macromates.com/en/snippets
|
||||
[import-docs]: http://yasnippet.googlecode.com/svn/trunk/doc/snippet-development.html#importing-textmate-snippets
|
||||
[youtube-demo]: http://www.youtube.com/watch?v=ZCGmZK4V7Sg
|
||||
[high-res-demo]: http://yasnippet.googlecode.com/files/yas_demo.avi
|
||||
|
||||
# Installation
|
||||
|
||||
## Manual install from Git
|
||||
## Install the most recent version
|
||||
|
||||
Clone this repository somewhere
|
||||
|
||||
$ cd ~/.emacs.d/plugins
|
||||
$ git clone --recursive https://github.com/joaotavora/yasnippet
|
||||
$ git clone https://github.com/capitaomorte/yasnippet
|
||||
|
||||
Add the following in your `.emacs` file:
|
||||
|
||||
@ -33,136 +36,108 @@ Add your own snippets to `~/.emacs.d/snippets` by placing files there or invokin
|
||||
|
||||
## Install with `package-install`
|
||||
|
||||
In a recent emacs `M-x list-packages` is the recommended way to list
|
||||
and install packages.
|
||||
It's available from [GNU ELPA][gnuelpa].
|
||||
If you need a very recent snapshot, you can get it from
|
||||
[GNU-devel ELPA][gnudevel] as well as [MELPA][melpa]
|
||||
(see http://melpa.org/#installing).
|
||||
In a recent emacs `M-x list-packages` is the recommended way to list and install packages.
|
||||
[MELPA][melpa] keeps a very recent snapshot of YASnippet, see http://melpa.milkbox.net/#installing.
|
||||
|
||||
## Install with el-get
|
||||
|
||||
El-get is another nice way to get the most recent version, too. See
|
||||
https://github.com/dimitri/el-get for instructions.
|
||||
El-get is a nice way to get the most recent version, too. See
|
||||
https://github.com/dimitri/el-get for instructions. Be sure to install the
|
||||
"master" branch since the 3.x series still use the old googlecode code, base.
|
||||
Consider using this "local" recipe.
|
||||
|
||||
(push '(:name yasnippet
|
||||
:website "https://github.com/capitaomorte/yasnippet.git"
|
||||
:description "YASnippet is a template system for Emacs."
|
||||
:type github
|
||||
:pkgname "capitaomorte/yasnippet"
|
||||
:features "yasnippet"
|
||||
:compile "yasnippet.el")
|
||||
el-get-sources)
|
||||
|
||||
## Use `yas-minor-mode` on a per-buffer basis
|
||||
|
||||
To use YASnippet as a non-global minor mode, don't call
|
||||
`yas-global-mode`; instead call `yas-reload-all` to load the snippet
|
||||
tables and then call `yas-minor-mode` from the hooks of major-modes
|
||||
where you want YASnippet enabled.
|
||||
To use YASnippet as a non-global minor mode, replace `(yas-global-mode 1)` with
|
||||
`(yas-reload-all)` to load the snippet tables. Then add a call to
|
||||
`(yas-minor-mode)` to the major-modes where you to enable YASnippet.
|
||||
|
||||
(yas-reload-all)
|
||||
(add-hook 'prog-mode-hook #'yas-minor-mode)
|
||||
(add-hook 'prog-mode-hook
|
||||
'(lambda ()
|
||||
(yas-minor-mode)))
|
||||
|
||||
# Where are the snippets?
|
||||
# (NOT) Contributing snippets
|
||||
|
||||
<a name="import"></a>
|
||||
Please **do not** open pull requests or ask me to add snippets to
|
||||
YASnippet.
|
||||
|
||||
YASnippet no longer bundles snippets directly, but it's very easy to
|
||||
get some!
|
||||
The bundled collection under `/snippets` is considered frozen: **I
|
||||
will not add more snippets to it**.
|
||||
|
||||
1. [yasnippet-snippets] - a snippet collection package maintained by
|
||||
[AndreaCrotti](https://github.com/AndreaCrotti).
|
||||
|
||||
It can be installed with `M-x package-install RET
|
||||
yasnippet-snippets` if you have added MELPA to your package
|
||||
sources.
|
||||
|
||||
2. [yasmate] a tool which is dedicated to converting textmate bundles
|
||||
into yasnippet snippets.
|
||||
|
||||
To use these snippets you have to run the tool first, so
|
||||
[see its doc][yasmate]), and then point the `yas-snippet-dirs`
|
||||
variable to the `.../yasmate/snippets` subdir.
|
||||
3. [textmate-to-yas.el]
|
||||
|
||||
This is another textmate bundle converting tool using Elisp
|
||||
instead of Ruby.
|
||||
|
||||
Naturally, you can point `yas-snippet-dirs` to good snippet collections out
|
||||
You can point `yas-snippet-dirs` to good snippet collections out
|
||||
there. If you have created snippets for a mode, or multiple modes,
|
||||
consider creating a repository to host them, then tell users that it
|
||||
should be added like this to `yas-snippet-dirs`:
|
||||
|
||||
(setq yas-snippet-dirs
|
||||
'("~/.emacs.d/snippets" ;; personal snippets
|
||||
"/path/to/some/collection/" ;; foo-mode and bar-mode snippet collection
|
||||
"/path/to/yasnippet/yasmate/snippets" ;; the yasmate collection
|
||||
'("~/.emacs.d/snippets" ;; personal snippets
|
||||
"/path/to/some/collection/" ;; just some foo-mode snippets
|
||||
"/path/to/some/othercollection/" ;; some more foo-mode and a complete baz-mode
|
||||
"/path/to/yasnippet/snippets" ;; the default collection
|
||||
))
|
||||
|
||||
(yas-global-mode 1) ;; or M-x yas-reload-all if you've started YASnippet already.
|
||||
|
||||
# Manual, issues etc
|
||||
# Importing TextMate snippets
|
||||
|
||||
There's comprehensive [documentation][docs] on using and customising
|
||||
YASnippet.
|
||||
There is a tool `extras/textmate-import.rb` than can import many
|
||||
actual TextMate snippets. These can be quite complex so the
|
||||
`extras/imported/*-mode/.yas-setup.el` files help it with the more
|
||||
difficult importation.
|
||||
|
||||
There's a [list of support issues][support-issues], with solutions to
|
||||
common problems and practical snippet examples.
|
||||
I'm focusing on developing `textmate-import.rb` tool and some
|
||||
`yas-setup.el` files. In the future `/snippets` snippets will be
|
||||
deprecated and might be replaced with `extras/imported`.
|
||||
|
||||
The [Github issue tracker][issues] is where most YASnippet-related
|
||||
discussion happens. Nevertheless, since YASnippet is a part of Emacs,
|
||||
you may alternatively report bugs to Emacs via `M-x report-emacs-bug` or
|
||||
sending an email to `bug-gnu-emacs@gnu.org`, putting "yasnippet"
|
||||
somewhere in the subject.
|
||||
## Example importation of rails snippets
|
||||
|
||||
## Important note regarding bug reporting
|
||||
To start using [drnic's](https://github.com/drnic) snippets for rails
|
||||
development, follow this example. It will convert `ruby`, `rails` and
|
||||
`html` bundles from github repositories. The importation will be
|
||||
guided by the `.yas-setup.el` files.
|
||||
|
||||
Your bug reports are very valuable.
|
||||
After cloning this repository to `~/.emacs.d/plugins/yasnippet`
|
||||
|
||||
The most important thing when reporting bugs is making sure that we have
|
||||
a way to reproduce the problem exactly like it happened to you.
|
||||
cd ~/.emacs.d/plugins/yasnippet
|
||||
git submodule init
|
||||
git submodule update
|
||||
gem install plist trollop
|
||||
rake convert_bundles # will convert ruby, rails and html bundles
|
||||
|
||||
To do this, we need to rule out interference from external factors
|
||||
like other Emacs extensions or your own customisations.
|
||||
Then, in your `.emacs` file
|
||||
|
||||
Here's an example report that "sandboxes" an Emacs session just for
|
||||
reproducing a bug.
|
||||
(add-to-list 'load-path
|
||||
"~/.emacs.d/plugins/yasnippet")
|
||||
(require 'yasnippet)
|
||||
(setq yas-snippet-dirs '("~/.emacs.d/snippets" "~/.emacs.d/plugins/yasnippet/extras/imported"))
|
||||
(yas-global-mode 1)
|
||||
|
||||
```
|
||||
$ emacs --version
|
||||
Emacs 24.3
|
||||
$ cd /tmp/
|
||||
$ git clone https://github.com/joaotavora/yasnippet.git yasnippet-bug
|
||||
$ cd yasnippet-bug
|
||||
$ git log -1 --oneline
|
||||
6053db0 Closes #527: Unbreak case where yas-fallback-behaviour is a list
|
||||
$ HOME=$PWD emacs -L . # This "sandboxes" your emacs, melpa configuration, etc
|
||||
Open some rails file (model, app, etc) and start using the textmate
|
||||
snippets. Note that in the example above we have abandoned the
|
||||
default snippet collection on `~/.emacs.d/plugins/yasnippet/snippets`
|
||||
|
||||
(require 'yasnippet)
|
||||
(yas-global-mode 1)
|
||||
# Documentation, issues, etc
|
||||
|
||||
When I open a foo-mode file I don't see foo-mode under the "YASnippet" menu!
|
||||
OR
|
||||
When loading yasnippet I see "Error: failed to frobnicate"!
|
||||
```
|
||||
Please refer to the comprehensive (albeit slightly outdated)
|
||||
[documentation][docs] for full customization
|
||||
and support. If you find a bug, please report it on
|
||||
[the GitHub issue tracker][issues]. (please **do not** submit new issues to the old
|
||||
[googlecode tracker][googlecode tracker])
|
||||
|
||||
Using `emacs -Q` or temporarily moving your `.emacs` init file to the side
|
||||
is another way to achieve good reproducibility.
|
||||
If you run into problems using YASnippet, or have snippets to contribute, post
|
||||
to the [YASnippet google group][forum]. Thank you very much for using YASnippet!
|
||||
|
||||
Here's a
|
||||
[another example](https://github.com/joaotavora/yasnippet/issues/318)
|
||||
of a bug report. It has everything needed for a successful analysis
|
||||
and speedy resolution.
|
||||
|
||||
Also, don't forget to state the Emacs version (use `M-x emacs-version`) and
|
||||
the yasnippet version you are using (if using the latest from github,
|
||||
do `git log -1` in the dir).
|
||||
|
||||
Any more info is welcome, but don't just paste a backtrace or an error
|
||||
message string you got, unless we ask for it.
|
||||
|
||||
Finally, thank you very much for using YASnippet!
|
||||
|
||||
[docs]: http://joaotavora.github.io/yasnippet/
|
||||
[issues]: https://github.com/joaotavora/yasnippet/issues
|
||||
[support-issues]: https://github.com/joaotavora/yasnippet/issues?q=label%3Asupport
|
||||
[docs]: http://capitaomorte.github.com/yasnippet/
|
||||
[issues]: https://github.com/capitaomorte/yasnippet/issues
|
||||
[googlecode tracker]: http://code.google.com/p/yasnippet/issues/list
|
||||
[forum]: http://groups.google.com/group/smart-snippet
|
||||
[melpa]: http://melpa.milkbox.net/
|
||||
[gnuelpa]: http://elpa.gnu.org/packages/yasnippet.html
|
||||
[gnudevel]: http://elpa.gnu.org/devel/yasnippet.html
|
||||
[yasmate]: http://github.com/joaotavora/yasmate
|
||||
[textmate-to-yas.el]: https://github.com/mattfidler/textmate-to-yas.el
|
||||
[yasnippet-snippets]: http://github.com/AndreaCrotti/yasnippet-snippets
|
||||
|
102
README.org
Normal file
102
README.org
Normal file
@ -0,0 +1,102 @@
|
||||
# -*- mode: org; fill-column: 80 -*-
|
||||
#+TITLE: Yet another snippet extension
|
||||
#+OPTIONS: toc:1
|
||||
#+STARTUP: showall
|
||||
|
||||
#+STYLE: <link rel="stylesheet" type="text/css" href="assets/stylesheet.css" />
|
||||
|
||||
# External links
|
||||
#
|
||||
#+LINK: smart-snippet http://code.google.com/p/smart-snippet
|
||||
#+LINK: pluskid http://pluskid.lifegoo.org
|
||||
|
||||
|
||||
#+LINK: screencast http://www.youtube.com/watch?v=ZCGmZK4V7Sg
|
||||
#+LINK: docs http://capitaomorte.github.com/yasnippet
|
||||
#+LINK: issues https://github.com/capitaomorte/yasnippet/issues
|
||||
#+LINK: googlecode-tracker http://code.google.com/p/yasnippet/issues/list
|
||||
#+LINK: forum http://groups.google.com/group/smart-snippet
|
||||
|
||||
*YASnippet* is a template system for Emacs. It allows you to type an
|
||||
abbreviation and automatically expand it into function templates. Bundled
|
||||
language templates includes: C, C++, C#, Perl, Python, Ruby, SQL, LaTeX, HTML,
|
||||
CSS and more. The snippet syntax is inspired from TextMate's syntax, you can
|
||||
even [[#import-textmate][import most TextMate snippets]]
|
||||
|
||||
YASnippet is an original creation of [[pluskid]] who also wrote its predecessor
|
||||
[[smart-snippet]].
|
||||
|
||||
* Watch a demo [[screencast]]
|
||||
|
||||
* Install the most recent version with git
|
||||
|
||||
Clone this repository somewhere
|
||||
|
||||
#+BEGIN_EXAMPLE
|
||||
$ cd ~/.emacs.d/plugins
|
||||
$ git clone https://github.com/capitaomorte/yasnippet
|
||||
#+END_EXAMPLE
|
||||
|
||||
Add the following in your =.emacs= file:
|
||||
|
||||
#+BEGIN_EXAMPLE
|
||||
(add-to-list 'load-path
|
||||
"~/.emacs.d/plugins/yasnippet")
|
||||
(require 'yasnippet)
|
||||
(yas/global-mode 1)
|
||||
#+END_EXAMPLE
|
||||
|
||||
Add your own snippets to `~/.emacs.d/snippets` by placing files there or invoking `yas/new-snippet`.
|
||||
|
||||
* Install yasnippet with el-get
|
||||
|
||||
[[https://github.com/dimitri/el-get.gti][El-get]] is a nice way to get the most recent version.
|
||||
|
||||
* Import textmate snippets (rails example)
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: import-textmate
|
||||
:END:
|
||||
|
||||
Clone the yasnippet repository to `~/.emacs.d/plugins/yasnippet`
|
||||
|
||||
#+BEGIN_EXAMPLE
|
||||
cd ~/.emacs.d/plugins/yasnippet
|
||||
git submodule init
|
||||
git submodule update
|
||||
gem install plist trollop
|
||||
rake convert_bundles # will convert ruby, rails and html bundles from drnic
|
||||
#+END_EXAMPLE
|
||||
|
||||
Then, in your .emacs file
|
||||
|
||||
#+BEGIN_EXAMPLE
|
||||
(add-to-list 'load-path
|
||||
"~/.emacs.d/plugins/yasnippet")
|
||||
(require 'yasnippet)
|
||||
(setq yas/snippet-dirs '("~/.emacs.d/snippets" "~/.emacs.d/extras/imported"))
|
||||
(yas/global-mode 1)
|
||||
#+END_EXAMPLE
|
||||
|
||||
Open some rails file (model, app, etc) and start using the textmate snippets.
|
||||
|
||||
* Contributing snippets
|
||||
|
||||
Please do not ask me to add snippets to the default collection under
|
||||
=/snippets=. This is considered frozen and by customizing =yas/snippet-dirs= you
|
||||
can point yasnippet to good snippet collections out there.
|
||||
|
||||
The =extras/textmate-import.rb= tool can import many actual Textmate
|
||||
snippets. See [[import-textmate]].
|
||||
|
||||
I'm focusing on developping =textmate-import.rb= tool and the =yas-setup.el=
|
||||
files that guide it with more difficult importation. In the future =/snippets=
|
||||
snippets will be deprecated and replaced with =extras/imported=.
|
||||
|
||||
* Documentation, issues, etc
|
||||
|
||||
Please refer to the comprehensive [[docs][documentation]] for full customization and
|
||||
support. If you think you've found a bug, please report it on [[issues][the GitHub issue
|
||||
tracker]]. (please **do not** submit new issues to the old [[googlecode-tracker][googlecode tracker]])
|
||||
|
||||
If you run into problems using YASnippet, or have snippets to contribute, post
|
||||
to the [[forum][yasnippet forum]]. Thank you very much for using YASnippet!
|
89
Rakefile
Normal file
89
Rakefile
Normal file
@ -0,0 +1,89 @@
|
||||
# -*- Ruby -*-
|
||||
|
||||
require 'fileutils'
|
||||
|
||||
def find_version
|
||||
File.read("yasnippet.el", :encoding => "UTF-8") =~ /;; Package-version: *([0-9.]+?) *$/
|
||||
$version = $1
|
||||
end
|
||||
find_version
|
||||
FileUtils.mkdir_p('pkg')
|
||||
|
||||
|
||||
desc "convert some textmate bundles to yasnippets"
|
||||
task :convert_bundles do
|
||||
Dir.glob "extras/bundles/*-tmbundle" do |bundle_dir|
|
||||
puts "Converting from #{bundle_dir}"
|
||||
mode_prefix = File.basename(bundle_dir).match(/[^-]*/)[0]
|
||||
raise "Couldn't guess mode name for #{bundle_dir}" unless mode_prefix
|
||||
output = "./extras/imported/#{mode_prefix}-mode"
|
||||
FileUtils.mkdir_p output
|
||||
sh "./extras/textmate_import.rb -d #{bundle_dir} -o #{output} -q"
|
||||
end
|
||||
end
|
||||
|
||||
desc "create a release package"
|
||||
task :package do
|
||||
release_dir = "pkg/yasnippet-#{$version}"
|
||||
FileUtils.mkdir_p(release_dir)
|
||||
files = ['snippets', 'yasnippet.el', 'dropdown-list.el']
|
||||
FileUtils.cp_r files, release_dir
|
||||
File.open(File.join(release_dir,'yasnippet-pkg.el'), 'w') do |file|
|
||||
file.puts <<END
|
||||
(define-package "yasnippet"
|
||||
"#{$version}"
|
||||
"A template system for Emacs")
|
||||
END
|
||||
end
|
||||
sh "git clean -f snippets"
|
||||
FileUtils.cd 'pkg' do
|
||||
sh "tar cf yasnippet-#{$version}.tar yasnippet-#{$version}"
|
||||
end
|
||||
end
|
||||
|
||||
desc "create a release package and upload it to google code"
|
||||
task :release => [:package, 'doc:archive'] do
|
||||
raise "Not implemented for github yet!"
|
||||
end
|
||||
|
||||
rule '.html' => '.rst' do |t|
|
||||
sh "doc/compile-doc.py #{t.source} > #{t.name}"
|
||||
end
|
||||
desc "Generate document"
|
||||
task :doc => FileList['doc/*.rst'].ext('html')
|
||||
|
||||
namespace :doc do
|
||||
task :archive do
|
||||
release_dir = "pkg/yasnippet-#{$version}"
|
||||
FileUtils.mkdir_p(release_dir)
|
||||
sh "tar cjf pkg/yasnippet-doc-#{$version}.tar.bz2 " +
|
||||
"--exclude=doc/.svn --exclude=doc/images/.svn doc/*.html doc/images"
|
||||
end
|
||||
|
||||
task :upload do
|
||||
if File.exists? 'doc/gh-pages'
|
||||
Dir.chdir 'doc/gh-pages' do
|
||||
sh "git checkout gh-pages"
|
||||
end
|
||||
Dir.glob("doc/*.{html,css}").each do |file|
|
||||
FileUtils.cp file, 'doc/gh-pages'
|
||||
end
|
||||
Dir.glob("doc/images/*").each do |file|
|
||||
FileUtils.cp file, 'doc/gh-pages/images'
|
||||
end
|
||||
Dir.chdir 'doc/gh-pages' do
|
||||
sh "git commit -a -m 'Automatic documentation update.'"
|
||||
sh "git push"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Compile yasnippet.el into yasnippet.elc"
|
||||
|
||||
rule '.elc' => '.el' do |t|
|
||||
sh "emacs --batch -L . --eval \"(byte-compile-file \\\"#{t.source}\\\")\""
|
||||
end
|
||||
task :compile => FileList["yasnippet.el", "dropdown-list.el"].ext('elc')
|
||||
|
||||
task :default => :doc
|
87
doc/faq.org
87
doc/faq.org
@ -1,87 +0,0 @@
|
||||
#+SETUPFILE: org-setup.inc
|
||||
|
||||
#+TITLE: Frequently Asked Questions
|
||||
|
||||
- *Note*: In addition to the questions and answers presented here,
|
||||
you might also with to visit the list of [[https://github.com/joaotavora/yasnippet/issues?q=label%3Asupport][solved support issues]] in
|
||||
the Github issue tracker. It might be more up-to-date than this
|
||||
list.
|
||||
|
||||
* Why are my snippet abbrev keys triggering when I don't want them too?
|
||||
Expansion of abbrev keys is controlled by [[sym:yas-key-syntaxes][=yas-key-syntaxes=]]. Try
|
||||
removing entries which correspond to the abbrev key character syntax.
|
||||
For example, if you have a snippet with abbrev key "bar", that you
|
||||
don't want to trigger when point follows the text =foo_bar=, remove
|
||||
the ="w"= entry (since "bar" has only word syntax characters).
|
||||
|
||||
* Why aren't my snippet abbrev keys triggering when I want them too?
|
||||
See previous question, but in reverse.
|
||||
|
||||
* Why is there an extra newline?
|
||||
|
||||
If there is a newline at the end of a snippet definition file,
|
||||
YASnippet will add a newline when expanding that snippet. When editing
|
||||
or saving a snippet file, please be careful not to accidentally add a
|
||||
terminal newline.
|
||||
|
||||
Note that some editors will automatically add a newline for you. In
|
||||
Emacs, if you set =require-final-newline= to =t=, it will add the
|
||||
final newline automatically.
|
||||
|
||||
* Why doesn't TAB navigation work with flyspell
|
||||
|
||||
This is [[https://debbugs.gnu.org/26672][Emacs Bug#26672]], so you should upgrade to version 25.3 or
|
||||
better. Otherwise, a workaround is to inhibit flyspell overlays while
|
||||
the snippet is active:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(add-hook 'flyspell-incorrect-hook
|
||||
#'(lambda (&rest _)
|
||||
(and yas-active-field-overlay
|
||||
(overlay-buffer yas-active-field-overlay))))
|
||||
#+END_SRC
|
||||
|
||||
* How do I use alternative keys, i.e. not TAB?
|
||||
|
||||
Edit the keymaps [[sym:yas-minor-mode-map][=yas-minor-mode-map=]] and [[sym:yas-keymap][=yas-keymap=]] as you would
|
||||
any other keymap, but use [[sym:yas-filtered-definition][=yas-filtered-definition=]] on the definition
|
||||
if you want to respect [[sym:yas-keymap-disable-hook][=yas-keymap-disable-hook=]]:
|
||||
|
||||
#+begin_src emacs-lisp :exports code
|
||||
(define-key yas-minor-mode-map (kbd "<tab>") nil)
|
||||
(define-key yas-minor-mode-map (kbd "TAB") nil)
|
||||
(define-key yas-minor-mode-map (kbd "<the new key>") yas-maybe-expand)
|
||||
|
||||
;;keys for navigation
|
||||
(define-key yas-keymap [(tab)] nil)
|
||||
(define-key yas-keymap (kbd "TAB") nil)
|
||||
(define-key yas-keymap [(shift tab)] nil)
|
||||
(define-key yas-keymap [backtab] nil)
|
||||
(define-key yas-keymap (kbd "<new-next-field-key>")
|
||||
(yas-filtered-definition 'yas-next-field-or-maybe-expand))
|
||||
(define-key yas-keymap (kbd "<new-prev-field-key>")
|
||||
(yas-filtered-definition 'yas-prev-field))
|
||||
#+end_src
|
||||
|
||||
* How do I define an abbrev key containing characters not supported by the filesystem?
|
||||
|
||||
- *Note*: This question applies if you're still defining snippets
|
||||
whose key /is/ the filename. This is behavior still provided by
|
||||
version 0.6 for backward compatibilty, but is somewhat
|
||||
deprecated...
|
||||
|
||||
For example, you want to define a snippet by the key =<= which is not a
|
||||
valid character for filename on Windows. This means you can't use the
|
||||
filename as a trigger key in this case.
|
||||
|
||||
You should rather use the =# key:= directive to specify the key of the
|
||||
defined snippet explicitly and name your snippet with an arbitrary valid
|
||||
filename, =lt.YASnippet= for example, using =<= for the =# key:=
|
||||
directive:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
# key: <
|
||||
# name: <...></...>
|
||||
# --
|
||||
<${1:div}>$0</$1>
|
||||
#+END_SRC
|
@ -1,47 +0,0 @@
|
||||
#+SETUPFILE: org-setup.inc
|
||||
#+TITLE: Yet another snippet extension
|
||||
|
||||
The YASnippet documentation has been split into separate parts:
|
||||
|
||||
0. [[https://github.com/joaotavora/yasnippet/blob/master/README.mdown][README]]
|
||||
|
||||
Contains an introduction, installation instructions and other important
|
||||
notes.
|
||||
|
||||
1. [[file:snippet-organization.org][Organizing Snippets]]
|
||||
|
||||
Describes ways to organize your snippets in the hard disk.
|
||||
|
||||
2. [[file:snippet-expansion.org][Expanding Snippets]]
|
||||
|
||||
Describes how YASnippet chooses snippets for expansion at point.
|
||||
|
||||
Maybe, you'll want some snippets to be expanded in a particular mode,
|
||||
or only under certain conditions, or be prompted using =ido=, etc...
|
||||
|
||||
3. [[file:snippet-development.org][Writing Snippets]]
|
||||
|
||||
Describes the YASnippet definition syntax, which is very close (but
|
||||
not equivalent) to Textmate's. Includes a section about converting
|
||||
TextMate snippets.
|
||||
|
||||
4. [[file:snippet-menu.org][The YASnippet menu]]
|
||||
|
||||
Explains how to use the YASnippet menu to explore, learn and modify
|
||||
snippets.
|
||||
|
||||
5. [[file:faq.org][Frequently asked questions]]
|
||||
|
||||
Answers to frequently asked questions.
|
||||
|
||||
6. [[file:snippet-reference.org][YASnippet Symbol Reference]]
|
||||
|
||||
An automatically generated listing of all YASnippet commands,
|
||||
(customization) variables, and functions.
|
||||
|
||||
|
||||
# Local Variables:
|
||||
# mode: org
|
||||
# fill-column: 80
|
||||
# coding: utf-8
|
||||
# End:
|
266
doc/manual.org
Normal file
266
doc/manual.org
Normal file
@ -0,0 +1,266 @@
|
||||
#+TITLE: Yet another snippet extension
|
||||
#+OPTIONS: toc:1
|
||||
#+STARTUP: showall
|
||||
|
||||
#+STYLE: <link rel="stylesheet" type="text/css" href="stylesheets/styles.css" />
|
||||
|
||||
# External links
|
||||
#
|
||||
#+LINK: smart-snippet http://code.google.com/p/smart-snippet
|
||||
#+LINK: pluskid http://pluskid.lifegoo.org
|
||||
|
||||
#+LINK: screencast http://www.youtube.com/watch?v=ZCGmZK4V7Sg
|
||||
#+LINK: docs http://capitaomorte.github.com/yasnippet
|
||||
#+LINK: issues https://github.com/capitaomorte/yasnippet/issues
|
||||
#+LINK: googlecode-tracker http://code.google.com/p/yasnippet/issues/list
|
||||
#+LINK: forum http://groups.google.com/group/smart-snippet
|
||||
|
||||
|
||||
* Quick start
|
||||
|
||||
*YASnippet* is a template system for Emacs. It allows you to type an
|
||||
abbreviation and automatically expand it into function templates. Bundled
|
||||
language templates includes: C, C++, C#, Perl, Python, Ruby, SQL, LaTeX, HTML,
|
||||
CSS and more. The snippet syntax is inspired from TextMate's syntax, you can
|
||||
even [[#import-textmate][import most TextMate snippets]]
|
||||
|
||||
YASnippet is an original creation of [[pluskid]] who also wrote its predecessor
|
||||
[[smart-snippet]].
|
||||
|
||||
** Watch a demo
|
||||
|
||||
[[youtube]]
|
||||
|
||||
** Installation
|
||||
|
||||
Clone this repository somewhere
|
||||
|
||||
#+begin_example
|
||||
$ cd ~/.emacs.d/plugins
|
||||
$ git clone https://github.com/capitaomorte/yasnippet
|
||||
#+end_example
|
||||
|
||||
Add the following in your =.emacs= file:
|
||||
|
||||
#+begin_src emacs-lisp :exports code
|
||||
(add-to-list 'load-path
|
||||
"~/.emacs.d/plugins/yasnippet")
|
||||
(require 'yasnippet)
|
||||
(yas/global-mode 1)
|
||||
#+end_src
|
||||
|
||||
Add your own snippets to =~/.emacs.d/snippets= by placing files there or
|
||||
invoking [[#yas-new-snippet][=yas-new-snippet=]].
|
||||
|
||||
** Import textmate snippets (rails example)
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: import-textmate
|
||||
:END:
|
||||
|
||||
YASnippet lets you use TextMate bundles directly:
|
||||
|
||||
#+begin_example
|
||||
$ cd ~/.emacs.d/plugins
|
||||
$ git clone https://github.com/capitaomorte/yasnippet
|
||||
$ cd yasnippet
|
||||
$ git submodule init
|
||||
$ git submodule update
|
||||
$ gem install plist trollop
|
||||
$ rake convert_bundles # will convert ruby, rails and html bundles from drnic
|
||||
#+end_example
|
||||
|
||||
Then, in your =.emacs= file
|
||||
|
||||
#+begin_example
|
||||
(add-to-list 'load-path
|
||||
"~/.emacs.d/plugins/yasnippet")
|
||||
(require 'yasnippet)
|
||||
(setq yas/snippet-dirs '("~/.emacs.d/snippets" "~/.emacs.d/extras/imported"))
|
||||
(yas/global-mode 1)
|
||||
#+end_example
|
||||
|
||||
Open some rails file (model, app, etc) and start using the textmate
|
||||
snippets. Consider that this is a work-in-progress and many snippets/commands
|
||||
might not work. Patches welcome!
|
||||
|
||||
** Contributing snippets
|
||||
|
||||
Please *do not ask me* to add snippets to the default collection under
|
||||
=/snippets=. This collection is considered frozen. By customizing
|
||||
[[#yas-snippet-dirs][=yas-snippet-dirs=]] you can point yasnippet to good
|
||||
snippet collections out there.
|
||||
|
||||
The =extras/textmate-import.rb= tool can import many actual Textmate
|
||||
snippets. I'm focusing on developing it and the accompanying =yas-setup.el=
|
||||
files that guide it with more difficult importations. The idea is to deprecate
|
||||
=/snippets= and replace it with =extras/imported=.
|
||||
|
||||
** Documentation, issues, etc
|
||||
|
||||
Please refer to the comprehensive [[docs][documentation]] for full
|
||||
customization and support. If you think you've found a bug, please report it
|
||||
on [[issues][the GitHub issue tracker]]. (please **do not** submit new
|
||||
issues to the old [[googlecode-tracker][googlecode tracker]])
|
||||
|
||||
If you run into problems using YASnippet, or have snippets to contribute,
|
||||
post to the [[forum][yasnippet forum]]. Thank you very much for using
|
||||
YASnippet!
|
||||
|
||||
* Organizing snippets
|
||||
|
||||
** Basic structure
|
||||
|
||||
Snippet collections can be stored in plain text files. They are arranged by
|
||||
sub-directories naming *snippet tables*. These mostly name Emacs major names.
|
||||
|
||||
#+begin_example
|
||||
.
|
||||
|-- c-mode
|
||||
| `-- printf
|
||||
|-- java-mode
|
||||
| `-- println
|
||||
`-- text-mode
|
||||
|-- email
|
||||
`-- time
|
||||
#+end_example
|
||||
|
||||
The collections are loaded into *snippet tables* which the triggering
|
||||
mechanism (see [[#expand-snippets][Expanding snippets]]) looks up and
|
||||
(hopefully) cause the right snippet to be expanded for you.
|
||||
|
||||
** Setting up =yas-snippet-dirs=
|
||||
|
||||
The emacs variable [[#yas-snippet-dirs][=yas-snippet-dirs=]] tells YASnippet
|
||||
which collections to consider. It's used when you activate
|
||||
[[#yas-global-mode][=yas-global-mode=]] or call
|
||||
[[#yas-reload-all][=yas-reload-all=]] interactively.
|
||||
|
||||
The default considers:
|
||||
|
||||
- a personal collection that lives in =~/.emacs.d/snippets=
|
||||
- the bundled collection, taken as a relative path to =yasnippet.el= localtion
|
||||
|
||||
When you come across other snippet collections, do the following to try them
|
||||
out:
|
||||
|
||||
#+begin_src emacs-lisp :exports code
|
||||
;; Develop in ~/emacs.d/mysnippets, but also
|
||||
;; try out snippets in ~/Downloads/interesting-snippets
|
||||
(setq yas/snippet-dirs '("~/emacs.d/mysnippets"
|
||||
"~/Downloads/interesting-snippets"))
|
||||
|
||||
;; OR, keeping yasnippet's defaults try out ~/Downloads/interesting-snippets
|
||||
(setq yas/snippet-dirs (append yas/snippet-dirs
|
||||
'("~/Downloads/interesting-snippets")))
|
||||
#+end_src
|
||||
|
||||
Collections appearing earlier in the list shadow snippets with same names
|
||||
appearing in collections later in the list. [[#yas-new-snippet][=yas-new-snippet=]] always stores
|
||||
snippets in the first collection.
|
||||
|
||||
** The =.yas.parents= file
|
||||
|
||||
It's very useful to have certain modes share snippets between themselves. To do
|
||||
this, choose a mode subdirectory and place a =.yas-parents= containing a
|
||||
whitespace-separated list of other mode names. When you reload those modes
|
||||
become parents of the original mode.
|
||||
|
||||
#+begin_example
|
||||
.
|
||||
|-- c-mode
|
||||
| |-- .yas-parents # contains "cc-mode text-mode"
|
||||
| `-- printf
|
||||
|-- cc-mode
|
||||
| |-- for
|
||||
| `-- while
|
||||
|-- java-mode
|
||||
| |-- .yas-parents # contains "cc-mode text-mode"
|
||||
| `-- println
|
||||
`-- text-mode
|
||||
|-- email
|
||||
`-- time
|
||||
#+end_example
|
||||
|
||||
** TODO The =.yas-make-groups= file
|
||||
|
||||
If you place an empty plain text file =.yas-make-groups= inside one of the
|
||||
mode directories, the names of these sub-directories are considered groups of
|
||||
snippets and [[snippet-menu][the menu]] is organized much more cleanly:
|
||||
|
||||
(TODO image)
|
||||
|
||||
Another alternative way to achieve this is to place a =# group:= directive
|
||||
inside the snippet definition. See [[#writing-snippets][Writing Snippets]]
|
||||
|
||||
#+begin_example
|
||||
$ tree ruby-mode/
|
||||
ruby-mode/
|
||||
|-- .yas-make-groups
|
||||
|-- collections
|
||||
| |-- each
|
||||
| `-- ...
|
||||
|-- control structure
|
||||
| |-- forin
|
||||
| `-- ...
|
||||
|-- definitions
|
||||
| `-- ...
|
||||
`-- general
|
||||
`-- ...
|
||||
#+end_example
|
||||
|
||||
Yet another way to create a nice snippet menu is to write into
|
||||
=.yas-make-groups= a menu definition. TODO
|
||||
|
||||
** TODO The =.yas-setup.el= file
|
||||
|
||||
*** TODO
|
||||
|
||||
** TODO The =.yas-compiled-snippet.el= file
|
||||
|
||||
*** TODO
|
||||
|
||||
** The =.yas-skip= file
|
||||
|
||||
* Expanding Snippets
|
||||
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: expand-snippets
|
||||
:END:
|
||||
|
||||
This section describes how YASnippet chooses snippets for expansion at point.
|
||||
|
||||
Maybe, you'll want some snippets to be expanded in a particular
|
||||
mode, or only under certain conditions, or be prompted using
|
||||
|
||||
** Triggering expansion
|
||||
|
||||
To make a snippet expand after the cursor:
|
||||
|
||||
* Type an the snippet's *trigger key* then press the key defined in
|
||||
[[#yas-trigger-key][=yas-trigger-key=]] (usually to "TAB").
|
||||
|
||||
* Use the snippet's *keybinding*.
|
||||
|
||||
* Call [[#yas-insert-snippet][=yas-insert-snippet=]] (use =M-x
|
||||
yas-insert-snippet== or its keybinding =C-c & C-s=).
|
||||
|
||||
* By expanding directly from the "YASnippet" menu in the menu-bar
|
||||
|
||||
* Using hippie-expand
|
||||
|
||||
* Use m2m's excellent auto-complete
|
||||
|
||||
* Reference
|
||||
#+BEGIN_SRC emacs-lisp :exports results :results value raw
|
||||
(yas--document-symbols 2 `("Interactive functions" . ,#'interactive-form)
|
||||
`("Customization variables" . ,#'(lambda (sym)
|
||||
(and (boundp sym)
|
||||
(get sym 'standard-value))))
|
||||
`("Useful functions" . ,#'fboundp)
|
||||
`("Useful variables" . ,#'boundp))
|
||||
#+END_SRC
|
||||
# Local Variables:
|
||||
# mode: org
|
||||
# fill-column: 80
|
||||
# coding: utf-8
|
||||
# End:
|
@ -1,16 +0,0 @@
|
||||
<nav>
|
||||
<ul class="center">
|
||||
<li> <a href="index.html">Overview</a>
|
||||
<li> <a href="https://github.com/joaotavora/yasnippet/blob/master/README.mdown">
|
||||
Intro and Tutorial</a>
|
||||
<li class="center border">Snippet
|
||||
<ul class="nopad">
|
||||
<li> <a href="snippet-organization.html">Organization</a>
|
||||
<li> <a href="snippet-expansion.html">Expansion</a>
|
||||
<li> <a href="snippet-development.html">Development</a>
|
||||
<li> <a href="snippet-menu.html">Menu</a>
|
||||
</ul>
|
||||
<li> <a href="faq.html">FAQ</a>
|
||||
<li> <a href="snippet-reference.html">Reference</a>
|
||||
</ul>
|
||||
</nav>
|
@ -1,11 +0,0 @@
|
||||
# -*- mode: org -*-
|
||||
|
||||
#+STARTUP: showall
|
||||
|
||||
#+LINK: sym file:snippet-reference.org::#%s
|
||||
|
||||
#+OPTIONS: author:nil num:nil timestamp:nil
|
||||
#+AUTHOR:
|
||||
# org < 8.0 use +STYLE, after use +HTML_HEAD
|
||||
#+STYLE: <link rel="stylesheet" type="text/css" href="stylesheets/manual.css" />
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="stylesheets/manual.css" />
|
@ -1,474 +0,0 @@
|
||||
#+SETUPFILE: org-setup.inc
|
||||
|
||||
#+TITLE: Writing snippets
|
||||
|
||||
* Snippet development
|
||||
|
||||
** Quickly finding snippets
|
||||
|
||||
There are some ways you can quickly find a snippet file or create a new one:
|
||||
|
||||
- =M-x yas-new-snippet=, key binding: =C-c & C-n=
|
||||
|
||||
Creates a new buffer with a template for making a new snippet. The
|
||||
buffer is in =snippet-mode= (see [[snippet-mode][below]]). When you are done editing
|
||||
the new snippet, use [[yas-load-snippet-buffer-and-close][=C-c C-c=]] to save it.
|
||||
|
||||
- =M-x yas-visit-snippet-file=, key binding: =C-c & C-v=
|
||||
|
||||
Prompts you for possible snippet expansions like
|
||||
[[sym:yas-insert-snippet][=yas-insert-snippet=]], but instead of expanding it, takes you directly
|
||||
to the snippet definition's file, if it exists.
|
||||
|
||||
Once you find this file it will be set to =snippet-mode= (see [[snippet-mode][ahead]])
|
||||
and you can start editing your snippet.
|
||||
|
||||
** Using the =snippet-mode= major mode <<snippet-mode>>
|
||||
|
||||
There is a major mode =snippet-mode= to edit snippets. You can set the
|
||||
buffer to this mode with =M-x snippet-mode=. It provides reasonably
|
||||
useful syntax highlighting.
|
||||
|
||||
Three commands are defined in this mode:
|
||||
|
||||
- =M-x yas-load-snippet-buffer=, key binding: =C-c C-l=
|
||||
|
||||
Prompts for a snippet table (with a default based on snippet's
|
||||
major mode) and loads the snippet currently being edited.
|
||||
|
||||
- =M-x yas-load-snippet-buffer-and-close=, key binding: =C-c C-c=
|
||||
<<yas-load-snippet-buffer-and-close>>
|
||||
|
||||
Like =yas-load-snippet-buffer=, but also saves the snippet and
|
||||
calls =quit-window=. The destination is decided based on the
|
||||
chosen snippet table and snippet collection directly (defaulting to
|
||||
the first directory in =yas-snippet-dirs= (see [[file:snippet-organization.org][Organizing Snippets]]
|
||||
for more detail on how snippets are organized).
|
||||
|
||||
- =M-x yas-tryout-snippet=, key binding: =C-c C-t=
|
||||
|
||||
When editing a snippet, this opens a new empty buffer, sets it to
|
||||
the appropriate major mode and inserts the snippet there, so you
|
||||
can see what it looks like.
|
||||
|
||||
There are also /snippets for writing snippets/: =vars=, =$f= and =$m=
|
||||
:-).
|
||||
|
||||
* File content
|
||||
|
||||
A file defining a snippet generally contains the template to be
|
||||
expanded.
|
||||
|
||||
Optionally, if the file contains a line of =# --=, the lines above it
|
||||
count as comments, some of which can be /directives/ (or meta data).
|
||||
Snippet directives look like =# property: value= and tweak certain
|
||||
snippet properties described below. If no =# --= is found, the whole
|
||||
file is considered the snippet template.
|
||||
|
||||
Here's a typical example:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
# contributor: pluskid <pluskid@gmail.com>
|
||||
# name: __...__
|
||||
# --
|
||||
__${init}__
|
||||
#+END_SRC
|
||||
|
||||
Here's a list of currently supported directives:
|
||||
|
||||
** =# key:= snippet abbrev
|
||||
|
||||
This is the probably the most important directive, it's the
|
||||
abbreviation you type to expand a snippet just before hitting the key
|
||||
that runs [[sym:yas-expand][=yas-expand=]]. If you don't specify this,
|
||||
the snippet will not be expandable through the trigger mechanism.
|
||||
|
||||
** =# name:= snippet name
|
||||
|
||||
This is a one-line description of the snippet. It will be displayed in
|
||||
the menu. It's a good idea to select a descriptive name for a snippet --
|
||||
especially distinguishable among similar snippets.
|
||||
|
||||
If you omit this name, it will default to the file name the snippet
|
||||
was loaded from.
|
||||
|
||||
** =# condition:= snippet condition
|
||||
|
||||
This is a piece of Emacs Lisp code. If a snippet has a condition, then
|
||||
it will only be expanded when the condition code evaluate to some
|
||||
non-nil value.
|
||||
|
||||
See also [[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] in
|
||||
[[./snippet-expansion.org][Expanding snippets]]
|
||||
|
||||
** =# group:= snippet menu grouping
|
||||
|
||||
When expanding/visiting snippets from the menu-bar menu, snippets for a
|
||||
given mode can be grouped into sub-menus. This is useful if one has too
|
||||
many snippets for a mode which will make the menu too long.
|
||||
|
||||
The =# group:= property only affect menu construction (See
|
||||
[[./snippet-menu.org][the YASnippet menu]]) and the same effect can be
|
||||
achieved by grouping snippets into sub-directories and using the
|
||||
=.yas-make-groups= special file (for this see
|
||||
[[./snippet-organization.org][Organizing Snippets]]
|
||||
|
||||
Refer to the bundled snippets for =ruby-mode= for examples of the
|
||||
=# group:= directive. Group can also be nested, e.g.
|
||||
=control structure.loops= indicates that the snippet is under the =loops=
|
||||
group which is under the =control structure= group.
|
||||
|
||||
** =# expand-env:= expand environment
|
||||
|
||||
This is another piece of Emacs Lisp code in the form of a =let= /varlist
|
||||
form/, i.e. a list of lists assigning values to variables. It can be
|
||||
used to override variable values while the snippet is being expanded.
|
||||
|
||||
Interesting variables to override are [[sym:yas-wrap-around-region][=yas-wrap-around-region=]] and
|
||||
[[sym:yas-indent-line][=yas-indent-line=]] (see [[./snippet-expansion.org][Expanding Snippets]]).
|
||||
|
||||
As an example, you might normally have [[sym:yas-indent-line][=yas-indent-line=]] set to '=auto=
|
||||
and [[sym:yas-wrap-around-region][=yas-wrap-around-region=]] set to =t=, but for this particularly
|
||||
brilliant piece of ASCII art these values would mess up your hard work.
|
||||
You can then use:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
# name: ASCII home
|
||||
# expand-env: ((yas-indent-line 'fixed) (yas-wrap-around-region 'nil))
|
||||
# --
|
||||
welcome to my
|
||||
X humble
|
||||
/ \ home,
|
||||
/ \ $0
|
||||
/ \
|
||||
/-------\
|
||||
| |
|
||||
| +-+ |
|
||||
| | | |
|
||||
+--+-+--+
|
||||
#+END_SRC
|
||||
|
||||
** =# binding:= direct keybinding
|
||||
|
||||
You can use this directive to expand a snippet directly from a normal
|
||||
Emacs keybinding. The keybinding will be registered in the Emacs keymap
|
||||
named after the major mode the snippet is active for.
|
||||
|
||||
Additionally a variable [[sym:yas-prefix][=yas-prefix=]] is set to the prefix argument
|
||||
you normally use for a command. This allows for small variations on the
|
||||
same snippet, for example in this =html-mode= snippet.
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
# name: <p>...</p>
|
||||
# binding: C-c C-c C-m
|
||||
# --
|
||||
<p>`(when yas-prefix "\n")`$0`(when yas-prefix "\n")`</p>
|
||||
#+END_SRC
|
||||
|
||||
This binding will be recorded in the keymap =html-mode-map=. To expand a
|
||||
paragraph tag newlines, just press =C-u C-c C-c C-m=. Omitting the =C-u=
|
||||
will expand the paragraph tag without newlines.
|
||||
|
||||
** =# type:= =snippet= or =command=
|
||||
|
||||
If the =type= directive is set to =command=, the body of the snippet
|
||||
is interpreted as Lisp code to be evaluated when the snippet is
|
||||
triggered.
|
||||
|
||||
If it's =snippet= (the default when there is no =type= directive), the
|
||||
snippet body will be parsed according to the [[Template Syntax]],
|
||||
described below.
|
||||
|
||||
** =# uuid:= unique identifier
|
||||
|
||||
This provides to a way to identify a snippet, independent of its name.
|
||||
Loading a second snippet file with the same uuid would replace the
|
||||
previous snippet.
|
||||
|
||||
** =# contributor:= snippet author
|
||||
|
||||
This is optional and has no effect whatsoever on snippet functionality,
|
||||
but it looks nice.
|
||||
|
||||
* Template Syntax
|
||||
|
||||
The syntax of the snippet template is simple but powerful, very similar
|
||||
to TextMate's.
|
||||
|
||||
** Plain Text
|
||||
|
||||
Arbitrary text can be included as the content of a template. They are
|
||||
usually interpreted as plain text, except =$= and =`=. You need to
|
||||
use =\= to escape them: =\$= and =\`=. The =\= itself may also needed to be
|
||||
escaped as =\\= sometimes.
|
||||
|
||||
** Embedded Emacs Lisp code
|
||||
|
||||
Emacs Lisp code can be embedded inside the template, written inside
|
||||
back-quotes (=`=). The Lisp forms are evaluated when the snippet is
|
||||
being expanded. The evaluation is done in the same buffer as the
|
||||
snippet being expanded.
|
||||
|
||||
Here's an example for =c-mode= to calculate the header file guard
|
||||
dynamically:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
#ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_}
|
||||
#define $1
|
||||
|
||||
$0
|
||||
|
||||
#endif /* $1 */
|
||||
#+END_SRC
|
||||
|
||||
From version 0.6, snippet expansions are run with some special
|
||||
Emacs Lisp variables bound. One of these is [[sym:yas-selected-text][=yas-selected-text=]]. You can
|
||||
therefore define a snippet like:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
for ($1;$2;$3) {
|
||||
`yas-selected-text`$0
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
to "wrap" the selected region inside your recently inserted snippet.
|
||||
Alternatively, you can also customize the variable
|
||||
[[sym:yas-wrap-around-region][=yas-wrap-around-region=]] to =t= which will do this automatically.
|
||||
|
||||
*** Note: backquote expressions should not modify the buffer
|
||||
|
||||
Please note that the Lisp forms in backquotes should *not* modify the
|
||||
buffer, doing so will trigger a warning. For example, instead of
|
||||
doing
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
Timestamp: `(insert (current-time-string))`
|
||||
#+END_SRC
|
||||
|
||||
do this:
|
||||
#+BEGIN_SRC snippet
|
||||
Timestamp: `(current-time-string)`
|
||||
#+END_SRC
|
||||
|
||||
The warning may be suppressed with the following code in your init file:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(add-to-list 'warning-suppress-types '(yasnippet backquote-change))
|
||||
#+END_SRC
|
||||
|
||||
|
||||
** Tab stop fields
|
||||
|
||||
Tab stops are fields that you can navigate back and forth by =TAB= and
|
||||
=S-TAB=. They are written by =$= followed with a number. =$0= has the
|
||||
special meaning of the /exit point/ of a snippet. That is the last place
|
||||
to go when you've traveled all the fields. Here's a typical example:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
<div$1>
|
||||
$0
|
||||
</div>
|
||||
#+END_SRC
|
||||
** Placeholder fields
|
||||
|
||||
Tab stops can have default values -- a.k.a placeholders. The syntax is
|
||||
like this:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
${N:default value}
|
||||
#+END_SRC
|
||||
|
||||
They act as the default value for a tab stop. But when you first
|
||||
type at a tab stop, the default value will be replaced by your typing.
|
||||
The number can be omitted if you don't want to create [[mirrors-fields][mirrors]] or
|
||||
[[mirror-transformations][transformations]] for this field.
|
||||
|
||||
** Mirrors <<mirrors-fields>>
|
||||
|
||||
We refer to tab stops with placeholders as a /field/. A field can
|
||||
have mirrors. *All* mirrors get updated whenever you update any field
|
||||
text. Here's an example:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
\begin{${1:enumerate}}
|
||||
$0
|
||||
\end{$1}
|
||||
#+END_SRC
|
||||
|
||||
When you type "document" at =${1:enumerate}=, the word "document" will
|
||||
also be inserted at =\end{$1}=. The best explanation is to see the
|
||||
screencast([[http://www.youtube.com/watch?v=vOj7btx3ATg][YouTube]] or [[http://yasnippet.googlecode.com/files/yasnippet.avi][avi video]]).
|
||||
|
||||
The tab stops with the same number to the field act as its mirrors. If
|
||||
none of the tab stops have an initial value, the first one is selected as
|
||||
the field and the others are its mirrors.
|
||||
|
||||
** Mirrors with transformations <<mirror-transformations>>
|
||||
|
||||
If the value of an =${n:=-construct starts with and contains =$(=,
|
||||
then it is interpreted as a mirror for field =n= with a
|
||||
transformation. The mirror's text content is calculated according to
|
||||
this transformation, which is Emacs Lisp code that gets evaluated in
|
||||
an environment where the variable [[sym:yas-text][=yas-text=]] is bound to the text
|
||||
content (string) contained in the field =n=. Here's an example for
|
||||
Objective-C:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
- (${1:id})${2:foo}
|
||||
{
|
||||
return $2;
|
||||
}
|
||||
|
||||
- (void)set${2:$(capitalize yas-text)}:($1)aValue
|
||||
{
|
||||
[$2 autorelease];
|
||||
$2 = [aValue retain];
|
||||
}
|
||||
$0
|
||||
#+END_SRC
|
||||
|
||||
Look at =${2:$(capitalize yas-text)}=, it is a mirror with
|
||||
transformation instead of a field. The actual field is at the first
|
||||
line: =${2:foo}=. When you type text in =${2:foo}=, the transformation
|
||||
will be evaluated and the result will be placed there as the
|
||||
transformed text. So in this example, if you type "baz" in the field,
|
||||
the transformed text will be "Baz". This example is also available in
|
||||
the screencast.
|
||||
|
||||
Another example is for =rst-mode=. In reStructuredText, the document
|
||||
title can be some text surrounded by "===" below and above. The "==="
|
||||
should be at least as long as the text. So
|
||||
|
||||
#+BEGIN_SRC rst
|
||||
=====
|
||||
Title
|
||||
=====
|
||||
#+END_SRC
|
||||
|
||||
is a valid title but
|
||||
|
||||
#+BEGIN_SRC rst
|
||||
===
|
||||
Title
|
||||
===
|
||||
#+END_SRC
|
||||
|
||||
is not. Here's an snippet for rst title:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
${1:$(make-string (string-width yas-text) ?\=)}
|
||||
${1:Title}
|
||||
${1:$(make-string (string-width yas-text) ?\=)}
|
||||
|
||||
$0
|
||||
#+END_SRC
|
||||
|
||||
Note that a mirror with a transform is not restricted to the text of
|
||||
the field it is mirroring. By making use of [[sym:yas-field-value][=yas-field-value=]], a
|
||||
mirror can look at any of the snippet's field (as mentioned above, all
|
||||
mirrors are updated when any field is updated). Here is an example
|
||||
which shows a "live" result of calling format:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
(format "${1:formatted %s}" "${2:value}")
|
||||
=> "${1:$(ignore-errors (format (yas-field-value 1) (yas-field-value 2)))}"
|
||||
#+END_SRC
|
||||
|
||||
To keep the example simple, it uses =ignore-errors= to suppress errors
|
||||
due to incomplete format codes.
|
||||
|
||||
** Fields with transformations
|
||||
|
||||
From version 0.6 on, you can also have Lisp transformation inside
|
||||
fields. These work mostly like mirror transformations. However, they
|
||||
are evaluated when you first enter the field, after each change you
|
||||
make to the field and also just before you exit the field.
|
||||
|
||||
The syntax is also a tiny bit different, so that the parser can
|
||||
distinguish between fields and mirrors. In the following example
|
||||
|
||||
: #define "${1:mydefine$(upcase yas-text)}"
|
||||
|
||||
=mydefine= gets automatically upcased to =MYDEFINE= once you enter the
|
||||
field. As you type text, it gets filtered through the transformation
|
||||
every time.
|
||||
|
||||
Note that to tell this kind of expression from a mirror with a
|
||||
transformation, YASnippet needs extra text between the =:= and the
|
||||
transformation's =$=. If you don't want this extra-text, you can use two
|
||||
=$='s instead.
|
||||
|
||||
: #define "${1:$$(upcase yas-text)}"
|
||||
|
||||
Please note that as soon as a transformation takes place, it changes the
|
||||
value of the field and sets it its internal modification state to
|
||||
=true=. As a consequence, the auto-deletion behaviour of normal fields
|
||||
does not take place. This is by design.
|
||||
|
||||
** Choosing fields value from a list and other tricks
|
||||
|
||||
As mentioned, the field transformation is invoked just after you enter
|
||||
the field, and with some useful variables bound, notably
|
||||
[[sym:yas-modified-p][=yas-modified-p=]] and [[sym:yas-moving-away-p][=yas-moving-away-p=]]. Because of this feature you
|
||||
can place a transformation in the primary field that lets you select
|
||||
default values for it.
|
||||
|
||||
For example, the [[sym:yas-choose-value][=yas-completing-read=]] function is version of
|
||||
=completing-read= which checks these variables. For example, asking
|
||||
the user for the initial value of a field:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
<div align="${2:$$(yas-completing-read "Alignment? " '("right" "center" "left"))}">
|
||||
$0
|
||||
</div>
|
||||
#+END_SRC
|
||||
|
||||
See the definition of [[sym:yas-choose-value][=yas-completing-read=]] to see how it was written
|
||||
using the two variables. If you're really lazy :) and can't spare a
|
||||
tab keypress, you can automatically move to the next field (or exit)
|
||||
after choosing the value with [[sym:yas-auto-next][=yas-auto-next=]]. The snippet above
|
||||
becomes:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
<div align="${2:$$(yas-auto-next
|
||||
(yas-completing-read
|
||||
"Alignment? "
|
||||
'("right" "center" "left")))}">
|
||||
$0
|
||||
</div>
|
||||
#+END_SRC
|
||||
|
||||
Here's another use, for =LaTeX-mode=, which calls reftex-label just as you
|
||||
enter snippet field 2. This one makes use of [[sym:yas-modified-p][=yas-modified-p=]] directly.
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
\section{${1:"Titel der Tour"}}%
|
||||
\index{$1}%
|
||||
\label{{2:"waiting for reftex-label call..."$(unless yas-modified-p (reftex-label nil 'dont-insert))}}%
|
||||
#+END_SRC
|
||||
|
||||
The function [[sym:yas-verify-value][=yas-verify-value=]] has another neat trick, and makes use
|
||||
of [[sym:yas-moving-away-p][=yas-moving-away-p=]]. Try it and see! Also, check out this [[http://groups.google.com/group/smart-snippet/browse_thread/thread/282a90a118e1b662][thread]]
|
||||
|
||||
** Nested placeholder fields
|
||||
|
||||
From version 0.6 on, you can also have nested placeholders of the type:
|
||||
|
||||
#+BEGIN_SRC snippet
|
||||
<div${1: id="${2:some_id}"}>$0</div>
|
||||
#+END_SRC
|
||||
|
||||
This allows you to choose if you want to give this =div= an =id=
|
||||
attribute. If you tab forward after expanding, it will let you change
|
||||
"some\_id" to whatever you like. Alternatively, you can just press =C-d=
|
||||
(which executes [[sym:yas-skip-and-clear-or-delete-char][=yas-skip-and-clear-or-delete-char=]]) and go straight to
|
||||
the exit marker.
|
||||
|
||||
By the way, =C-d= will only clear the field if you cursor is at the
|
||||
beginning of the field /and/ it hasn't been changed yet. Otherwise, it
|
||||
performs the normal Emacs =delete-char= command.
|
||||
|
||||
** Indentation markers
|
||||
|
||||
If [[sym:yas-indent-line][=yas-indent-line=]] is *not* set to '=auto=, it's still possible to
|
||||
indent specific lines by adding an indentation marker, =$>=, somewhere
|
||||
on the line.
|
@ -1,284 +0,0 @@
|
||||
#+SETUPFILE: org-setup.inc
|
||||
|
||||
#+TITLE: Expanding snippets
|
||||
|
||||
This section describes how YASnippet chooses snippets for expansion at point.
|
||||
|
||||
Maybe, you'll want some snippets to be expanded in a particular
|
||||
mode, or only under certain conditions, or be prompted using
|
||||
|
||||
* Triggering expansion
|
||||
|
||||
You can use YASnippet to expand snippets in different ways:
|
||||
|
||||
- When [[sym:yas-minor-mode][=yas-minor-mode=]] is active:
|
||||
- Type the snippet's *trigger key* then calling [[sym:yas-expand][=yas-expand=]]
|
||||
(bound to =TAB= by default).
|
||||
|
||||
- Use the snippet's *keybinding*.
|
||||
|
||||
- By expanding directly from the "YASnippet" menu in the menu-bar
|
||||
|
||||
- Using hippie-expand
|
||||
|
||||
- Call [[sym:yas-insert-snippet][=yas-insert-snippet=]] (use =M-x yas-insert-snippet= or its
|
||||
keybinding =C-c & C-s=).
|
||||
|
||||
- Use m2m's excellent auto-complete
|
||||
TODO: example for this
|
||||
|
||||
- Expanding from emacs-lisp code
|
||||
|
||||
** Trigger key
|
||||
|
||||
[[sym:yas-expand][=yas-expand=]] tries to expand a /snippet abbrev/ (also known as
|
||||
/snippet key/) before point. YASnippet also provides a /conditional
|
||||
binding/ for this command: the variable [[sym:yas-expand][=yas-maybe-expand=]] contains a
|
||||
special value which, when bound in a keymap, tells Emacs to call
|
||||
[[sym:yas-expand][=yas-expand=]] if and only if there is a snippet abbrev before point.
|
||||
If there is no snippet to expand, Emacs will behave as if [[sym:yas-expand][=yas-expand=]]
|
||||
is unbound and so will run whatever command is bound to that key
|
||||
normally.
|
||||
|
||||
When [[sym:yas-minor-mode][=yas-minor-mode=]] is enabled, it binds [[sym:yas-maybe-expand][=yas-maybe-expand=]] to =TAB=
|
||||
and =<tab>= by default, however, you can freely remove those bindings:
|
||||
|
||||
#+begin_src emacs-lisp :exports code
|
||||
(define-key yas-minor-mode-map (kbd "<tab>") nil)
|
||||
(define-key yas-minor-mode-map (kbd "TAB") nil)
|
||||
#+end_src
|
||||
|
||||
And set your own:
|
||||
|
||||
#+begin_src emacs-lisp :exports code
|
||||
;; Bind `SPC' to `yas-expand' when snippet expansion available (it
|
||||
;; will still call `self-insert-command' otherwise).
|
||||
(define-key yas-minor-mode-map (kbd "SPC") yas-maybe-expand)
|
||||
;; Bind `C-c y' to `yas-expand' ONLY.
|
||||
(define-key yas-minor-mode-map (kbd "C-c y") #'yas-expand)
|
||||
#+end_src
|
||||
|
||||
|
||||
To enable the YASnippet minor mode in all buffers globally use the
|
||||
command [[sym:yas-global-mode][=yas-global-mode=]]. This will enable a modeline indicator,
|
||||
=yas=:
|
||||
|
||||
[[./images/minor-mode-indicator.png]]
|
||||
|
||||
When you use [[sym:yas-global-mode][=yas-global-mode=]] you can also selectively disable
|
||||
YASnippet in some buffers by calling [[sym:yas-minor-mode][=yas-minor-mode=]] with a negative
|
||||
argument in the buffer's mode hook.
|
||||
|
||||
*** Fallback behaviour
|
||||
|
||||
YASnippet used to support a more complicated way of sharing
|
||||
keybindings before [[sym:yas-expand][=yas-maybe-expand=]] was added. This is now
|
||||
obsolete.
|
||||
|
||||
** Insert at point
|
||||
|
||||
The command [[sym:yas-insert-snippet][=yas-insert-snippet=]] lets you insert snippets at point
|
||||
/for your current major mode/. It prompts you for the snippet key
|
||||
first, and then for a snippet template if more than one template
|
||||
exists for the same key.
|
||||
|
||||
The list presented contains the snippets that can be inserted at point,
|
||||
according to the condition system. If you want to see all applicable
|
||||
snippets for the major mode, prefix this command with =C-u=.
|
||||
|
||||
The prompting methods used are again controlled by
|
||||
[[sym:yas-prompt-functions][=yas-prompt-functions=]].
|
||||
|
||||
*** Inserting region or register contents into snippet
|
||||
|
||||
It's often useful to inject already written text in the middle of a
|
||||
snippet. The variable [[sym:yas-wrap-around-region][=yas-wrap-around-region=]] when to t substitute
|
||||
the region contents into the =$0= placeholder of a snippet expanded by
|
||||
[[sym:yas-insert-snippet][=yas-insert-snippet=]]. Setting it to a character value (e.g. =?0=)
|
||||
will insert the contents of corresponding register.
|
||||
|
||||
Older (versions 0.9.1 and below) of Yasnippet, supported a setting of
|
||||
=cua= that is equivalent to =?0= but only worked with =cua-mode=
|
||||
turned on. This setting is still supported for backwards
|
||||
compatibility, but is now entirely equivalent to =?0=.
|
||||
|
||||
** Snippet keybinding
|
||||
|
||||
See the section of the =# binding:= directive in
|
||||
[[./snippet-development.org][Writing Snippets]].
|
||||
|
||||
** Expanding from the menu
|
||||
|
||||
See [[./snippet-menu.org][the YASnippet Menu]].
|
||||
|
||||
** Expanding with =hippie-expand=
|
||||
|
||||
To integrate with =hippie-expand=, just put
|
||||
[[sym:yas-hippie-try-expand][=yas-hippie-try-expand=]] in
|
||||
=hippie-expand-try-functions-list=. This probably makes more sense
|
||||
when placed at the top of the list, but it can be put anywhere you
|
||||
prefer.
|
||||
|
||||
** Expanding from emacs-lisp code
|
||||
|
||||
Sometimes you might want to expand a snippet directly from your own
|
||||
elisp code. You should call [[sym:yas-expand-snippet][=yas-expand-snippet=]] instead of
|
||||
[[sym:yas-expand][=yas-expand=]] in this case. [[sym:yas-expand-snippet][=yas-expand-snippet=]] takes a string in
|
||||
snippet template syntax, if you want to expand an existing snippet you
|
||||
can use [[sym:yas-lookup-snippet][=yas-lookup-snippet=]] to find its contents by name.
|
||||
|
||||
As with expanding from the menubar, the condition system and multiple
|
||||
candidates doesn't affect expansion (the condition system does affect
|
||||
[[sym:yas-lookup-snippet][=yas-lookup-snippet=]] though). In fact, expanding from the YASnippet
|
||||
menu has the same effect of evaluating the follow code:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(yas-expand-snippet template)
|
||||
#+END_SRC
|
||||
|
||||
See the internal documentation on [[sym:yas-expand-snippet][=yas-expand-snippet=]] and
|
||||
[[sym:yas-lookup-snippet][=yas-lookup-snippet=]] for more information.
|
||||
|
||||
* Controlling expansion
|
||||
|
||||
** Eligible snippets<<eligible-snippets>>
|
||||
|
||||
YASnippet does quite a bit of filtering to find out which snippets are
|
||||
eligible for expanding at the current cursor position.
|
||||
|
||||
In particular, the following things matter:
|
||||
|
||||
- Currently loaded snippets tables
|
||||
|
||||
These are loaded from a directory hierarchy in your file system. See
|
||||
[[./snippet-organization.org][Organizing Snippets]]. They are named
|
||||
after major modes like =html-mode=, =ruby-mode=, etc...
|
||||
|
||||
- Major mode of the current buffer
|
||||
|
||||
If the currrent major mode matches one of the loaded snippet tables,
|
||||
then all that table's snippets are considered for expansion. Use
|
||||
=M-x describe-variable RET major-mode RET= to find out which major
|
||||
mode you are in currently.
|
||||
|
||||
- Parent tables
|
||||
|
||||
Snippet tables defined as the parent of some other eligible table
|
||||
are also considered. This works recursively, i.e., parents of
|
||||
parents of eligible tables are also considered. As a special case,
|
||||
if a mode doesn't have a parent, then =fundamental-mode= is
|
||||
considered to be its parent.
|
||||
|
||||
- Buffer-local list of extra modes
|
||||
|
||||
Use [[sym:yas-activate-extra-mode][=yas-activate-extra-mode=]] to
|
||||
consider snippet tables whose name does not correspond to a major
|
||||
mode. Typically, you call this from a minor mode hook, for example:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
;; When entering rinari-minor-mode, consider also the snippets in the
|
||||
;; snippet table "rails-mode"
|
||||
(add-hook 'rinari-minor-mode-hook
|
||||
#'(lambda ()
|
||||
(yas-activate-extra-mode 'rails-mode)))
|
||||
#+END_SRC
|
||||
|
||||
- Buffer-local [[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] variable
|
||||
|
||||
This variable provides finer grained control over what snippets can
|
||||
be expanded in the current buffer. For example, the constant
|
||||
[[sym:yas-not-string-or-comment-condition][=yas-not-string-or-comment-condition=]] has a value that disables
|
||||
snippet expansion inside comments or string literals. See [[condition-system][the
|
||||
condition system]] for more info.
|
||||
|
||||
** The condition system <<condition-system>>
|
||||
|
||||
Consider this scenario: you are an old Emacs hacker. You like the
|
||||
abbrev-way and bind [[sym:yas-expand][=yas-expand=]] to =SPC=. However, you don't want
|
||||
=if= to be expanded as a snippet when you are typing in a comment
|
||||
block or a string (e.g. in =python-mode=).
|
||||
|
||||
If you use the =# condition := directive (see [[./snippet-development.org][Writing Snippets]]) you
|
||||
could just specify the condition for =if= to be =(not
|
||||
(python-syntax-comment-or-string-p))=. But how about =while=, =for=,
|
||||
etc? Writing the same condition for all the snippets is just boring.
|
||||
So you can instead set [[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] to =(not
|
||||
(python-syntax-comment-or-string-p))= in =python-mode-hook=.
|
||||
|
||||
Then, what if you really want some particular snippet to expand even
|
||||
inside a comment? Set [[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] like this
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(add-hook 'python-mode-hook
|
||||
(lambda ()
|
||||
(setq yas-buffer-local-condition
|
||||
(lambda ()
|
||||
(if (python-syntax-comment-or-string-p)
|
||||
'(require-snippet-condition . force-in-comment)
|
||||
t)))))
|
||||
#+END_SRC
|
||||
|
||||
... and for a snippet that you want to expand in comments, specify a
|
||||
condition which evaluates to the symbol =force-in-comment=. Then it
|
||||
can be expanded as you expected, while other snippets like =if= still
|
||||
can't expanded in comments.
|
||||
|
||||
For the full set of possible conditions, see the documentation for
|
||||
[[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]].
|
||||
|
||||
** Multiples snippet with the same key
|
||||
|
||||
The rules outlined [[eligible-snippets][above]] can return more than
|
||||
one snippet to be expanded at point.
|
||||
|
||||
When there are multiple candidates, YASnippet will let you select one.
|
||||
The UI for selecting multiple candidate can be customized through
|
||||
[[sym:yas-prompt-functions][=yas-prompt-functions=]] , which defines your preferred methods of being
|
||||
prompted for snippets.
|
||||
|
||||
You can customize it with
|
||||
=M-x customize-variable RET yas-prompt-functions RET=. Alternatively you
|
||||
can put in your emacs-file:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq yas-prompt-functions '(yas-x-prompt yas-dropdown-prompt))
|
||||
#+END_SRC
|
||||
|
||||
Currently there are some alternatives solution with YASnippet.
|
||||
|
||||
*** Use the X window system
|
||||
|
||||
[[./images/x-menu.png]]
|
||||
|
||||
The function [[sym:yas-x-prompt][=yas-x-prompt=]] can be used to show a popup menu for you to
|
||||
select. This menu will be part of you native window system widget, which
|
||||
means:
|
||||
|
||||
- It usually looks beautiful. E.g. when you compile Emacs with gtk
|
||||
support, this menu will be rendered with your gtk theme.
|
||||
- Your window system may or may not allow to you use =C-n=, =C-p= to
|
||||
navigate this menu.
|
||||
- This function can't be used when in a terminal.
|
||||
|
||||
*** Minibuffer prompting
|
||||
|
||||
[[./images/ido-menu.png]]
|
||||
|
||||
You can use functions [[sym:yas-completing-prompt][=yas-completing-prompt=]] for the classic emacs
|
||||
completion method or [[sym:yas-ido-prompt][=yas-ido-prompt=]] for a much nicer looking method.
|
||||
The best way is to try it. This works in a terminal.
|
||||
|
||||
*** Use =dropdown-menu.el=
|
||||
|
||||
[[./images/dropdown-menu.png]]
|
||||
|
||||
The function [[sym:yas-dropdown-prompt][=yas-dropdown-prompt=]] can also be placed in the
|
||||
[[sym:yas-prompt-functions][=yas-prompt-functions=]] list.
|
||||
|
||||
This works in both window system and terminal and is customizable, you
|
||||
can use =C-n=, =C-p= to navigate, =q= to quit and even press =6= as a
|
||||
shortcut to select the 6th candidate.
|
||||
|
||||
*** Roll your own
|
||||
|
||||
See the documentation on variable [[sym:yas-prompt-functions][=yas-prompt-functions=]]
|
@ -1,68 +0,0 @@
|
||||
#+SETUPFILE: org-setup.inc
|
||||
|
||||
#+TITLE: YASnippet menu
|
||||
|
||||
When [[sym:yas-minor-mode][=yas-minor-mode=]] is active, YASnippet will setup a menu just after
|
||||
the "Buffers" menu in the menubar.
|
||||
|
||||
In this menu, you can find
|
||||
|
||||
- The currently loaded snippet definitions, organized by major mode,
|
||||
and optional grouping.
|
||||
|
||||
- A rundown of the most common commands, (followed by their
|
||||
keybindings) including commands to load directories and reload all
|
||||
snippet definitions.
|
||||
|
||||
- A series of submenus for customizing and exploring YASnippet
|
||||
behavior.
|
||||
|
||||
[[./images/menu-1.png]]
|
||||
|
||||
* Loading snippets from menu
|
||||
|
||||
Invoking "Load snippets..." from the menu invokes [[sym:yas-load-directory][=yas-load-directory=]]
|
||||
and prompts you for a snippet directory hierarchy to load.
|
||||
|
||||
Also useful is the "Reload everything" item to invoke [[sym:yas-reload-all][=yas-reload-all=]]
|
||||
which uncondionally reloads all the snippets directories defined in
|
||||
[[sym:yas-snippet-dirs][=yas-snippet-dirs=]] and rebuilds the menus.
|
||||
|
||||
* Snippet menu behavior
|
||||
|
||||
YASnippet will list in this section all the loaded snippet definitions
|
||||
organized by snippet table name.
|
||||
|
||||
You can use this section to explore currently loaded snippets. If you
|
||||
click on one of them, the default behavior is to expand it,
|
||||
unconditionally, inside the current buffer.
|
||||
|
||||
You can however, customize variable [[sym:yas-visit-from-menu][=yas-visit-from-menu=]] to be =t=
|
||||
which will take you to the snippet definition file when you select it
|
||||
from the menu.
|
||||
|
||||
If you want the menu show only snippet tables whose name corresponds to
|
||||
a "real" major mode. You do this by setting [[sym:yas-use-menu][=yas-use-menu=]] to
|
||||
'=real-modes=.
|
||||
|
||||
Finally, to have the menu show only the tables for the currently active
|
||||
mode, set [[sym:yas-use-menu][=yas-use-menu=]] to =abbreviate=.
|
||||
|
||||
These customizations can also be found in the menu itself, under the
|
||||
"Snippet menu behavior" submenu.
|
||||
|
||||
* Controlling indenting
|
||||
|
||||
The "Indenting" submenu contains options to control the values of
|
||||
[[sym:yas-indent-line][=yas-indent-line=]] and [[sym:yas-also-auto-indent-first-line][=yas-also-auto-indent-first-line=]]. See
|
||||
[[./snippet-development.org][Writing snippets]].
|
||||
|
||||
* Prompting method
|
||||
|
||||
The "Prompting method" submenu contains options to control the value of
|
||||
[[sym:yas-prompt-functions][=yas-prompt-functions=]]. See [[./snippet-expansion.org][Expanding snippets]].
|
||||
|
||||
* Misc
|
||||
|
||||
The "Misc" submenu contains options to control the values of more
|
||||
variables.
|
@ -1,132 +0,0 @@
|
||||
#+SETUPFILE: org-setup.inc
|
||||
|
||||
#+TITLE: Organizing snippets
|
||||
|
||||
* Basic structure
|
||||
|
||||
Snippet collections can be stored in plain text files. They are
|
||||
arranged by sub-directories naming *snippet tables*. These mostly
|
||||
name Emacs major mode names.
|
||||
|
||||
#+begin_example
|
||||
.
|
||||
|-- c-mode
|
||||
| `-- printf
|
||||
|-- java-mode
|
||||
| `-- println
|
||||
`-- text-mode
|
||||
|-- email
|
||||
`-- time
|
||||
#+end_example
|
||||
|
||||
The collections are loaded into *snippet tables* which the
|
||||
triggering mechanism (see [[file:snippet-expansion.org][Expanding Snippets]]) looks up and
|
||||
(hopefully) causes the right snippet to be expanded for you.
|
||||
|
||||
* Setting up =yas-snippet-dirs=
|
||||
|
||||
The emacs variable [[sym:yas-snippet-dirs][=yas-snippet-dirs=]] tells YASnippet
|
||||
which collections to consider. It's used when you activate
|
||||
[[sym:yas-global-mode][=yas-global-mode=]] or call
|
||||
[[sym:yas-reload-all][=yas-reload-all=]] interactively.
|
||||
|
||||
The default considers:
|
||||
|
||||
- a personal collection that lives in =~/.emacs.d/snippets=
|
||||
- the bundled collection, taken as a relative path to =yasnippet.el= location
|
||||
|
||||
When you come across other snippet collections, do the following to try them
|
||||
out:
|
||||
|
||||
#+begin_src emacs-lisp :exports code
|
||||
;; Develop in ~/emacs.d/mysnippets, but also
|
||||
;; try out snippets in ~/Downloads/interesting-snippets
|
||||
(setq yas-snippet-dirs '("~/emacs.d/mysnippets"
|
||||
"~/Downloads/interesting-snippets"))
|
||||
|
||||
;; OR, keeping YASnippet defaults try out ~/Downloads/interesting-snippets
|
||||
(setq yas-snippet-dirs (append yas-snippet-dirs
|
||||
'("~/Downloads/interesting-snippets")))
|
||||
#+end_src
|
||||
|
||||
Collections appearing earlier in the list override snippets with same names
|
||||
appearing in collections later in the list. [[sym:yas-new-snippet][=yas-new-snippet=]] always stores
|
||||
snippets in the first collection.
|
||||
|
||||
* The =.yas-parents= file
|
||||
|
||||
It's very useful to have certain modes share snippets between
|
||||
themselves. To do this, choose a mode subdirectory and place a
|
||||
=.yas-parents= containing a whitespace-separated list of other mode
|
||||
names. When you reload those modes become parents of the original
|
||||
mode.
|
||||
|
||||
#+begin_example
|
||||
.
|
||||
|-- c-mode
|
||||
| |-- .yas-parents # contains "cc-mode text-mode"
|
||||
| `-- printf
|
||||
|-- cc-mode
|
||||
| |-- for
|
||||
| `-- while
|
||||
|-- java-mode
|
||||
| |-- .yas-parents # contains "cc-mode text-mode"
|
||||
| `-- println
|
||||
`-- text-mode
|
||||
|-- email
|
||||
`-- time
|
||||
#+end_example
|
||||
|
||||
|
||||
* TODO The =.yas-make-groups= file
|
||||
|
||||
If you place an empty plain text file =.yas-make-groups= inside one
|
||||
of the mode directories, the names of these sub-directories are
|
||||
considered groups of snippets and [[file:snippet-menu.org][the menu]] is organized much more
|
||||
cleanly:
|
||||
|
||||
[[./images/menu-groups.png]]
|
||||
|
||||
Another way to achieve this is to place a =# group:= directive
|
||||
inside the snippet definition. See [[./snippet-development.org][Writing Snippets]].
|
||||
|
||||
#+begin_example
|
||||
$ tree ruby-mode/
|
||||
ruby-mode/
|
||||
|-- .yas-make-groups
|
||||
|-- collections
|
||||
| |-- each
|
||||
| `-- ...
|
||||
|-- control structure
|
||||
| |-- forin
|
||||
| `-- ...
|
||||
|-- definitions
|
||||
| `-- ...
|
||||
`-- general
|
||||
`-- ...
|
||||
#+end_example
|
||||
|
||||
Yet another way to create a nice snippet menu is to write into
|
||||
=.yas-make-groups= a menu definition. TODO
|
||||
|
||||
* The =.yas-setup.el= file
|
||||
|
||||
If there is file named =.yas-setup.el= in a mode's snippet
|
||||
subdirectory, it is loaded along with the snippets. Utility
|
||||
functions used by the snippets can be put here.
|
||||
|
||||
* The =.yas-compiled-snippet.el= file
|
||||
|
||||
You may compile a top-level snippet directory with the
|
||||
=yas-compile-directory= function, which will create a
|
||||
=.yas-compiled-snippets.el= file under each mode subdirectory,
|
||||
which contains definitions for all snippets in the subdirectory.
|
||||
Compilation helps improve loading time.
|
||||
|
||||
Alternatively, you may compile all directories in the list
|
||||
=yas-snippet-dirs= with the =yas-recompile-all= function.
|
||||
|
||||
* The =.yas-skip= file
|
||||
|
||||
A =.yas-skip= file in a mode's snippet subdirectory tells YASnippet
|
||||
not to load snippets from there.
|
@ -1,12 +0,0 @@
|
||||
#+SETUPFILE: org-setup.inc
|
||||
|
||||
#+TITLE: Reference
|
||||
|
||||
#+BEGIN_SRC emacs-lisp :exports results :results value raw
|
||||
(yas--document-symbols 1 `("Interactive functions" . ,#'interactive-form)
|
||||
`("Customization variables" . ,#'(lambda (sym)
|
||||
(and (boundp sym)
|
||||
(get sym 'standard-value))))
|
||||
`("Useful functions" . ,#'fboundp)
|
||||
`("Useful variables" . ,#'boundp))
|
||||
#+END_SRC
|
@ -1,70 +0,0 @@
|
||||
.center { margin-left: auto; margin-right: auto; text-align: center; }
|
||||
.current {
|
||||
font-weight: bold;
|
||||
background-color: #E0E8F0;
|
||||
}
|
||||
|
||||
body { background-color: #E4F0F4 }
|
||||
div#content {
|
||||
max-width: 20cm;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
nav li {
|
||||
vertical-align: top;
|
||||
|
||||
display: inline;
|
||||
list-style-type: none;
|
||||
padding: 0.5em;
|
||||
}
|
||||
nav > ul > li {
|
||||
display: inline-block;
|
||||
}
|
||||
.nopad {
|
||||
padding: 0;
|
||||
}
|
||||
li.border {
|
||||
border: solid;
|
||||
border-width: 1px;
|
||||
}
|
||||
|
||||
pre, code{ background-color: #F3F5F7; }
|
||||
code {
|
||||
/* http://neugierig.org/software/chromium/notes/2009/09/monospace-fonts-workaround.html */
|
||||
font-family: WorkAroundWebKitAndMozilla, monospace;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Styles for htmlize.el fontification. */
|
||||
|
||||
.org-comment { color: #005000; } /* font-lock-comment-face */
|
||||
.org-keyword { font-weight: bold; } /* font-lock-keyword-face */
|
||||
.org-string { color: #8b0000; } /* font-lock-string-face */
|
||||
.org-warning { color: #ff8c00;
|
||||
font-weight: bold; } /* warning */
|
||||
.org-warning-1 { color: #ff0000;
|
||||
font-weight: bold; } /* font-lock-warning-face */
|
||||
.org-preprocessor { color: #483d8b; } /* font-lock-preprocessor-face */
|
||||
.org-constant { color: #008b8b; } /* font-lock-constant-face */
|
||||
.org-function-name { color: #0000ff; } /* font-lock-function-name-face */
|
||||
.org-type { color: #228b22; } /* font-lock-type-face */
|
||||
.org-variable-name { color: #a0522d; } /* font-lock-variable-name-face */
|
||||
|
||||
.org-rst-adornment { color: #a020f0; } /* rst-adornment */
|
||||
.org-rst-block { color: #a020f0; } /* rst-block */
|
||||
.org-rst-comment { color: #b22222; } /* rst-comment */
|
||||
.org-rst-definition { color: #0000ff; } /* rst-definition */
|
||||
.org-rst-directive { color: #483d8b; } /* rst-directive */
|
||||
.org-rst-emphasis1 { font-style: italic; } /* rst-emphasis1 */
|
||||
.org-rst-emphasis2 { font-weight: bold; } /* rst-emphasis2 */
|
||||
.org-rst-external { color: #228b22; } /* rst-external */
|
||||
.org-rst-level-1 { background-color: #d9d9d9; } /* rst-level-1 */
|
||||
.org-rst-level-2 { background-color: #c7c7c7; } /* rst-level-2 */
|
||||
.org-rst-level-3 { background-color: #b5b5b5; } /* rst-level-3 */
|
||||
.org-rst-level-4 { background-color: #a3a3a3; } /* rst-level-4 */
|
||||
.org-rst-level-5 { background-color: #919191; } /* rst-level-5 */
|
||||
.org-rst-level-6 { background-color: #7f7f7f; } /* rst-level-6 */
|
||||
.org-rst-literal { color: #8b2252; } /* rst-literal */
|
||||
.org-rst-reference { color: #a0522d; } /* rst-reference */
|
||||
.org-rst-transition { color: #a020f0; } /* rst-transition */
|
93
doc/stylesheets/styles.css
Normal file
93
doc/stylesheets/styles.css
Normal file
@ -0,0 +1,93 @@
|
||||
@media all
|
||||
{
|
||||
body {
|
||||
margin: 1em auto;
|
||||
/*margin: 10px 18% 10px 18%;*/
|
||||
font-family: Arial;
|
||||
/*text-align: justify;*/
|
||||
font-size: 14pt;
|
||||
padding: 10px;
|
||||
line-height: 1.2em;
|
||||
max-width: 600pt;
|
||||
}
|
||||
|
||||
div#table-of-contents {
|
||||
position: fixed;
|
||||
left: 0%;
|
||||
right: 0%;
|
||||
top: 0px;
|
||||
z-index: 100;
|
||||
background: black;
|
||||
}
|
||||
|
||||
div#table-of-contents h2 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div#table-of-contents a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
}
|
||||
|
||||
div#table-of-contents a:visited {
|
||||
color: white;
|
||||
}
|
||||
|
||||
div#table-of-contents a:hover {
|
||||
color: orange;
|
||||
}
|
||||
|
||||
div.outline-2 h2{
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
div#text-table-of-contents {
|
||||
text-color: white;
|
||||
text-align: center;
|
||||
margin-left: 30%;
|
||||
margin-right: 30%;
|
||||
}
|
||||
|
||||
div#text-table-of-contents ul {
|
||||
height: 2em;
|
||||
width: 500px;
|
||||
list-style: none;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
div#text-table-of-contents ul li {
|
||||
float: left;
|
||||
margin-left:auto;
|
||||
margin-right: auto;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
div#postamble{
|
||||
position: fixed;
|
||||
width: 800px;
|
||||
height: 250px;
|
||||
left: 50%;
|
||||
right: 50%;
|
||||
margin:-75px 0 0 -400px;
|
||||
bottom: -20px;
|
||||
font-size: 10pt;
|
||||
color: grey;
|
||||
background: url('siscog-bottom-logo.png') no-repeat;
|
||||
/* background-size: 100% 100%; */
|
||||
}
|
||||
|
||||
div#postamble *{
|
||||
display: none;
|
||||
}
|
||||
|
||||
div#postamble p.date{
|
||||
position: relative;
|
||||
bottom: -200px;
|
||||
text-align: center;
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
256
doc/yas-doc-helper.el
Normal file → Executable file
256
doc/yas-doc-helper.el
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
;;; yas-doc-helper.el --- Help generate documentation for YASnippet -*- lexical-binding: t; -*-
|
||||
;;; yas-doc-helper.el --- Help generate documentation for YASnippet
|
||||
|
||||
;; Copyright (C) 2012-2023 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2012 João Távora
|
||||
|
||||
;; Author: João Távora <joaotavora@gmail.com>
|
||||
;; Keywords: convenience
|
||||
@ -24,205 +24,79 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl-lib))
|
||||
(require 'org)
|
||||
(require 'ox-publish)
|
||||
(require 'yasnippet) ; docstrings must be loaded
|
||||
|
||||
;; Presumably one of org/ox-publish provided the following vars:
|
||||
(defvar org-publish-project-alist)
|
||||
(defvar org-publish-use-timestamps-flag)
|
||||
(defvar org-export-copy-to-kill-ring)
|
||||
(defvar org-html-htmlize-output-type)
|
||||
|
||||
(defun yas--org-raw-html (tag content &optional attrs)
|
||||
;; in version 8.0 org-mode changed the export syntax, see
|
||||
;; http://orgmode.org/worg/org-8.0.html#sec-8-1
|
||||
(format (if (version< org-version "8.0.0")
|
||||
"@<%s>%s@</%s>" ; old: @<tag>
|
||||
"@@html:<%s>@@%s@@html:</%s>@@") ; new: @@html:<tag>@@
|
||||
(concat tag (if attrs " ") attrs)
|
||||
content tag))
|
||||
|
||||
(defun yas--document-symbol (symbol level)
|
||||
(let* ((stars (make-string level ?*))
|
||||
(args (and (fboundp symbol)
|
||||
(mapcar #'symbol-name (help-function-arglist symbol t))))
|
||||
(heading (cond ((fboundp symbol)
|
||||
(format
|
||||
"%s %s (%s)\n" stars (yas--org-raw-html "code" symbol "class='function'")
|
||||
(mapconcat (lambda (a)
|
||||
(format (if (string-prefix-p "&" a)
|
||||
"/%s/" "=%s=")
|
||||
a))
|
||||
args " ")))
|
||||
(t
|
||||
(format "%s %s\n" stars
|
||||
(yas--org-raw-html "code" symbol "class='variable'")))))
|
||||
(after-heading (format ":PROPERTIES:\n:CUSTOM_ID: %s\n:END:" symbol))
|
||||
(text-quoting-style 'grave)
|
||||
(body (or (cond ((fboundp symbol)
|
||||
(let ((doc-synth (car-safe (get symbol 'function-documentation))))
|
||||
(if (functionp doc-synth)
|
||||
(funcall doc-synth nil)
|
||||
(documentation symbol t))))
|
||||
((boundp symbol)
|
||||
(documentation-property symbol 'variable-documentation t))
|
||||
(t
|
||||
(format "*WARNING*: no symbol named =%s=" symbol)))
|
||||
(format "*WARNING*: no doc for symbol =%s=" symbol)))
|
||||
(case-fold-search nil))
|
||||
;; Do some transformations on the body:
|
||||
;; ARGxxx becomes @<code>arg@</code>xxx
|
||||
;; FOO becomes /foo/
|
||||
;; `bar' becomes [[#bar][=bar=]]
|
||||
;; (...) becomes #+BEGIN_SRC elisp (...) #+END_SRC
|
||||
;; Info node `(some-manual) Node Name' becomes
|
||||
;; [[https://www.gnu.org/software/emacs/manual/html_node/some-manual/Node-Name.html]
|
||||
;; [(some-manual) Node Name]]
|
||||
;;
|
||||
;; This is fairly fragile, though it seems to be working for
|
||||
;; now...
|
||||
(setq body (replace-regexp-in-string
|
||||
"\\<\\([A-Z][-A-Z0-9]+\\)\\(\\sw+\\)?\\>"
|
||||
#'(lambda (match)
|
||||
(let* ((match1 (match-string 1 match))
|
||||
(prefix (downcase match1))
|
||||
(suffix (match-string 2 match))
|
||||
(fmt (cond
|
||||
((member prefix args)
|
||||
(yas--org-raw-html "code" "%s"))
|
||||
((null suffix) "/%s/"))))
|
||||
(if fmt (format fmt prefix)
|
||||
match1)))
|
||||
body t t 1)
|
||||
body (replace-regexp-in-string
|
||||
"\\\\{[^}]+}"
|
||||
(lambda (match)
|
||||
(concat "#+BEGIN_EXAMPLE\n"
|
||||
(substitute-command-keys match)
|
||||
"#+END_EXAMPLE\n"))
|
||||
body t t)
|
||||
body (substitute-command-keys body)
|
||||
body (replace-regexp-in-string
|
||||
"Info node `(\\([-a-z]+\\)) \\([A-Za-z0-9 ]+\\)'"
|
||||
(lambda (match)
|
||||
(let* ((manual (match-string 1 match))
|
||||
(node (match-string 2 match))
|
||||
(html-node (replace-regexp-in-string " " "-" node t t)))
|
||||
(format "Info node\
|
||||
[[https://www.gnu.org/software/emacs/manual/html_node/%s/%s.html][(%s) %s]]"
|
||||
manual html-node manual node)))
|
||||
body t t)
|
||||
body (replace-regexp-in-string
|
||||
"`\\([-a-z]+\\)'"
|
||||
#'(lambda (match)
|
||||
(let* ((name (downcase (match-string 1 match)))
|
||||
(sym (intern-soft name)))
|
||||
(if (memq sym yas--exported-syms)
|
||||
(format "[[#%s][=%s=]]" name name)
|
||||
(format "=%s=" name))))
|
||||
body t t)
|
||||
body (replace-regexp-in-string
|
||||
"\n\n +(.+\\(?:\n +.+\\)*"
|
||||
(lambda (match)
|
||||
(concat "\n#+BEGIN_SRC elisp\n"
|
||||
match
|
||||
"\n#+END_SRC\n"))
|
||||
body t t))
|
||||
;; output the paragraph
|
||||
(concat heading after-heading "\n" body)))
|
||||
(flet ((concat-lines (&rest lines)
|
||||
(mapconcat #'identity lines "\n")))
|
||||
(let* ((stars (make-string level ?*))
|
||||
(heading (cond ((fboundp symbol)
|
||||
(format "%s =%s= (%s)"
|
||||
stars
|
||||
symbol
|
||||
(mapconcat #'symbol-name
|
||||
(help-function-arglist symbol t) " ")))
|
||||
(t
|
||||
(format "%s =%s=\n" stars symbol))))
|
||||
(after-heading
|
||||
(concat-lines ":PROPERTIES:"
|
||||
(format ":CUSTOM_ID: %s" symbol)
|
||||
":END:"))
|
||||
(body (or (cond ((boundp symbol)
|
||||
(documentation-property symbol 'variable-documentation t))
|
||||
((fboundp symbol)
|
||||
(documentation-property symbol 'function-documentation t))
|
||||
(t
|
||||
(format "*WARNING*: no symbol named =%s=" symbol)))
|
||||
(format "*WARNING*: no doc for symbol =%s=" symbol)))
|
||||
(case-fold-search nil))
|
||||
;; do some transformations on the body: FOO becomes /foo/ and
|
||||
;; `bar' becomes [[#bar][=bar=]]
|
||||
(setq body (replace-regexp-in-string
|
||||
"[A-Z][A-Z-]+" #'(lambda (match)
|
||||
(format "/%s/" (downcase match)))
|
||||
body)
|
||||
body (replace-regexp-in-string "`\\([a-z-]+\\)'" #'(lambda (match)
|
||||
(let* ((name (downcase (match-string 1 match)))
|
||||
(sym (intern name)))
|
||||
(if (and (or (boundp sym)
|
||||
(fboundp sym))
|
||||
(save-match-data
|
||||
(string-match "^yas-" name)))
|
||||
(format "[[#%s][=%s=]]"
|
||||
name name)
|
||||
(format "=%s=" name))))
|
||||
body))
|
||||
;; output the paragraph
|
||||
;;
|
||||
(concat-lines heading
|
||||
after-heading
|
||||
body))))
|
||||
|
||||
(defun yas--document-symbols (level &rest names-and-predicates)
|
||||
(let ((sym-lists (make-vector (length names-and-predicates) nil))
|
||||
(stars (make-string level ?*)))
|
||||
(cl-loop for sym in yas--exported-syms
|
||||
do (cl-loop for test in (mapcar #'cdr names-and-predicates)
|
||||
for i from 0
|
||||
do (when (funcall test sym)
|
||||
(push sym (aref sym-lists i))
|
||||
(cl-return))))
|
||||
(cl-loop for slist across sym-lists
|
||||
for name in (mapcar #'car names-and-predicates)
|
||||
concat (format "\n%s %s\n" stars name)
|
||||
concat (mapconcat (lambda (sym)
|
||||
(yas--document-symbol sym (1+ level)))
|
||||
slist "\n\n"))))
|
||||
(let ((sym-lists (make-vector (length names-and-predicates) (list)))
|
||||
(retval ""))
|
||||
(loop for sym in yas--exported-syms
|
||||
do (loop for test in (mapcar #'cdr names-and-predicates)
|
||||
for i from 0
|
||||
do (when (funcall test sym)
|
||||
(push sym (aref sym-lists i))
|
||||
(return))))
|
||||
(loop for slist across sym-lists
|
||||
for name in (mapcar #'car names-and-predicates)
|
||||
do (progn
|
||||
(setq retval
|
||||
(concat retval
|
||||
(format "\n** %s\n" name)
|
||||
(mapconcat #'yas--document-symbol slist "\n\n")))))
|
||||
retval))
|
||||
|
||||
(defun yas--internal-link-snippet ()
|
||||
(interactive)
|
||||
(yas-expand-snippet "[[#$1][=${1:`yas/selected-text`}=]]"))
|
||||
|
||||
(define-key org-mode-map [M-f8] #'yas--internal-link-snippet)
|
||||
|
||||
;; This lets all the org files be exported to HTML with
|
||||
;; `org-publish-current-project' (C-c C-e P).
|
||||
|
||||
(defun yas--make-preamble (props)
|
||||
"Return contents of nav-menu-html.inc.
|
||||
But replace link to \"current\" page with a span element."
|
||||
(with-temp-buffer
|
||||
(let ((dir (file-name-directory (plist-get props :input-file))))
|
||||
(insert-file-contents (expand-file-name "nav-menu.html.inc" dir))
|
||||
(goto-char (point-min))
|
||||
(search-forward (concat "<a href=\""
|
||||
(file-name-nondirectory
|
||||
(plist-get props :output-file))
|
||||
"\">"))
|
||||
(replace-match "<span class='current'>")
|
||||
(search-forward "</a>")
|
||||
(replace-match "</span>")
|
||||
(buffer-string))))
|
||||
|
||||
(let* ((dir (if load-file-name (file-name-directory load-file-name)
|
||||
default-directory))
|
||||
(src-epoch (getenv "SOURCE_DATE_EPOCH"))
|
||||
;; Presence of SOURCE_DATE_EPOCH indicates a reproducible
|
||||
;; build, don't depend on git.
|
||||
(rev (unless src-epoch
|
||||
(ignore-errors
|
||||
(car (process-lines "git" "describe" "--dirty")))))
|
||||
(date (format-time-string
|
||||
"(%Y-%m-%d %H:%M:%S)"
|
||||
(seconds-to-time
|
||||
(string-to-number
|
||||
(or (if rev (car (process-lines "git" "show" "--format=%ct"))
|
||||
src-epoch)
|
||||
"0")))
|
||||
t))
|
||||
(proj-plist
|
||||
`(,@(when (fboundp 'org-html-publish-to-html)
|
||||
'(:publishing-function org-html-publish-to-html))
|
||||
:base-directory ,dir :publishing-directory ,dir
|
||||
:html-preamble yas--make-preamble
|
||||
;;:with-broken-links mark
|
||||
:html-postamble
|
||||
,(concat "<hr><p class='creator'>Generated by %c from "
|
||||
rev " " date "</p>\n"
|
||||
"<p class='xhtml-validation'>%v</p>\n")))
|
||||
(project (assoc "yasnippet" org-publish-project-alist)))
|
||||
(when rev ;; Rakefile :doc:upload uses "html-revision".
|
||||
(with-temp-file (expand-file-name "html-revision" dir)
|
||||
(princ rev (current-buffer))))
|
||||
(if project
|
||||
(setcdr project proj-plist)
|
||||
(push `("yasnippet" . ,proj-plist)
|
||||
org-publish-project-alist)))
|
||||
|
||||
(defun yas--generate-html-batch ()
|
||||
(let ((org-publish-use-timestamps-flag nil)
|
||||
(org-export-copy-to-kill-ring nil)
|
||||
(org-confirm-babel-evaluate nil)
|
||||
(make-backup-files nil)
|
||||
(org-html-htmlize-output-type 'css))
|
||||
(org-publish "yasnippet" 'force)))
|
||||
|
||||
|
||||
(define-key org-mode-map [M-f8] 'yas--internal-link-snippet)
|
||||
|
||||
(provide 'yas-doc-helper)
|
||||
;;; yas-doc-helper.el ends here
|
||||
;; Local Variables:
|
||||
;; indent-tabs-mode: nil
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
;;; yas-doc-helper.el ends here
|
||||
|
253
dropdown-list.el
Normal file
253
dropdown-list.el
Normal file
@ -0,0 +1,253 @@
|
||||
;;; dropdown-list.el --- Drop-down menu interface
|
||||
;;
|
||||
;; Filename: dropdown-list.el
|
||||
;; Description: Drop-down menu interface
|
||||
;; Copyright (C) 2008-2012 Free Software Foundation, Inc.
|
||||
;; Author: Jaeyoun Chung [jay.chung@gmail.com]
|
||||
;; Maintainer:
|
||||
;; Authors: pluskid <pluskid@gmail.com>, João Távora <joaotavora@gmail.com>
|
||||
;; Created: Sun Mar 16 11:20:45 2008 (Pacific Daylight Time)
|
||||
;; Version:
|
||||
;; Last-Updated: Sun Mar 16 12:19:49 2008 (Pacific Daylight Time)
|
||||
;; By: dradams
|
||||
;; Update #: 43
|
||||
;; URL: http://www.emacswiki.org/cgi-bin/wiki/dropdown-list.el
|
||||
;; Keywords: convenience menu
|
||||
;; Compatibility: GNU Emacs 21.x, GNU Emacs 22.x
|
||||
;;
|
||||
;; Features that might be required by this library:
|
||||
;;
|
||||
;; `cl'.
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; According to Jaeyoun Chung, "overlay code stolen from company-mode.el."
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Change log:
|
||||
;;
|
||||
;; 2008/03/16 dadams
|
||||
;; Clean-up - e.g. use char-to-string for control chars removed by email posting.
|
||||
;; Moved example usage code (define-key*, command-selector) inside the library.
|
||||
;; Require cl.el at byte-compile time.
|
||||
;; Added GPL statement.
|
||||
;; 2008/01/06 Jaeyoun Chung
|
||||
;; Posted to gnu-emacs-sources@gnu.org at 9:10 p.m.
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; This program is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile (require 'cl)) ;; decf, fourth, incf, loop, mapcar*
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defface dropdown-list-face
|
||||
'((t :inherit default :background "lightyellow" :foreground "black"))
|
||||
"*Bla." :group 'dropdown-list)
|
||||
|
||||
(defface dropdown-list-selection-face
|
||||
'((t :inherit dropdown-list-face :background "purple"))
|
||||
"*Bla." :group 'dropdown-list)
|
||||
|
||||
(defvar dropdown-list-overlays nil)
|
||||
|
||||
(defun dropdown-list-hide ()
|
||||
(while dropdown-list-overlays
|
||||
(delete-overlay (pop dropdown-list-overlays))))
|
||||
|
||||
(defun dropdown-list-put-overlay (beg end &optional prop value prop2 value2)
|
||||
(let ((ov (make-overlay beg end)))
|
||||
(overlay-put ov 'window t)
|
||||
(when prop
|
||||
(overlay-put ov prop value)
|
||||
(when prop2 (overlay-put ov prop2 value2)))
|
||||
ov))
|
||||
|
||||
(defun dropdown-list-line (start replacement &optional no-insert)
|
||||
;; start might be in the middle of a tab, which means we need to hide the
|
||||
;; tab and add spaces
|
||||
(let ((end (+ start (length replacement)))
|
||||
beg-point end-point
|
||||
before-string after-string)
|
||||
(goto-char (point-at-eol))
|
||||
(if (< (current-column) start)
|
||||
(progn (setq before-string (make-string (- start (current-column)) ? ))
|
||||
(setq beg-point (point)))
|
||||
(goto-char (point-at-bol)) ;; Emacs bug, move-to-column is wrong otherwise
|
||||
(move-to-column start)
|
||||
(setq beg-point (point))
|
||||
(when (> (current-column) start)
|
||||
(goto-char (1- (point)))
|
||||
(setq beg-point (point))
|
||||
(setq before-string (make-string (- start (current-column)) ? ))))
|
||||
(move-to-column end)
|
||||
(setq end-point (point))
|
||||
(let ((end-offset (- (current-column) end)))
|
||||
(when (> end-offset 0) (setq after-string (make-string end-offset ?b))))
|
||||
(when no-insert
|
||||
;; prevent inheriting of faces
|
||||
(setq before-string (when before-string (propertize before-string 'face 'default)))
|
||||
(setq after-string (when after-string (propertize after-string 'face 'default))))
|
||||
(let ((string (concat before-string replacement after-string)))
|
||||
(if no-insert
|
||||
string
|
||||
(push (dropdown-list-put-overlay beg-point end-point 'invisible t
|
||||
'after-string string)
|
||||
dropdown-list-overlays)))))
|
||||
|
||||
(defun dropdown-list-start-column (display-width)
|
||||
(let ((column (mod (current-column) (window-width)))
|
||||
(width (window-width)))
|
||||
(cond ((<= (+ column display-width) width) column)
|
||||
((> column display-width) (- column display-width))
|
||||
((>= width display-width) (- width display-width))
|
||||
(t nil))))
|
||||
|
||||
(defun dropdown-list-move-to-start-line (candidate-count)
|
||||
(decf candidate-count)
|
||||
(let ((above-line-count (save-excursion (- (vertical-motion (- candidate-count)))))
|
||||
(below-line-count (save-excursion (vertical-motion candidate-count))))
|
||||
(cond ((= below-line-count candidate-count)
|
||||
t)
|
||||
((= above-line-count candidate-count)
|
||||
(vertical-motion (- candidate-count))
|
||||
t)
|
||||
((>= (+ below-line-count above-line-count) candidate-count)
|
||||
(vertical-motion (- (- candidate-count below-line-count)))
|
||||
t)
|
||||
(t nil))))
|
||||
|
||||
(defun dropdown-list-at-point (candidates &optional selidx)
|
||||
(dropdown-list-hide)
|
||||
(let* ((lengths (mapcar #'length candidates))
|
||||
(max-length (apply #'max lengths))
|
||||
(start (dropdown-list-start-column (+ max-length 3)))
|
||||
(i -1)
|
||||
(candidates (mapcar* (lambda (candidate length)
|
||||
(let ((diff (- max-length length)))
|
||||
(propertize
|
||||
(concat (if (> diff 0)
|
||||
(concat candidate (make-string diff ? ))
|
||||
(substring candidate 0 max-length))
|
||||
(format "%3d" (+ 2 i)))
|
||||
'face (if (eql (incf i) selidx)
|
||||
'dropdown-list-selection-face
|
||||
'dropdown-list-face))))
|
||||
candidates
|
||||
lengths)))
|
||||
(save-excursion
|
||||
(and start
|
||||
(dropdown-list-move-to-start-line (length candidates))
|
||||
(loop initially (vertical-motion 0)
|
||||
for candidate in candidates
|
||||
do (dropdown-list-line (+ (current-column) start) candidate)
|
||||
while (/= (vertical-motion 1) 0)
|
||||
finally return t)))))
|
||||
|
||||
(defun dropdown-list (candidates)
|
||||
(let ((selection)
|
||||
(temp-buffer))
|
||||
(save-window-excursion
|
||||
(unwind-protect
|
||||
(let ((candidate-count (length candidates))
|
||||
done key (selidx 0))
|
||||
(while (not done)
|
||||
(unless (dropdown-list-at-point candidates selidx)
|
||||
(switch-to-buffer (setq temp-buffer (get-buffer-create "*selection*"))
|
||||
'norecord)
|
||||
(delete-other-windows)
|
||||
(delete-region (point-min) (point-max))
|
||||
(insert (make-string (length candidates) ?\n))
|
||||
(goto-char (point-min))
|
||||
(dropdown-list-at-point candidates selidx))
|
||||
(setq key (read-key-sequence ""))
|
||||
(cond ((and (stringp key)
|
||||
(>= (aref key 0) ?1)
|
||||
(<= (aref key 0) (+ ?0 (min 9 candidate-count))))
|
||||
(setq selection (- (aref key 0) ?1)
|
||||
done t))
|
||||
((member key `(,(char-to-string ?\C-p) [up] "p"))
|
||||
(setq selidx (mod (+ candidate-count (1- (or selidx 0)))
|
||||
candidate-count)))
|
||||
((member key `(,(char-to-string ?\C-n) [down] "n"))
|
||||
(setq selidx (mod (1+ (or selidx -1)) candidate-count)))
|
||||
((member key `(,(char-to-string ?\f))))
|
||||
((member key `(,(char-to-string ?\r) [return]))
|
||||
(setq selection selidx
|
||||
done t))
|
||||
(t (setq done t)))))
|
||||
(dropdown-list-hide)
|
||||
(and temp-buffer (kill-buffer temp-buffer)))
|
||||
;; (when selection
|
||||
;; (message "your selection => %d: %s" selection (nth selection candidates))
|
||||
;; (sit-for 1))
|
||||
selection)))
|
||||
|
||||
(defun define-key* (keymap key command)
|
||||
"Add COMMAND to the multiple-command binding of KEY in KEYMAP.
|
||||
Use multiple times to bind different COMMANDs to the same KEY."
|
||||
(define-key keymap key (combine-command command (lookup-key keymap key))))
|
||||
|
||||
(defun combine-command (command defs)
|
||||
"$$$$$ FIXME - no doc string"
|
||||
(cond ((null defs) command)
|
||||
((and (listp defs)
|
||||
(eq 'lambda (car defs))
|
||||
(= (length defs) 4)
|
||||
(listp (fourth defs))
|
||||
(eq 'command-selector (car (fourth defs))))
|
||||
(unless (member `',command (cdr (fourth defs)))
|
||||
(setcdr (fourth defs) (nconc (cdr (fourth defs)) `(',command))))
|
||||
defs)
|
||||
(t
|
||||
`(lambda () (interactive) (command-selector ',defs ',command)))))
|
||||
|
||||
(defvar command-selector-last-command nil "$$$$$ FIXME - no doc string")
|
||||
|
||||
(defun command-selector (&rest candidates)
|
||||
"$$$$$ FIXME - no doc string"
|
||||
(if (and (eq last-command this-command) command-selector-last-command)
|
||||
(call-interactively command-selector-last-command)
|
||||
(let* ((candidate-strings
|
||||
(mapcar (lambda (candidate)
|
||||
(format "%s" (if (symbolp candidate)
|
||||
candidate
|
||||
(let ((s (format "%s" candidate)))
|
||||
(if (>= (length s) 7)
|
||||
(concat (substring s 0 7) "...")
|
||||
s)))))
|
||||
candidates))
|
||||
(selection (dropdown-list candidate-strings)))
|
||||
(when selection
|
||||
(let ((cmd (nth selection candidates)))
|
||||
(call-interactively cmd)
|
||||
(setq command-selector-last-command cmd))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(provide 'dropdown-list)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; dropdown-list.el ends here
|
||||
;; Local Variables:
|
||||
;; coding: utf-8
|
||||
;; End:
|
1
extras/bundles/html-tmbundle
Submodule
1
extras/bundles/html-tmbundle
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 0bab270103ce27ebd896f80ba303859c549ad3c5
|
1
extras/bundles/rails-tmbundle
Submodule
1
extras/bundles/rails-tmbundle
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 683f6e652cc467e0007f80aa11f174a4d9189f3c
|
1
extras/bundles/ruby-tmbundle
Submodule
1
extras/bundles/ruby-tmbundle
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 74683ecbb353bd39bb942a6f9c82026f82696cd6
|
690
extras/imported/html-mode/.yas-setup.el
Normal file
690
extras/imported/html-mode/.yas-setup.el
Normal file
@ -0,0 +1,690 @@
|
||||
;; .yas-setup.el for html-mode
|
||||
|
||||
(defvar yas-html-default-tag "p")
|
||||
|
||||
(defvar yas-html-xhtml-attr "")
|
||||
|
||||
(defvar yas-html-just-like-tm nil
|
||||
"Html-mode snippets behave as close to TextMate as possible.")
|
||||
|
||||
(defun yas-html-activate ()
|
||||
(add-to-list (make-local-variable 'yas-mode-symbol) 'html-mode))
|
||||
|
||||
(add-hook 'nxml-mode-hook 'yas-html-activate)
|
||||
(add-hook 'rhtml-mode-hook 'yas-html-activate)
|
||||
|
||||
(defun yas-html-remove-preceding-word ()
|
||||
(interactive)
|
||||
(let (word-begin
|
||||
word-end
|
||||
(line-beginning-position (line-beginning-position))
|
||||
(orig-point (point))
|
||||
retval)
|
||||
(save-excursion
|
||||
(when (and (forward-word -1)
|
||||
(setq word-begin (point))
|
||||
(forward-word 1)
|
||||
(setq word-end (point))
|
||||
(< word-begin orig-point)
|
||||
(>= word-end orig-point)
|
||||
(<= (line-beginning-position) word-begin)
|
||||
;; (not (string-match "^[\s\t]+$" " "))
|
||||
)
|
||||
(setq retval
|
||||
(cons
|
||||
(buffer-substring-no-properties word-begin orig-point)
|
||||
(buffer-substring-no-properties word-end orig-point)))
|
||||
(delete-region word-begin word-end)
|
||||
retval))))
|
||||
|
||||
|
||||
(defun yas-html-first-word (string)
|
||||
(replace-regexp-in-string "\\\W.*" "" string))
|
||||
|
||||
(defun yas-html-insert-tag-pair-snippet ()
|
||||
(let* ((tag-and-suffix (or (and yas-selected-text
|
||||
(cons yas-selected-text nil))
|
||||
(yas-html-remove-preceding-word)))
|
||||
(tag (car tag-and-suffix))
|
||||
(suffix (or (cdr tag-and-suffix) ""))
|
||||
(single-no-arg "\\(br\\|hr\\)")
|
||||
(single "\\(img\\|meta\\|link\\|input\\|base\\|area\\|col\\|frame\\|param\\)"))
|
||||
(cond ((null tag)
|
||||
(yas-expand-snippet (format "<${1:%s}>%s</${1:$(yas-html-first-word yas-text)}>%s"
|
||||
(or yas-html-default-tag
|
||||
"p")
|
||||
(if yas-html-just-like-tm "$2" "$0")
|
||||
suffix)))
|
||||
((string-match single-no-arg tag)
|
||||
(insert (format "<%s%s/>%s" tag yas-html-xhtml-attr suffix)))
|
||||
((string-match single tag)
|
||||
(yas-expand-snippet (format "<%s $1%s/>%s" tag yas-html-xhtml-attr suffix)))
|
||||
(t
|
||||
(yas-expand-snippet (format "<%s>%s</%s>%s"
|
||||
tag
|
||||
(if yas-html-just-like-tm "$1" "$0")
|
||||
(replace-regexp-in-string "\\\W.*" "" tag)
|
||||
suffix))))))
|
||||
|
||||
(defun yas-html-wrap-each-line-in-openclose-tag ()
|
||||
(let* ((mirror "${1:$(yas-html-first-word yas-text)}")
|
||||
(yas-html-wrap-newline (when (string-match "\n" yas-selected-text) "\n"))
|
||||
(template (concat (format "<${1:%s}>" (or yas-html-default-tag "p"))
|
||||
yas-selected-text
|
||||
"</" mirror ">")))
|
||||
(setq template (replace-regexp-in-string "\n" (concat "</" mirror ">\n<$1>") template))
|
||||
(yas-expand-snippet template)))
|
||||
|
||||
(defun yas-html-toggle-wrap (string wrap)
|
||||
(or (and string
|
||||
(string-match (format "<%s>\\(.*\\)</%s>" wrap wrap)
|
||||
string)
|
||||
(match-string 1 string))
|
||||
(concat wrap string wrap)))
|
||||
|
||||
(defun yas-html-between-tag-pair-p ()
|
||||
(save-excursion
|
||||
(backward-word)
|
||||
(looking-at "\\\w+></\\\w+>")))
|
||||
|
||||
(defun yas-html-id-from-string (string)
|
||||
(replace-regexp-in-string " " "_" (downcase string)))
|
||||
|
||||
(defun yas-html-tidy ()
|
||||
(interactive)
|
||||
(let ((start (or (and mark-active
|
||||
(region-beginning))
|
||||
(point-min)))
|
||||
(end (or (and mark-active
|
||||
(region-end))
|
||||
(point-max)))
|
||||
(orig (point))
|
||||
(orig-line (count-screen-lines (window-start) (line-beginning-position))))
|
||||
(shell-command-on-region start end "tidy" (current-buffer) t (get-buffer-create "*tidy errors*") t)
|
||||
(goto-char (min (point-max) orig))
|
||||
(recenter (1- orig-line))))
|
||||
|
||||
(defun yas-html-tag-description ()
|
||||
(interactive)
|
||||
(let* ((tag-at-point (sgml-beginning-of-tag))
|
||||
(fragment (and tag-at-point
|
||||
(cdr (assoc (upcase tag-at-point) yas-html-tag-description-urls)))))
|
||||
(if fragment
|
||||
(browse-url (concat "http://www.w3.org/TR/html4/index/"
|
||||
fragment))
|
||||
(if tag-at-point
|
||||
(message "No documentation for " tag-at-point)
|
||||
(message "Not on a HTML tag.")))))
|
||||
|
||||
(defvar yas-html-tag-description-urls
|
||||
'(("A" . "../struct/links.html#edef-A")
|
||||
("ABBR" . "../struct/text.html#edef-ABBR")
|
||||
("ACRONYM" . "../struct/text.html#edef-ACRONYM")
|
||||
("ADDRESS" . "../struct/global.html#edef-ADDRESS")
|
||||
("APPLET" . "../struct/objects.html#edef-APPLET")
|
||||
("AREA" . "../struct/objects.html#edef-AREA")
|
||||
("B" . "../present/graphics.html#edef-B")
|
||||
("BASE" . "../struct/links.html#edef-BASE")
|
||||
("BASEFONT" . "../present/graphics.html#edef-BASEFONT")
|
||||
("BDO" . "../struct/dirlang.html#edef-BDO")
|
||||
("BIG" . "../present/graphics.html#edef-BIG")
|
||||
("BLOCKQUOTE" . "../struct/text.html#edef-BLOCKQUOTE")
|
||||
("BODY" . "../struct/global.html#edef-BODY")
|
||||
("BR" . "../struct/text.html#edef-BR")
|
||||
("BUTTON" . "../interact/forms.html#edef-BUTTON")
|
||||
("CAPTION" . "../struct/tables.html#edef-CAPTION")
|
||||
("CENTER" . "../present/graphics.html#edef-CENTER")
|
||||
("CITE" . "../struct/text.html#edef-CITE")
|
||||
("CODE" . "../struct/text.html#edef-CODE")
|
||||
("COL" . "../struct/tables.html#edef-COL")
|
||||
("COLGROUP" . "../struct/tables.html#edef-COLGROUP")
|
||||
("DD" . "../struct/lists.html#edef-DD")
|
||||
("DEL" . "../struct/text.html#edef-del")
|
||||
("DFN" . "../struct/text.html#edef-DFN")
|
||||
("DIR" . "../struct/lists.html#edef-DIR")
|
||||
("DIV" . "../struct/global.html#edef-DIV")
|
||||
("DL" . "../struct/lists.html#edef-DL")
|
||||
("DT" . "../struct/lists.html#edef-DT")
|
||||
("EM" . "../struct/text.html#edef-EM")
|
||||
("FIELDSET" . "../interact/forms.html#edef-FIELDSET")
|
||||
("FONT" . "../present/graphics.html#edef-FONT")
|
||||
("FORM" . "../interact/forms.html#edef-FORM")
|
||||
("FRAME" . "../present/frames.html#edef-FRAME")
|
||||
("FRAMESET" . "../present/frames.html#edef-FRAMESET")
|
||||
("H1" . "../struct/global.html#edef-H1")
|
||||
("H2" . "../struct/global.html#edef-H2")
|
||||
("H3" . "../struct/global.html#edef-H3")
|
||||
("H4" . "../struct/global.html#edef-H4")
|
||||
("H5" . "../struct/global.html#edef-H5")
|
||||
("H6" . "../struct/global.html#edef-H6")
|
||||
("HEAD" . "../struct/global.html#edef-HEAD")
|
||||
("HR" . "../present/graphics.html#edef-HR")
|
||||
("HTML" . "../struct/global.html#edef-HTML")
|
||||
("I" . "../present/graphics.html#edef-I")
|
||||
("IFRAME" . "../present/frames.html#edef-IFRAME")
|
||||
("IMG" . "../struct/objects.html#edef-IMG")
|
||||
("INPUT" . "../interact/forms.html#edef-INPUT")
|
||||
("INS" . "../struct/text.html#edef-ins")
|
||||
("ISINDEX" . "../interact/forms.html#edef-ISINDEX")
|
||||
("KBD" . "../struct/text.html#edef-KBD")
|
||||
("LABEL" . "../interact/forms.html#edef-LABEL")
|
||||
("LEGEND" . "../interact/forms.html#edef-LEGEND")
|
||||
("LI" . "../struct/lists.html#edef-LI")
|
||||
("LINK" . "../struct/links.html#edef-LINK")
|
||||
("MAP" . "../struct/objects.html#edef-MAP")
|
||||
("MENU" . "../struct/lists.html#edef-MENU")
|
||||
("META" . "../struct/global.html#edef-META")
|
||||
("NOFRAMES" . "../present/frames.html#edef-NOFRAMES")
|
||||
("NOSCRIPT" . "../interact/scripts.html#edef-NOSCRIPT")
|
||||
("OBJECT" . "../struct/objects.html#edef-OBJECT")
|
||||
("OL" . "../struct/lists.html#edef-OL")
|
||||
("OPTGROUP" . "../interact/forms.html#edef-OPTGROUP")
|
||||
("OPTION" . "../interact/forms.html#edef-OPTION")
|
||||
("P" . "../struct/text.html#edef-P")
|
||||
("PARAM" . "../struct/objects.html#edef-PARAM")
|
||||
("PRE" . "../struct/text.html#edef-PRE")
|
||||
("Q" . "../struct/text.html#edef-Q")
|
||||
("S" . "../present/graphics.html#edef-S")
|
||||
("SAMP" . "../struct/text.html#edef-SAMP")
|
||||
("SCRIPT" . "../interact/scripts.html#edef-SCRIPT")
|
||||
("SELECT" . "../interact/forms.html#edef-SELECT")
|
||||
("SMALL" . "../present/graphics.html#edef-SMALL")
|
||||
("SPAN" . "../struct/global.html#edef-SPAN")
|
||||
("STRIKE" . "../present/graphics.html#edef-STRIKE")
|
||||
("STRONG" . "../struct/text.html#edef-STRONG")
|
||||
("STYLE" . "../present/styles.html#edef-STYLE")
|
||||
("SUB" . "../struct/text.html#edef-SUB")
|
||||
("SUP" . "../struct/text.html#edef-SUP")
|
||||
("TABLE" . "../struct/tables.html#edef-TABLE")
|
||||
("TBODY" . "../struct/tables.html#edef-TBODY")
|
||||
("TD" . "../struct/tables.html#edef-TD")
|
||||
("TEXTAREA" . "../interact/forms.html#edef-TEXTAREA")
|
||||
("TFOOT" . "../struct/tables.html#edef-TFOOT")
|
||||
("TH" . "../struct/tables.html#edef-TH")
|
||||
("THEAD" . "../struct/tables.html#edef-THEAD")
|
||||
("TITLE" . "../struct/global.html#edef-TITLE")
|
||||
("TR" . "../struct/tables.html#edef-TR")
|
||||
("TT" . "../present/graphics.html#edef-TT")
|
||||
("U" . "../present/graphics.html#edef-U")
|
||||
("UL" . "../struct/lists.html#edef-UL")
|
||||
("VAR" . "../struct/text.html#edef-VAR")))
|
||||
|
||||
;;
|
||||
;;
|
||||
;; Substitutions for: content
|
||||
;; # as in Snippets/Emphasize.yasnippet
|
||||
;; ${TM_SELECTED_TEXT/\A<em>(.*)<\/em>\z|.*/(?1:$1:<em>$0<\/em>)/m} =yyas> `(yas-html-toggle-wrap yas-selected-text "em")`
|
||||
;; ${TM_SELECTED_TEXT/\A<strong>(.*)<\/strong>\z|.*/(?1:$1:<strong>$0<\/strong>)/m} =yyas> `(yas-html-toggle-wrap yas-selected-text "strong")`
|
||||
;; ${1/\s.*//} =yyas> ${1:$(replace-regexp-in-string "[\s\t\n].*" "" yas-text)}
|
||||
;; ${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g} =yyas> ${1:$(replace-regexp-in-string " " "_" (downcase yas-text))}
|
||||
;; ${TM_XHTML} =yyas> `yas-html-xhtml-attr`
|
||||
|
||||
|
||||
;; # as in Commands/Preview in All Active Browsers.yasnippet
|
||||
;; 970EE6B4-A091-11D9-A5A2-000D93C8BE28 =yyas> (browse-url-of-buffer)
|
||||
;; 637CEA2B-578C-429C-BB74-30E8D42BFA22 =yyas> (yas-html-tag-description)
|
||||
;; 2ED44A32-C353-447F-BAE4-E3522DB6944D =yyas> (yas-html-insert-tag-pair-snippet)
|
||||
;; 991E7EBD-F3F5-469A-BA01-DC30E04AD472 =yyas> (yas-html-wrap-each-line-in-openclose-tag)
|
||||
|
||||
;; Substitutions for: binding
|
||||
;;
|
||||
;; # as in Snippets/Strong.yasnippet
|
||||
;; @b =yyas> s-b
|
||||
;;
|
||||
;; # as in Snippets/Emphasize.yasnippet
|
||||
;; ^@i =yyas>
|
||||
;; @i =yyas> s-i
|
||||
;;
|
||||
;; # as in Snippets/Wrap Selection In Tag.yasnippet
|
||||
;; ^W =yyas> C-c M-w
|
||||
;;
|
||||
;; # as in Commands/Insert Tag Pair.yasnippet
|
||||
;; ^< =yyas> C-<
|
||||
;;
|
||||
;; # as in Commands/Documentation for Tag.yasnippet
|
||||
;; ^h =yyas> C-c M-h
|
||||
;;
|
||||
;; # as in Commands/Wrap Each Selected Line in OpenClose Tag.yasnippet
|
||||
;; ^@W =yyas> C-c M-W
|
||||
;;
|
||||
;; # as in Snippets/XHTML   NonBreakingSpace.yasnippet
|
||||
;; ~ =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Insert Entity.yasnippet
|
||||
;; @& =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Refresh All Active Browsers.yasnippet
|
||||
;; @r =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Persistent Include.yasnippet
|
||||
;; ^@i =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/CodeCompletion HTML Tags.yasnippet
|
||||
;; ~ =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Update Includes.yasnippet
|
||||
;; ^@u =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Macros/Delete whitespace between tags.yasnippet
|
||||
;; ^~ =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Tidy.yasnippet
|
||||
;; ^H =yyas> (yas-unknown)
|
||||
;;
|
||||
;;
|
||||
;; --**--
|
||||
;; Automatically generated code, do not edit this part
|
||||
;;
|
||||
;; Translated menu
|
||||
;;
|
||||
(yas-define-menu 'html-mode
|
||||
'(;; Documentation for Tag
|
||||
(yas-item "637CEA2B-578C-429C-BB74-30E8D42BFA22")
|
||||
;; Ignoring Validate Syntax (W3C)
|
||||
(yas-ignore-item "3F26240E-6E4A-11D9-B411-000D93589AF6")
|
||||
|
||||
;; Open Document in Running Browser(s)
|
||||
(yas-item "970EE6B4-A091-11D9-A5A2-000D93C8BE28")
|
||||
;; Ignoring Refresh Running Browser(s)
|
||||
(yas-ignore-item "B8651C6E-A05E-11D9-86AC-000D93C8BE28")
|
||||
|
||||
(yas-submenu "Entities"
|
||||
(;; Ignoring Convert Character / Selection to Entities
|
||||
(yas-ignore-item "3DD8406C-A116-11D9-A5A2-000D93C8BE28")
|
||||
;; Ignoring Convert Character / Selection to Entities Excl. Tags
|
||||
(yas-ignore-item "43C9E8AE-3E53-4B82-A1AF-56697BB3EF09")
|
||||
;; Ignoring Decode Entities in Line / Selection
|
||||
(yas-ignore-item "C183920D-A126-11D9-A5A2-000D93C8BE28")
|
||||
|
||||
;; Non-Breaking Space
|
||||
(yas-item "73B40BAE-A295-11D9-87F7-000D93C8BE28")
|
||||
;; →
|
||||
(yas-item "C70BB693-0954-4440-AEB4-F2ADD6D923F0")
|
||||
;; ←
|
||||
(yas-item "C0418A4A-7E42-4D49-8F86-6E339296CB84")
|
||||
;; ⇤
|
||||
(yas-item "7F102705-27D8-4029-BF61-2F042FB61E06")
|
||||
;; ⌅
|
||||
(yas-item "7062316B-4236-4793-AD35-05E4A6577393")
|
||||
;; ⌃
|
||||
(yas-item "B4987DA5-9C2F-4D2D-AC14-678115079205")
|
||||
;; ⌦
|
||||
(yas-item "44E448B6-37CE-4BFE-8611-C5113593B74B")
|
||||
;; ↩
|
||||
(yas-item "9B216475-D73D-4518-851F-CACD0066A909")
|
||||
;; ⇥
|
||||
(yas-item "ADC78A82-40C2-4AAC-8968-93AF0ED98DF0")
|
||||
;; ⌫
|
||||
(yas-item "38E50882-27AF-4246-A039-355C3E1A699E")
|
||||
;; ⌘
|
||||
(yas-item "7214ACD1-93D9-4D3F-A428-8A7302E0A35E")
|
||||
;; ↓
|
||||
(yas-item "35654B4E-2D76-4CD3-8FBB-2DA1F314BA19")
|
||||
;; →
|
||||
(yas-item "AC15621A-8A16-40DD-A671-EA4C37637215")
|
||||
;; ↑
|
||||
(yas-item "0E2F4A47-EADE-4A05-931E-FC874FA28FC3")
|
||||
;; ⇧
|
||||
(yas-item "1B8D58B9-D9DB-484C-AACD-5D5DF5385308")
|
||||
;; ⎋
|
||||
(yas-item "D7CC7C7C-CD01-4357-AF91-AEFFD914DF98")
|
||||
;; ⌥
|
||||
(yas-item "980A8D39-CA8B-4EC2-9739-DC36A262F28E")
|
||||
(yas-separator)
|
||||
;; Ignoring Insert Entity…
|
||||
(yas-ignore-item "89E5CC0A-3EFF-4DEF-A299-2E9651DE6529")))
|
||||
(yas-submenu "URL Escapes"
|
||||
(;; Ignoring URL Escape Line / Selection
|
||||
(yas-ignore-item "6B024865-6095-4CE3-8EDD-DC6F2230C2FF")
|
||||
;; Ignoring URL Unescape Line / Selection
|
||||
(yas-ignore-item "2C4C9673-B166-432A-8938-75A5CA622481")))
|
||||
;; Ignoring Encrypt Line / Selection (ROT 13)
|
||||
(yas-ignore-item "9B13543F-8356-443C-B6E7-D9259B604927")
|
||||
|
||||
;; Ignoring CodeCompletion HTML Attributes
|
||||
(yas-ignore-item "CBD82CF3-74E9-4E7A-B3F6-9348754EB5AA")
|
||||
;; Insert Open/Close Tag (With Current Word)
|
||||
(yas-item "2ED44A32-C353-447F-BAE4-E3522DB6944D")
|
||||
;; Ignoring Insert Close Tag
|
||||
(yas-ignore-item "0658019F-3635-462E-AAC2-74E4FE508A9B")
|
||||
(yas-submenu "Insert DocType"
|
||||
(;; HTML — 4.01 Strict
|
||||
(yas-item "944F1410-188C-4D70-8340-CECAA56FC7F2")
|
||||
;; HTML — 4.01 Transitional
|
||||
(yas-item "B2AAEE56-42D8-42C3-8F67-865473F50E8D")
|
||||
(yas-separator)
|
||||
;; XHTML — 1.0 Frameset
|
||||
(yas-item "9ED6ABBE-A802-11D9-BFC8-000D93C8BE28")
|
||||
;; XHTML — 1.0 Strict
|
||||
(yas-item "C8B83564-A802-11D9-BFC8-000D93C8BE28")
|
||||
;; XHTML — 1.0 Transitional
|
||||
(yas-item "7D8C2F74-A802-11D9-BFC8-000D93C8BE28")
|
||||
;; XHTML — 1.1
|
||||
(yas-item "5CE8FC6E-A802-11D9-BFC8-000D93C8BE28")))
|
||||
(yas-submenu "Insert Tag"
|
||||
(;; Ignoring CodeCompletion HTML Tags
|
||||
(yas-ignore-item "3463E85F-F500-49A0-8631-D78ED85F9D60")
|
||||
|
||||
;; Base
|
||||
(yas-item "4462A6B8-A08A-11D9-A5A2-000D93C8BE28")
|
||||
;; Body
|
||||
(yas-item "4905D47B-A08B-11D9-A5A2-000D93C8BE28")
|
||||
;; Br
|
||||
(yas-item "3E008E42-A5C9-11D9-9BCD-000D93C8BE28")
|
||||
;; Div
|
||||
(yas-item "576036C0-A60E-11D9-ABD6-000D93C8BE28")
|
||||
;; Embed QT Movie
|
||||
(yas-item "42F15753-9B6D-4DD8-984C-807B94363277")
|
||||
;; Fieldset
|
||||
(yas-item "9BD2BE01-A854-4D55-B584-725D04C075C0")
|
||||
;; Form
|
||||
(yas-item "232C2E8B-A08E-11D9-A5A2-000D93C8BE28")
|
||||
;; Head
|
||||
(yas-item "9CF008C4-A086-11D9-A5A2-000D93C8BE28")
|
||||
;; Heading
|
||||
(yas-item "65BA66DC-A07F-11D9-A5A2-000D93C8BE28")
|
||||
;; Input
|
||||
(yas-item "44180979-A08E-11D9-A5A2-000D93C8BE28")
|
||||
;; Input with Label
|
||||
(yas-item "D8DCCC81-749A-4E2A-B4BC-D109D5799CAA")
|
||||
;; Link
|
||||
(yas-item "77BFD0C0-A08A-11D9-A5A2-000D93C8BE28")
|
||||
;; Mail Anchor
|
||||
(yas-item "81DA4C74-A530-11D9-9BCD-000D93C8BE28")
|
||||
;; Meta
|
||||
(yas-item "DA99AC44-A083-11D9-A5A2-000D93C8BE28")
|
||||
;; Option
|
||||
(yas-item "5820372E-A093-4F38-B25C-B0CCC50A0FC4")
|
||||
;; Script
|
||||
(yas-item "6592050A-A087-11D9-A5A2-000D93C8BE28")
|
||||
;; Script With External Source
|
||||
(yas-item "7D676C4C-A087-11D9-A5A2-000D93C8BE28")
|
||||
;; Select Box
|
||||
(yas-item "26023CFF-C73F-4EF5-9803-E4DBA2CBEADD")
|
||||
;; Style
|
||||
(yas-item "3C518074-A088-11D9-A5A2-000D93C8BE28")
|
||||
;; Table
|
||||
(yas-item "57176082-A12F-11D9-A5A2-000D93C8BE28")
|
||||
;; Text Area
|
||||
(yas-item "AAC9D7B8-A12C-11D9-A5A2-000D93C8BE28")
|
||||
;; Title
|
||||
(yas-item "B62ECABE-A086-11D9-A5A2-000D93C8BE28")))
|
||||
|
||||
(yas-submenu "Includes"
|
||||
(;; Ignoring Add Persistent Include
|
||||
(yas-ignore-item "0D814247-7A00-46EE-A2A4-45FBBF4B1181")
|
||||
;; Ignoring Update Document
|
||||
(yas-ignore-item "4400BCE9-20E3-426E-B1D7-2C0BCA53BCF8")
|
||||
;; Ignoring Help: Persistent Includes
|
||||
(yas-ignore-item "9AFDEB2C-D9F0-423E-8211-EBB089F51F0C")))
|
||||
(yas-submenu "Format"
|
||||
(;; Strong
|
||||
(yas-item "4117D930-B6FA-4022-97E7-ECCAF4E70F63")
|
||||
;; Emphasize
|
||||
(yas-item "EBB98620-3292-4621-BA38-D8A9A65D9551")))
|
||||
(yas-submenu "Conditional Comments"
|
||||
(;; IE Conditional Comment: Internet Explorer
|
||||
(yas-item "0ED6DA73-F38F-4A65-B18F-3379D2BA9387")
|
||||
;; IE Conditional Comment: Internet Explorer 5.0 only
|
||||
(yas-item "3A517A94-001E-464D-8184-1FE56D0D0D70")
|
||||
;; IE Conditional Comment: Internet Explorer 5.5 only
|
||||
(yas-item "E3F8984E-7269-4981-9D30-967AB56A6ACE")
|
||||
;; IE Conditional Comment: Internet Explorer 5.x
|
||||
(yas-item "F3512848-7889-45DA-993B-0547976C8E6D")
|
||||
;; IE Conditional Comment: Internet Explorer 6 and below
|
||||
(yas-item "32BBB9AB-8732-4F91-A587-354941A27B69")
|
||||
;; IE Conditional Comment: Internet Explorer 6 only
|
||||
(yas-item "48DF7485-52EA-49B3-88AF-3A41F933F325")
|
||||
;; IE Conditional Comment: Internet Explorer 7 and above
|
||||
(yas-item "CBC24AF4-88E0-498B-BE50-934B9CF29EC7")
|
||||
;; IE Conditional Comment: NOT Internet Explorer
|
||||
(yas-item "F00170EE-4A82-413F-A88B-85293E69A88B")))
|
||||
|
||||
;; Wrap Selection in Open/Close Tag
|
||||
(yas-item "BC8B8AE2-5F16-11D9-B9C3-000D93589AF6")
|
||||
;; Wrap Each Selected Line in Open/Close Tag
|
||||
(yas-item "991E7EBD-F3F5-469A-BA01-DC30E04AD472")
|
||||
;; Wrap in <?= … ?>
|
||||
(yas-item "912906A0-9A29-434B-AE98-E9DFDE6E48B4")
|
||||
(yas-separator)
|
||||
;; Ignoring Strip HTML Tags from Document / Selection
|
||||
(yas-ignore-item "20D760B5-A127-11D9-A5A2-000D93C8BE28")
|
||||
;; Ignoring Tidy
|
||||
(yas-ignore-item "45F92B81-6F0E-11D9-A1E4-000D9332809C"))
|
||||
'("7B7E945E-A112-11D9-A5A2-000D93C8BE28"
|
||||
"3C44EABE-8D6F-4B1B-AB91-F419FAD1A0AD"
|
||||
"9AFDEB2C-D9F0-423E-8211-EBB089F51F0C"
|
||||
"CBD82CF3-74E9-4E7A-B3F6-9348754EB5AA"
|
||||
"3463E85F-F500-49A0-8631-D78ED85F9D60"
|
||||
"9B13543F-8356-443C-B6E7-D9259B604927"
|
||||
"0D814247-7A00-46EE-A2A4-45FBBF4B1181"
|
||||
"4400BCE9-20E3-426E-B1D7-2C0BCA53BCF8"
|
||||
"6B024865-6095-4CE3-8EDD-DC6F2230C2FF"
|
||||
"3DD8406C-A116-11D9-A5A2-000D93C8BE28"
|
||||
"43C9E8AE-3E53-4B82-A1AF-56697BB3EF09"
|
||||
"C183920D-A126-11D9-A5A2-000D93C8BE28"
|
||||
"2C4C9673-B166-432A-8938-75A5CA622481"
|
||||
"0658019F-3635-462E-AAC2-74E4FE508A9B"
|
||||
"89E5CC0A-3EFF-4DEF-A299-2E9651DE6529"
|
||||
"B8651C6E-A05E-11D9-86AC-000D93C8BE28"
|
||||
"20D760B5-A127-11D9-A5A2-000D93C8BE28"
|
||||
"45F92B81-6F0E-11D9-A1E4-000D9332809C"
|
||||
"3F26240E-6E4A-11D9-B411-000D93589AF6"
|
||||
"B23D6E15-6B33-11D9-86C1-000D93589AF6"
|
||||
"C8B717C2-6B33-11D9-BB47-000D93589AF6"
|
||||
"CD6D2CC6-6B33-11D9-BDFD-000D93589AF6"
|
||||
"7B7E945E-A112-11D9-A5A2-000D93C8BE28"
|
||||
"04332FA8-8157-46C4-9854-8C190FFD96C6"
|
||||
"E6F19171-F664-4B4F-92DA-3E15E6CAD35C"
|
||||
"26068A55-4C84-409D-BA00-162B55AF6961"
|
||||
"EBEE6B51-29C7-4362-818F-A190CACD5296"
|
||||
"65D38039-6B0A-48E9-9E49-43832ECC4107"
|
||||
"CDE8EFD6-9DE2-4E8C-BB6A-52E8CCD2E977"))
|
||||
|
||||
;; Unknown substitutions
|
||||
;;
|
||||
;; Substitutions for: content
|
||||
;;
|
||||
;; # as in Snippets/Emphasize.yasnippet
|
||||
;; `(yas-html-toggle-wrap yas-selected-text "em")` =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/XHTML h1.yasnippet
|
||||
;; `yas-selected-text` =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/IE Conditional Comment Internet Explorer 5_0 only.yasnippet
|
||||
;; `(or (yas-selected-text) " IE Conditional Comment: Internet Explorer 5.0 only ")` =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/IE Conditional Comment Internet Explorer 5_5 only.yasnippet
|
||||
;; `(or (yas-selected-text) " IE Conditional Comment: Internet Explorer 5.5 only ")` =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/IE Conditional Comment Internet Explorer 5_x.yasnippet
|
||||
;; `(or (yas-selected-text) " IE Conditional Comment: Internet Explorer 5.x ")` =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/IE Conditional Comment Internet Explorer 6 and below.yasnippet
|
||||
;; `(or (yas-selected-text) " IE Conditional Comment: Internet Explorer 6 and below ")` =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/IE Conditional Comment Internet Explorer 6 only.yasnippet
|
||||
;; `(or (yas-selected-text) " IE Conditional Comment: Internet Explorer 6 only ")` =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/IE Conditional Comment Internet Explorer 7+.yasnippet
|
||||
;; `(or (yas-selected-text) " IE Conditional Comment: Internet Explorer 7 and above ")` =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/IE Conditional Comment Internet Explorer.yasnippet
|
||||
;; `(or (yas-selected-text) " IE Conditional Comment: Internet Explorer ")` =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/IE Conditional Comment NOT Internet Explorer.yasnippet
|
||||
;; `(or (yas-selected-text) " IE Conditional Comment: NOT Internet Explorer ")` =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/XHTML meta.yasnippet
|
||||
;; `yas-html-xhtml-attr` =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/Strong.yasnippet
|
||||
;; `(yas-html-toggle-wrap yas-selected-text "strong")` =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/About Persistent Includes.yasnippet
|
||||
;; 9AFDEB2C-D9F0-423E-8211-EBB089F51F0C =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/CodeCompletion HTML Attributes.yasnippet
|
||||
;; CBD82CF3-74E9-4E7A-B3F6-9348754EB5AA =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/CodeCompletion HTML Tags.yasnippet
|
||||
;; 3463E85F-F500-49A0-8631-D78ED85F9D60 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Encrypt Line Selection (ROT 13).yasnippet
|
||||
;; 9B13543F-8356-443C-B6E7-D9259B604927 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Persistent Include.yasnippet
|
||||
;; 0D814247-7A00-46EE-A2A4-45FBBF4B1181 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Update Includes.yasnippet
|
||||
;; 4400BCE9-20E3-426E-B1D7-2C0BCA53BCF8 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Convert Line Selection to URL Escapes.yasnippet
|
||||
;; 6B024865-6095-4CE3-8EDD-DC6F2230C2FF =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Convert to HTML Entities.yasnippet
|
||||
;; 3DD8406C-A116-11D9-A5A2-000D93C8BE28 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Convert to named entities excl tags.yasnippet
|
||||
;; 43C9E8AE-3E53-4B82-A1AF-56697BB3EF09 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Decode HTML Entities.yasnippet
|
||||
;; C183920D-A126-11D9-A5A2-000D93C8BE28 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Decode Numeric URL Escapes in Line Selection.yasnippet
|
||||
;; 2C4C9673-B166-432A-8938-75A5CA622481 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Insert Close Tag.yasnippet
|
||||
;; 0658019F-3635-462E-AAC2-74E4FE508A9B =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Insert Entity.yasnippet
|
||||
;; 89E5CC0A-3EFF-4DEF-A299-2E9651DE6529 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Refresh All Active Browsers.yasnippet
|
||||
;; B8651C6E-A05E-11D9-86AC-000D93C8BE28 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Strip HTML tags.yasnippet
|
||||
;; 20D760B5-A127-11D9-A5A2-000D93C8BE28 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Tidy.yasnippet
|
||||
;; 45F92B81-6F0E-11D9-A1E4-000D9332809C =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/W3C validation.yasnippet
|
||||
;; 3F26240E-6E4A-11D9-B411-000D93589AF6 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in DragCommands/Anchor Tag.yasnippet
|
||||
;; B23D6E15-6B33-11D9-86C1-000D93589AF6 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in DragCommands/CSS Link.yasnippet
|
||||
;; C8B717C2-6B33-11D9-BB47-000D93589AF6 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in DragCommands/Image Tag.yasnippet
|
||||
;; CD6D2CC6-6B33-11D9-BDFD-000D93589AF6 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Macros/Delete whitespace between tags.yasnippet
|
||||
;; 7B7E945E-A112-11D9-A5A2-000D93C8BE28 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/XHTML body.yasnippet
|
||||
;; ${TM_FILENAME/(.*)\..*/\L$1/} =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/XHTML form.yasnippet
|
||||
;; ${TM_FILENAME/(.*?)\..*/$1_submit/} =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/XHTML title.yasnippet
|
||||
;; ${TM_FILENAME/((.+)\..*)?/(?2:$2:Page Title)/} =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Templates/HTML 4.0 Strict/info.yasnippet
|
||||
;; 04332FA8-8157-46C4-9854-8C190FFD96C6 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Templates/HTML 4.0 Transitional/info.yasnippet
|
||||
;; E6F19171-F664-4B4F-92DA-3E15E6CAD35C =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Templates/XHTML 1.0 Frameset/info.yasnippet
|
||||
;; 26068A55-4C84-409D-BA00-162B55AF6961 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Templates/XHTML 1.0 Strict/info.yasnippet
|
||||
;; EBEE6B51-29C7-4362-818F-A190CACD5296 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Templates/XHTML 1.0 Transitional/info.yasnippet
|
||||
;; 65D38039-6B0A-48E9-9E49-43832ECC4107 =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Templates/XHTML 1.1/info.yasnippet
|
||||
;; CDE8EFD6-9DE2-4E8C-BB6A-52E8CCD2E977 =yyas> (yas-unknown)
|
||||
;;
|
||||
;;
|
||||
|
||||
;; Substitutions for: condition
|
||||
;;
|
||||
;; # as in Templates/XHTML 1.1/info.yasnippet
|
||||
;; text.html =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/CodeCompletion HTML Attributes.yasnippet
|
||||
;; text.html punctuation.definition.tag -source, text.html meta.tag -entity.other.attribute-name -source =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/CodeCompletion HTML Tags.yasnippet
|
||||
;; text.html -entity.other.attribute-name -string.quoted, invalid.illegal.incomplete.html =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Documentation for Tag.yasnippet
|
||||
;; text.html, text.html entity.name.tag =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Refresh All Active Browsers.yasnippet
|
||||
;; text.html, source.css =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/Smart returnindent for tag pairs.yasnippet
|
||||
;; meta.scope.between-tag-pair =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/Wrap Selection In Tag.yasnippet
|
||||
;; text.html, =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/Wrap in =.yasnippet
|
||||
;; text.html string =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/XHTML head.yasnippet
|
||||
;; text.html - text.html source =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/XHTML title.yasnippet
|
||||
;; text.html - text.blog =yyas> (yas-unknown)
|
||||
;;
|
||||
;;
|
||||
|
||||
;; Substitutions for: binding
|
||||
;;
|
||||
;; # as in Commands/CodeCompletion HTML Tags.yasnippet
|
||||
;; ~ =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Insert Entity.yasnippet
|
||||
;; @& =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Persistent Include.yasnippet
|
||||
;; =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Update Includes.yasnippet
|
||||
;; ^@u =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Insert Close Tag.yasnippet
|
||||
;; ~@. =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Refresh All Active Browsers.yasnippet
|
||||
;; @r =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/Tidy.yasnippet
|
||||
;; ^H =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Commands/W3C validation.yasnippet
|
||||
;; ^V =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Macros/Delete whitespace between tags.yasnippet
|
||||
;; ^~ =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/Smart returnindent for tag pairs.yasnippet
|
||||
;;
=yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/XHTML   NonBreakingSpace.yasnippet
|
||||
;; ~ =yyas> (yas-unknown)
|
||||
;;
|
||||
;; # as in Snippets/XHTML br.yasnippet
|
||||
;; ^
=yyas> (yas-unknown)
|
||||
;;
|
||||
;;
|
||||
|
||||
;; .yas-setup.el for html-mode ends here
|
88
extras/imported/objc-mode/.yas-setup.el
Normal file
88
extras/imported/objc-mode/.yas-setup.el
Normal file
@ -0,0 +1,88 @@
|
||||
(defun yas-objc-docset-query (query)
|
||||
|
||||
)
|
||||
(defvar yas-objc-method-names (make-vector 1023 0))
|
||||
(defvar yas-objc-class-names (make-vector 1023 0))
|
||||
|
||||
(defvar yas-objc-languages (list))
|
||||
(defvar yas-objc-defkinds (list))
|
||||
|
||||
|
||||
(defun yas-objc-extract-super-list ()
|
||||
(interactive)
|
||||
(setq yas-objc-method-names (make-vector 1023 0)
|
||||
yas-objc-class-names (make-vector 1023 0)
|
||||
yas-objc-languages (list)
|
||||
yas-objc-defkinds (list))
|
||||
(with-temp-buffer
|
||||
(shell-command
|
||||
"/Developer/usr/bin/docsetutil dump -skip-text /Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/"
|
||||
(current-buffer))
|
||||
(goto-char (point-min))
|
||||
(search-forward-regexp "API index contains .* tokens")
|
||||
(while (search-forward-regexp "^\\([^/]*\\)/\\([^/]*\\)/\\([^/]*\\)/\\([^/]*\\)$" nil 'noerror)
|
||||
(intern (match-string 3) yas-objc-class-names)
|
||||
(intern (match-string 4) yas-objc-method-names)
|
||||
(add-to-list 'yas-objc-languages (match-string 1))
|
||||
(add-to-list 'yas-objc-defkinds (match-string 2)))))
|
||||
|
||||
;; (put (intern-soft (setq chosen (completing-read "Method: " yas-objc-method-names)) yas-objc-method-names)
|
||||
;; 'someshit
|
||||
;; 'someday)
|
||||
|
||||
;; (completing-read "Class: " yas-objc-class-names)
|
||||
|
||||
;; (get (intern-soft (setq chosen (completing-read "hey: " yas-objc-method-names)) yas-objc-method-names)
|
||||
;; 'someshit)
|
||||
|
||||
(defun yas-objc-current-method-signature ()
|
||||
(let ((orig-point (point))
|
||||
(start-point nil)
|
||||
sig
|
||||
orig-ppss
|
||||
ppss)
|
||||
(save-excursion
|
||||
(condition-case nil
|
||||
(while (not (eq (point) (point-min))) (backward-sexp))
|
||||
(error nil))
|
||||
(when (eq (preceding-char) ?\[)
|
||||
(setq orig-ppss (syntax-ppss))
|
||||
(forward-sexp)
|
||||
(skip-chars-forward " \t\n")
|
||||
(setq ppss (syntax-ppss))
|
||||
(while (and (>= (car ppss) (car orig-ppss))
|
||||
(search-forward-regexp "[[:alpha:]]+:" nil 'noerror))
|
||||
(setq ppss (syntax-ppss))
|
||||
(when (eq (car ppss) (car orig-ppss))
|
||||
(setq sig
|
||||
(concat (or sig "") (match-string-no-properties 0)))))
|
||||
sig))))
|
||||
|
||||
(defun yas-objc-current-method-signature ()
|
||||
(let ((orig-point (point))
|
||||
(start-point nil)
|
||||
sig
|
||||
orig-ppss
|
||||
ppss)
|
||||
(save-excursion
|
||||
(condition-case nil
|
||||
(while (not (eq (point) (point-max))) (backward-sexp))
|
||||
(error ))
|
||||
(when (eq (preceding-char) ?\[)
|
||||
(setq orig-ppss (syntax-ppss))
|
||||
(forward-sexp)
|
||||
(skip-chars-forward " \t\n")
|
||||
(setq ppss (syntax-ppss))
|
||||
(condition-case nil
|
||||
(while (and (>= (car ppss) (car orig-ppss))
|
||||
(search-forward-regexp "[[:alpha:]]+:" orig-point 'noerror))
|
||||
(setq ppss (syntax-ppss))
|
||||
(when (eq (car ppss) (car orig-ppss))
|
||||
(setq sig
|
||||
(concat (or sig "") (match-string-no-properties 0))))
|
||||
(forward-sexp))
|
||||
(error nil))
|
||||
(save-excursion
|
||||
(backward-word)
|
||||
(concat sig (buffer-substring-no-properties (point) orig-point)))
|
||||
sig))))
|
59477
extras/imported/objc-mode/Support/alldefs.txt
Normal file
59477
extras/imported/objc-mode/Support/alldefs.txt
Normal file
File diff suppressed because it is too large
Load Diff
1304
extras/imported/rails-mode/.yas-setup.el
Normal file
1304
extras/imported/rails-mode/.yas-setup.el
Normal file
File diff suppressed because it is too large
Load Diff
1032
extras/imported/ruby-mode/.yas-setup.el
Normal file
1032
extras/imported/ruby-mode/.yas-setup.el
Normal file
File diff suppressed because it is too large
Load Diff
468
extras/textmate_import.rb
Executable file
468
extras/textmate_import.rb
Executable file
@ -0,0 +1,468 @@
|
||||
#!/usr/bin/env ruby
|
||||
# -*- coding: utf-8 -*-
|
||||
# textmate_import.rb --- import textmate snippets
|
||||
#
|
||||
# Copyright (C) 2009 Rob Christie, 2010 João Távora
|
||||
#
|
||||
# This is a quick script to generate YASnippets from TextMate Snippets.
|
||||
#
|
||||
# I based the script off of a python script of a similar nature by
|
||||
# Jeff Wheeler: http://nokrev.com
|
||||
# http://code.nokrev.com/?p=snippet-copier.git;a=blob_plain;f=snippet_copier.py
|
||||
#
|
||||
# Use textmate_import.rb --help to get usage information.
|
||||
|
||||
require 'rubygems'
|
||||
require 'plist'
|
||||
require 'trollop'
|
||||
require 'fileutils'
|
||||
require 'shellwords' # String#shellescape
|
||||
require 'ruby-debug' if $DEBUG
|
||||
|
||||
Encoding.default_external = Encoding::UTF_8 if RUBY_VERSION > '1.8.7'
|
||||
|
||||
opts = Trollop::options do
|
||||
opt :bundle_dir, "TextMate bundle directory", :short => '-d', :type => :string
|
||||
opt :output_dir, "Output directory", :short => '-o', :type => :string
|
||||
opt :glob, "Specific snippet file (or glob) inside <bundle_dir>", :short => '-g', :default => '*.{tmSnippet,tmCommand,plist,tmMacro}'
|
||||
opt :pretty, 'Pretty prints multiple snippets when printing to standard out', :short => '-p'
|
||||
opt :quiet, "Be quiet", :short => '-q'
|
||||
opt :plist_file, "Use a specific plist file to derive menu information from", :type => :string
|
||||
end
|
||||
Trollop::die :bundle_dir, "must be provided" unless opts.bundle_dir
|
||||
Trollop::die :bundle_dir, "must exist" unless File.directory? opts.bundle_dir
|
||||
|
||||
Trollop::die :output_dir, "must be provided" unless opts.output_dir
|
||||
Trollop::die :output_dir, "must exist" unless File.directory? opts.output_dir
|
||||
|
||||
Trollop::die :plist_file, "must exist" if opts.plist_file && File.directory?(opts.plist_file)
|
||||
|
||||
|
||||
# Represents and is capable of outputting the representation of a
|
||||
# TextMate menu in terms of `yas-define-menu'
|
||||
#
|
||||
class TmSubmenu
|
||||
|
||||
@@excluded_items = [];
|
||||
def self.excluded_items; @@excluded_items; end
|
||||
|
||||
attr_reader :items, :name
|
||||
def initialize(name, hash)
|
||||
@items = hash["items"]
|
||||
@name = name
|
||||
end
|
||||
|
||||
def to_lisp(allsubmenus,
|
||||
deleteditems,
|
||||
indent = 0,
|
||||
thingy = ["(", ")"])
|
||||
|
||||
first = true;
|
||||
|
||||
string = ""
|
||||
separator_useless = true;
|
||||
items.each do |uuid|
|
||||
if deleteditems && deleteditems.index(uuid)
|
||||
$stderr.puts "#{uuid} has been deleted!"
|
||||
next
|
||||
end
|
||||
string += "\n"
|
||||
string += " " * indent
|
||||
string += (first ? thingy[0] : (" " * thingy[0].length))
|
||||
|
||||
submenu = allsubmenus[uuid]
|
||||
snippet = TmSnippet::snippets_by_uid[uuid]
|
||||
unimplemented = TmSnippet::unknown_substitutions["content"][uuid]
|
||||
if submenu
|
||||
str = "(yas-submenu "
|
||||
string += str + "\"" + submenu.name + "\""
|
||||
string += submenu.to_lisp(allsubmenus, deleteditems,
|
||||
indent + str.length + thingy[0].length)
|
||||
elsif snippet and not unimplemented
|
||||
string += ";; " + snippet.name + "\n"
|
||||
string += " " * (indent + thingy[0].length)
|
||||
string += "(yas-item \"" + uuid + "\")"
|
||||
separator_useless = false;
|
||||
elsif snippet and unimplemented
|
||||
string += ";; Ignoring " + snippet.name + "\n"
|
||||
string += " " * (indent + thingy[0].length)
|
||||
string += "(yas-ignore-item \"" + uuid + "\")"
|
||||
separator_useless = true;
|
||||
elsif (uuid =~ /---------------------/)
|
||||
string += "(yas-separator)" unless separator_useless
|
||||
end
|
||||
first = false;
|
||||
end
|
||||
string += ")"
|
||||
string += thingy[1]
|
||||
|
||||
return string
|
||||
end
|
||||
|
||||
def self.main_menu_to_lisp (parsed_plist, modename)
|
||||
mainmenu = parsed_plist["mainMenu"]
|
||||
deleted = parsed_plist["deleted"]
|
||||
|
||||
root = TmSubmenu.new("__main_menu__", mainmenu)
|
||||
all = {}
|
||||
|
||||
mainmenu["submenus"].each_pair do |k,v|
|
||||
all[k] = TmSubmenu.new(v["name"], v)
|
||||
end
|
||||
|
||||
excluded = (mainmenu["excludedItems"] || []) + TmSubmenu::excluded_items
|
||||
closing = "\n '("
|
||||
closing+= excluded.collect do |uuid|
|
||||
"\"" + uuid + "\""
|
||||
end.join( "\n ") + "))"
|
||||
|
||||
str = "(yas-define-menu "
|
||||
return str + "'#{modename}" + root.to_lisp(all,
|
||||
deleted,
|
||||
str.length,
|
||||
["'(" , closing])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Represents a textmate snippet
|
||||
#
|
||||
# - @file is the .tmsnippet/.plist file path relative to cwd
|
||||
#
|
||||
# - optional @info is a Plist.parsed info.plist found in the bundle dir
|
||||
#
|
||||
# - @@snippets_by_uid is where one can find all the snippets parsed so
|
||||
# far.
|
||||
#
|
||||
#
|
||||
class SkipSnippet < RuntimeError; end
|
||||
class TmSnippet
|
||||
@@known_substitutions = {
|
||||
"content" => {
|
||||
"${TM_RAILS_TEMPLATE_START_RUBY_EXPR}" => "<%= ",
|
||||
"${TM_RAILS_TEMPLATE_END_RUBY_EXPR}" => " %>",
|
||||
"${TM_RAILS_TEMPLATE_START_RUBY_INLINE}" => "<% ",
|
||||
"${TM_RAILS_TEMPLATE_END_RUBY_INLINE}" => " -%>",
|
||||
"${TM_RAILS_TEMPLATE_END_RUBY_BLOCK}" => "end" ,
|
||||
"${0:$TM_SELECTED_TEXT}" => "${0:`yas-selected-text`}",
|
||||
/\$\{(\d+)\}/ => "$\\1",
|
||||
"${1:$TM_SELECTED_TEXT}" => "${1:`yas-selected-text`}",
|
||||
"${2:$TM_SELECTED_TEXT}" => "${2:`yas-selected-text`}",
|
||||
'$TM_SELECTED_TEXT' => "`yas-selected-text`",
|
||||
%r'\$\{TM_SELECTED_TEXT:([^\}]*)\}' => "`(or (yas-selected-text) \"\\1\")`",
|
||||
%r'`[^`]+\n[^`]`' => Proc.new {|uuid, match| "(yas-multi-line-unknown " + uuid + ")"}},
|
||||
"condition" => {
|
||||
/^source\..*$/ => "" },
|
||||
"binding" => {},
|
||||
"type" => {}
|
||||
}
|
||||
|
||||
def self.extra_substitutions; @@extra_substitutions; end
|
||||
@@extra_substitutions = {
|
||||
"content" => {},
|
||||
"condition" => {},
|
||||
"binding" => {},
|
||||
"type" => {}
|
||||
}
|
||||
|
||||
def self.unknown_substitutions; @@unknown_substitutions; end
|
||||
@@unknown_substitutions = {
|
||||
"content" => {},
|
||||
"condition" => {},
|
||||
"binding" => {},
|
||||
"type" => {}
|
||||
}
|
||||
|
||||
@@snippets_by_uid={}
|
||||
def self.snippets_by_uid; @@snippets_by_uid; end
|
||||
|
||||
def initialize(file,info=nil)
|
||||
@file = file
|
||||
@info = info
|
||||
@snippet = TmSnippet::read_plist(file)
|
||||
@@snippets_by_uid[self.uuid] = self;
|
||||
raise SkipSnippet.new "not a snippet/command/macro." unless (@snippet["scope"] || @snippet["command"])
|
||||
raise SkipSnippet.new "looks like preferences."if @file =~ /Preferences\//
|
||||
raise RuntimeError.new("Cannot convert this snippet #{file}!") unless @snippet;
|
||||
end
|
||||
|
||||
def name
|
||||
@snippet["name"]
|
||||
end
|
||||
|
||||
def uuid
|
||||
@snippet["uuid"]
|
||||
end
|
||||
|
||||
def key
|
||||
@snippet["tabTrigger"]
|
||||
end
|
||||
|
||||
def condition
|
||||
yas_directive "condition"
|
||||
end
|
||||
|
||||
def type
|
||||
override = yas_directive "type"
|
||||
if override
|
||||
return override
|
||||
else
|
||||
return "# type: command\n" if @file =~ /(Commands\/|Macros\/)/
|
||||
end
|
||||
end
|
||||
|
||||
def binding
|
||||
yas_directive "binding"
|
||||
end
|
||||
|
||||
def content
|
||||
known = @@known_substitutions["content"]
|
||||
extra = @@extra_substitutions["content"]
|
||||
if direct = extra[uuid]
|
||||
return direct
|
||||
else
|
||||
ct = @snippet["content"]
|
||||
if ct
|
||||
known.each_pair do |k,v|
|
||||
if v.respond_to? :call
|
||||
ct.gsub!(k) {|match| v.call(uuid, match)}
|
||||
else
|
||||
ct.gsub!(k,v)
|
||||
end
|
||||
end
|
||||
extra.each_pair do |k,v|
|
||||
ct.gsub!(k,v)
|
||||
end
|
||||
# the remaining stuff is an unknown substitution
|
||||
#
|
||||
[ %r'\$\{ [^/\}\{:]* / [^/]* / [^/]* / [^\}]*\}'x ,
|
||||
%r'\$\{[^\d][^}]+\}',
|
||||
%r'`[^`]+`',
|
||||
%r'\$TM_[\w_]+',
|
||||
%r'\(yas-multi-line-unknown [^\)]*\)'
|
||||
].each do |reg|
|
||||
ct.scan(reg) do |match|
|
||||
@@unknown_substitutions["content"][match] = self
|
||||
end
|
||||
end
|
||||
return ct
|
||||
else
|
||||
@@unknown_substitutions["content"][uuid] = self
|
||||
TmSubmenu::excluded_items.push(uuid)
|
||||
return "(yas-unimplemented)"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def to_yas
|
||||
doc = "# -*- mode: snippet -*-\n"
|
||||
doc << (self.type || "")
|
||||
doc << "# uuid: #{self.uuid}\n"
|
||||
doc << "# key: #{self.key}\n" if self.key
|
||||
doc << "# contributor: Translated from textmate snippet by PROGRAM_NAME\n"
|
||||
doc << "# name: #{self.name}\n"
|
||||
doc << (self.binding || "")
|
||||
doc << (self.condition || "")
|
||||
doc << "# --\n"
|
||||
doc << (self.content || "(yas-unimplemented)")
|
||||
doc
|
||||
end
|
||||
|
||||
def self.canonicalize(filename)
|
||||
invalid_char = /[^ a-z_0-9.+=~(){}\/'`&#,-]/i
|
||||
|
||||
filename.
|
||||
gsub(invalid_char, ''). # remove invalid characters
|
||||
gsub(/ {2,}/,' '). # squeeze repeated spaces into a single one
|
||||
rstrip # remove trailing whitespaces
|
||||
end
|
||||
|
||||
def yas_file()
|
||||
File.join(TmSnippet::canonicalize(@file[0, @file.length-File.extname(@file).length]) + ".yasnippet")
|
||||
end
|
||||
|
||||
def self.read_plist(xml_or_binary)
|
||||
begin
|
||||
parsed = Plist::parse_xml(xml_or_binary)
|
||||
return parsed if parsed
|
||||
raise ArgumentError.new "Probably in binary format and parse_xml is very quiet..."
|
||||
rescue StandardError => e
|
||||
if (system "plutil -convert xml1 #{xml_or_binary.shellescape} -o /tmp/textmate_import.tmpxml")
|
||||
return Plist::parse_xml("/tmp/textmate_import.tmpxml")
|
||||
else
|
||||
raise RuntimeError.new "plutil failed miserably, check if you have it..."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@yas_to_tm_directives = {"condition" => "scope", "binding" => "keyEquivalent", "key" => "tabTrigger"}
|
||||
def yas_directive(yas_directive)
|
||||
#
|
||||
# Merge "known" hardcoded substitution with "extra" substitutions
|
||||
# provided in the .yas-setup.el file.
|
||||
#
|
||||
merged = @@known_substitutions[yas_directive].
|
||||
merge(@@extra_substitutions[yas_directive])
|
||||
#
|
||||
# First look for an uuid-based direct substitution for this
|
||||
# directive.
|
||||
#
|
||||
if direct = merged[uuid]
|
||||
return "# #{yas_directive}: "+ direct + "\n" unless direct.empty?
|
||||
else
|
||||
tm_directive = @@yas_to_tm_directives[yas_directive]
|
||||
val = tm_directive && @snippet[tm_directive]
|
||||
if val and !val.delete(" ").empty? then
|
||||
#
|
||||
# Sort merged substitutions by length (bigger ones first,
|
||||
# regexps last), and apply them to the value gotten for plist.
|
||||
#
|
||||
allsubs = merged.sort_by do |what, with|
|
||||
if what.respond_to? :length then -what.length else 0 end
|
||||
end
|
||||
allsubs.each do |sub|
|
||||
if val.gsub!(sub[0],sub[1])
|
||||
# puts "SUBBED #{sub[0]} for #{sub[1]}"
|
||||
return "# #{yas_directive}: "+ val + "\n" unless val.empty?
|
||||
end
|
||||
end
|
||||
#
|
||||
# If we get here, no substitution matched, so mark this an
|
||||
# unknown substitution.
|
||||
#
|
||||
@@unknown_substitutions[yas_directive][val] = self
|
||||
return "## #{yas_directive}: \""+ val + "\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
if __FILE__ == $PROGRAM_NAME
|
||||
# Read the the bundle's info.plist if can find it/guess it
|
||||
#
|
||||
info_plist_file = opts.plist_file || File.join(opts.bundle_dir,"info.plist")
|
||||
info_plist = TmSnippet::read_plist(info_plist_file) if info_plist_file and File.readable? info_plist_file;
|
||||
|
||||
# Calculate the mode name
|
||||
#
|
||||
modename = File.basename opts.output_dir || "major-mode-name"
|
||||
|
||||
# Read in .yas-setup.el looking for the separator between auto-generated
|
||||
#
|
||||
original_dir = Dir.pwd
|
||||
yas_setup_el_file = File.join(original_dir, opts.output_dir, ".yas-setup.el")
|
||||
separator = ";; --**--"
|
||||
whole, head , tail = "", "", ""
|
||||
if File::exists? yas_setup_el_file
|
||||
File.open yas_setup_el_file, 'r' do |file|
|
||||
whole = file.read
|
||||
head , tail = whole.split(separator)
|
||||
end
|
||||
else
|
||||
head = ";; .yas-setup.el for #{modename}\n" + ";; \n"
|
||||
end
|
||||
|
||||
# Now iterate the tail part to find extra substitutions
|
||||
#
|
||||
tail ||= ""
|
||||
head ||= ""
|
||||
directive = nil
|
||||
# puts "get this head #{head}"
|
||||
head.each_line do |line|
|
||||
case line
|
||||
when /^;; Substitutions for:(.*)$/
|
||||
directive = $~[1].strip
|
||||
# puts "found the directove #{directive}"
|
||||
when /^;;(.*)[ ]+=yyas>(.*)$/
|
||||
replacewith = $~[2].strip
|
||||
lookfor = $~[1]
|
||||
lookfor.gsub!(/^[ ]*/, "")
|
||||
lookfor.gsub!(/[ ]*$/, "")
|
||||
# puts "found this wonderful substitution for #{directive} which is #{lookfor} => #{replacewith}"
|
||||
unless !directive or replacewith =~ /yas-unknown/ then
|
||||
TmSnippet.extra_substitutions[directive][lookfor] = replacewith
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Glob snippets into snippet_files, going into subdirs
|
||||
#
|
||||
Dir.chdir opts.bundle_dir
|
||||
snippet_files_glob = File.join("**", opts.glob)
|
||||
snippet_files = Dir.glob(snippet_files_glob)
|
||||
|
||||
# Attempt to convert each snippet files in snippet_files
|
||||
#
|
||||
puts "Will try to convert #{snippet_files.length} snippets...\n" unless opts.quiet
|
||||
|
||||
|
||||
# Iterate the globbed files
|
||||
#
|
||||
snippet_files.each do |file|
|
||||
begin
|
||||
$stdout.print "Processing \"#{File.join(opts.bundle_dir,file)}\"..." unless opts.quiet
|
||||
snippet = TmSnippet.new(file,info_plist)
|
||||
|
||||
file_to_create = File.join(original_dir, opts.output_dir, snippet.yas_file)
|
||||
FileUtils.mkdir_p(File.dirname(file_to_create))
|
||||
File.open(file_to_create, 'w') do |f|
|
||||
f.write(snippet.to_yas)
|
||||
end
|
||||
$stdout.print "done\n" unless opts.quiet
|
||||
rescue SkipSnippet => e
|
||||
$stdout.print "skipped! #{e.message}\n" unless opts.quiet
|
||||
rescue RuntimeError => e
|
||||
$stderr.print "failed! #{e.message}\n"
|
||||
$strerr.print "#{e.backtrace.join("\n")}" unless opts.quiet
|
||||
end
|
||||
end
|
||||
|
||||
# Attempt to decypher the menu
|
||||
#
|
||||
menustr = TmSubmenu::main_menu_to_lisp(info_plist, modename) if info_plist
|
||||
puts menustr if $DEBUG
|
||||
|
||||
# Write some basic .yas-* files
|
||||
#
|
||||
if opts.output_dir
|
||||
FileUtils.mkdir_p opts.output_dir
|
||||
FileUtils.touch File.join(original_dir, opts.output_dir, ".yas-make-groups") unless menustr
|
||||
|
||||
# Now, output head + a new tail in (possibly new) .yas-setup.el
|
||||
# file
|
||||
#
|
||||
File.open yas_setup_el_file, 'w' do |file|
|
||||
file.puts head
|
||||
file.puts separator
|
||||
file.puts ";; Automatically generated code, do not edit this part"
|
||||
file.puts ";; "
|
||||
file.puts ";; Translated menu"
|
||||
file.puts ";; "
|
||||
file.puts menustr
|
||||
file.puts
|
||||
file.puts ";; Unknown substitutions"
|
||||
file.puts ";; "
|
||||
["content", "condition", "binding"].each do |type|
|
||||
file.puts ";; Substitutions for: #{type}"
|
||||
file.puts ";; "
|
||||
# TmSnippet::extra_substitutions[type].
|
||||
# each_pair do |k,v|
|
||||
# file.puts ";; " + k + "" + (" " * [1, 90-k.length].max) + " =yyas> " + v
|
||||
# end
|
||||
unknown = TmSnippet::unknown_substitutions[type];
|
||||
unknown.keys.uniq.each do |k|
|
||||
file.puts ";; # as in " + unknown[k].yas_file
|
||||
file.puts ";; " + k + "" + (" " * [1, 90-k.length].max) + " =yyas> (yas-unknown)"
|
||||
file.puts ";; "
|
||||
end
|
||||
file.puts ";; "
|
||||
file.puts
|
||||
end
|
||||
file.puts ";; .yas-setup.el for #{modename} ends here"
|
||||
end
|
||||
end
|
||||
end
|
1
snippets/c++-mode/.yas-parents
Normal file
1
snippets/c++-mode/.yas-parents
Normal file
@ -0,0 +1 @@
|
||||
cc-mode
|
4
snippets/c++-mode/beginend
Normal file
4
snippets/c++-mode/beginend
Normal file
@ -0,0 +1,4 @@
|
||||
# name: v.begin(), v.end()
|
||||
# key: beginend
|
||||
# --
|
||||
${1:v}.begin(), $1.end
|
9
snippets/c++-mode/class
Normal file
9
snippets/c++-mode/class
Normal file
@ -0,0 +1,9 @@
|
||||
# name: class ... { ... }
|
||||
# key: class
|
||||
# --
|
||||
class ${1:Name}
|
||||
{
|
||||
public:
|
||||
${1:$(yas-substr text "[^: ]*")}($2);
|
||||
virtual ~${1:$(yas-substr text "[^: ]*")}();
|
||||
};
|
4
snippets/c++-mode/ns
Normal file
4
snippets/c++-mode/ns
Normal file
@ -0,0 +1,4 @@
|
||||
# name: namespace ...
|
||||
# key: ns
|
||||
# --
|
||||
namespace
|
4
snippets/c++-mode/template
Normal file
4
snippets/c++-mode/template
Normal file
@ -0,0 +1,4 @@
|
||||
# name: template <typename ...>
|
||||
# key: template
|
||||
# --
|
||||
template <typename ${T}>
|
5
snippets/c++-mode/using
Normal file
5
snippets/c++-mode/using
Normal file
@ -0,0 +1,5 @@
|
||||
# name: using namespace ...
|
||||
# key: using
|
||||
# --
|
||||
using namespace ${std};
|
||||
$0
|
1
snippets/c-mode/.yas-parents
Normal file
1
snippets/c-mode/.yas-parents
Normal file
@ -0,0 +1 @@
|
||||
cc-mode
|
4
snippets/c-mode/fopen
Normal file
4
snippets/c-mode/fopen
Normal file
@ -0,0 +1,4 @@
|
||||
# name: FILE *fp = fopen(..., ...);
|
||||
# key: fopen
|
||||
# --
|
||||
FILE *${fp} = fopen(${"file"}, "${r}");
|
7
snippets/c-mode/printf
Normal file
7
snippets/c-mode/printf
Normal file
@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: printf
|
||||
# contributor: joaotavora
|
||||
# key: printf
|
||||
# --
|
||||
printf ("${1:%s}\\n"${1:$(if (string-match "%" text) "," "\);")
|
||||
}$2${1:$(if (string-match "%" text) "\);" "")}
|
1
snippets/cc-mode/.yas-parents
Normal file
1
snippets/cc-mode/.yas-parents
Normal file
@ -0,0 +1 @@
|
||||
text-mode
|
7
snippets/cc-mode/do
Normal file
7
snippets/cc-mode/do
Normal file
@ -0,0 +1,7 @@
|
||||
# name: do { ... } while (...)
|
||||
# key: do
|
||||
# --
|
||||
do
|
||||
{
|
||||
$0
|
||||
} while (${1:condition});
|
7
snippets/cc-mode/for
Normal file
7
snippets/cc-mode/for
Normal file
@ -0,0 +1,7 @@
|
||||
# name: for (...; ...; ...) { ... }
|
||||
# key: for
|
||||
# --
|
||||
for (${1:int i = 0}; ${2:i < N}; ${3:++i})
|
||||
{
|
||||
$0
|
||||
}
|
7
snippets/cc-mode/if
Normal file
7
snippets/cc-mode/if
Normal file
@ -0,0 +1,7 @@
|
||||
# name: if (...) { ... }
|
||||
# key: if
|
||||
# --
|
||||
if (${1:condition})
|
||||
{
|
||||
$0
|
||||
}
|
4
snippets/cc-mode/inc
Normal file
4
snippets/cc-mode/inc
Normal file
@ -0,0 +1,4 @@
|
||||
# name: #include "..."
|
||||
# key: inc
|
||||
# --
|
||||
#include "$1"
|
4
snippets/cc-mode/inc.1
Normal file
4
snippets/cc-mode/inc.1
Normal file
@ -0,0 +1,4 @@
|
||||
# name: #include <...>
|
||||
# key: inc
|
||||
# --
|
||||
#include <$1>
|
8
snippets/cc-mode/main
Normal file
8
snippets/cc-mode/main
Normal file
@ -0,0 +1,8 @@
|
||||
# name: int main(argc, argv) { ... }
|
||||
# key: main
|
||||
# --
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
$0
|
||||
return 0;
|
||||
}
|
9
snippets/cc-mode/once
Normal file
9
snippets/cc-mode/once
Normal file
@ -0,0 +1,9 @@
|
||||
# name: #ifndef XXX; #define XXX; #endif
|
||||
# key: once
|
||||
# --
|
||||
#ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_}
|
||||
#define $1
|
||||
|
||||
$0
|
||||
|
||||
#endif /* $1 */
|
7
snippets/cc-mode/struct
Normal file
7
snippets/cc-mode/struct
Normal file
@ -0,0 +1,7 @@
|
||||
# name: struct ... { ... }
|
||||
# key: struct
|
||||
# --
|
||||
struct ${1:name}
|
||||
{
|
||||
$0
|
||||
};
|
1
snippets/cperl-mode/.yas-parents
Normal file
1
snippets/cperl-mode/.yas-parents
Normal file
@ -0,0 +1 @@
|
||||
perl-mode
|
1
snippets/csharp-mode/.yas-parents
Normal file
1
snippets/csharp-mode/.yas-parents
Normal file
@ -0,0 +1 @@
|
||||
cc-mode
|
8
snippets/csharp-mode/attrib
Normal file
8
snippets/csharp-mode/attrib
Normal file
@ -0,0 +1,8 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: private attribute ....;
|
||||
# key: attrib
|
||||
# --
|
||||
/// <summary>
|
||||
/// $3
|
||||
/// </summary>
|
||||
private $1 $2;
|
22
snippets/csharp-mode/attrib.1
Normal file
22
snippets/csharp-mode/attrib.1
Normal file
@ -0,0 +1,22 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: private attribute ....; public property ... ... { ... }
|
||||
# key: attrib
|
||||
# --
|
||||
/// <summary>
|
||||
/// $3
|
||||
/// </summary>
|
||||
private $1 $2;
|
||||
|
||||
/// <summary>
|
||||
/// $4
|
||||
/// </summary>
|
||||
/// <value>$5</value>
|
||||
public $1 $2
|
||||
{
|
||||
get {
|
||||
return this.$2;
|
||||
}
|
||||
set {
|
||||
this.$2 = value;
|
||||
}
|
||||
}
|
22
snippets/csharp-mode/attrib.2
Normal file
22
snippets/csharp-mode/attrib.2
Normal file
@ -0,0 +1,22 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: private _attribute ....; public Property ... ... { ... }
|
||||
# key: attrib
|
||||
# --
|
||||
/// <summary>
|
||||
/// $3
|
||||
/// </summary>
|
||||
private $1 ${2:$(if (> (length text) 0) (format "_%s%s" (downcase (substring text 0 1)) (substring text 1 (length text))) "")};
|
||||
|
||||
/// <summary>
|
||||
/// ${3:Description}
|
||||
/// </summary>
|
||||
/// <value><c>$1</c></value>
|
||||
public ${1:Type} ${2:Name}
|
||||
{
|
||||
get {
|
||||
return this.${2:$(if (> (length text) 0) (format "_%s%s" (downcase (substring text 0 1)) (substring text 1 (length text))) "")};
|
||||
}
|
||||
set {
|
||||
this.${2:$(if (> (length text) 0) (format "_%s%s" (downcase (substring text 0 1)) (substring text 1 (length text))) "")} = value;
|
||||
}
|
||||
}
|
22
snippets/csharp-mode/class
Normal file
22
snippets/csharp-mode/class
Normal file
@ -0,0 +1,22 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: class ... { ... }
|
||||
# key: class
|
||||
# --
|
||||
${5:public} class ${1:Name}
|
||||
{
|
||||
#region Ctor & Destructor
|
||||
/// <summary>
|
||||
/// ${3:Standard Constructor}
|
||||
/// </summary>
|
||||
public $1($2)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ${4:Default Destructor}
|
||||
/// </summary>
|
||||
public ~$1()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
7
snippets/csharp-mode/comment
Normal file
7
snippets/csharp-mode/comment
Normal file
@ -0,0 +1,7 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: /// <summary> ... </summary>
|
||||
# key: comment
|
||||
# --
|
||||
/// <summary>
|
||||
/// $1
|
||||
/// </summary>
|
5
snippets/csharp-mode/comment.1
Normal file
5
snippets/csharp-mode/comment.1
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: /// <param name="..."> ... </param>
|
||||
# key: comment
|
||||
# --
|
||||
/// <param name="$1">$2</param>
|
5
snippets/csharp-mode/comment.2
Normal file
5
snippets/csharp-mode/comment.2
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: /// <param name="..."> ... </param>
|
||||
# key: comment
|
||||
# --
|
||||
/// <returns>$1</returns>
|
5
snippets/csharp-mode/comment.3
Normal file
5
snippets/csharp-mode/comment.3
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: /// <exception cref="..."> ... </exception>
|
||||
# key: comment
|
||||
# --
|
||||
/// <exception cref="$1">$2</exception>
|
11
snippets/csharp-mode/method
Normal file
11
snippets/csharp-mode/method
Normal file
@ -0,0 +1,11 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: public void Method { ... }
|
||||
# key: method
|
||||
# --
|
||||
/// <summary>
|
||||
/// ${5:Description}
|
||||
/// </summary>${2:$(if (string= (upcase text) "VOID") "" (format "%s%s%s" "\n/// <returns><c>" text "</c></returns>"))}
|
||||
${1:public} ${2:void} ${3:MethodName}($4)
|
||||
{
|
||||
$0
|
||||
}
|
8
snippets/csharp-mode/namespace
Normal file
8
snippets/csharp-mode/namespace
Normal file
@ -0,0 +1,8 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: namespace .. { ... }
|
||||
# key: namespace
|
||||
# --
|
||||
namespace $1
|
||||
{
|
||||
$0
|
||||
}
|
17
snippets/csharp-mode/prop
Normal file
17
snippets/csharp-mode/prop
Normal file
@ -0,0 +1,17 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: property ... ... { ... }
|
||||
# key: prop
|
||||
# --
|
||||
/// <summary>
|
||||
/// $5
|
||||
/// </summary>
|
||||
/// <value>$6</value>
|
||||
$1 $2 $3
|
||||
{
|
||||
get {
|
||||
return this.$4;
|
||||
}
|
||||
set {
|
||||
this.$4 = value;
|
||||
}
|
||||
}
|
7
snippets/csharp-mode/region
Normal file
7
snippets/csharp-mode/region
Normal file
@ -0,0 +1,7 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: #region ... #endregion
|
||||
# key: region
|
||||
# --
|
||||
#region $1
|
||||
$0
|
||||
#endregion
|
5
snippets/csharp-mode/using
Normal file
5
snippets/csharp-mode/using
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: using ...;
|
||||
# key: using
|
||||
# --
|
||||
using $1;
|
5
snippets/csharp-mode/using.1
Normal file
5
snippets/csharp-mode/using.1
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: using System;
|
||||
# key: using
|
||||
# --
|
||||
using System;
|
5
snippets/csharp-mode/using.2
Normal file
5
snippets/csharp-mode/using.2
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: Alejandro Espinoza Esparza <aespinoza@structum.com.mx>
|
||||
# name: using System....;
|
||||
# key: using
|
||||
# --
|
||||
using System.$1;
|
1
snippets/css-mode/.yas-parents
Normal file
1
snippets/css-mode/.yas-parents
Normal file
@ -0,0 +1 @@
|
||||
text-mode
|
4
snippets/css-mode/bg
Normal file
4
snippets/css-mode/bg
Normal file
@ -0,0 +1,4 @@
|
||||
# name: background-color: ...
|
||||
# key: bg
|
||||
# --
|
||||
background-color: #${1:DDD};
|
4
snippets/css-mode/bg.1
Normal file
4
snippets/css-mode/bg.1
Normal file
@ -0,0 +1,4 @@
|
||||
# name: background-image: ...
|
||||
# key: bg
|
||||
# --
|
||||
background-image: url($1);
|
4
snippets/css-mode/bor
Normal file
4
snippets/css-mode/bor
Normal file
@ -0,0 +1,4 @@
|
||||
# name: border size style color
|
||||
# key: bor
|
||||
# --
|
||||
border: ${1:1px} ${2:solid} #${3:999};
|
5
snippets/css-mode/cl
Normal file
5
snippets/css-mode/cl
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: clear: ...
|
||||
# key: cl
|
||||
# --
|
||||
clear: $1;
|
5
snippets/css-mode/disp.block
Normal file
5
snippets/css-mode/disp.block
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: display: block
|
||||
# key: disp
|
||||
# --
|
||||
display: block;
|
5
snippets/css-mode/disp.inline
Normal file
5
snippets/css-mode/disp.inline
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: display: inline
|
||||
# key: disp
|
||||
# --
|
||||
display: inline;
|
5
snippets/css-mode/disp.none
Normal file
5
snippets/css-mode/disp.none
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: display: none
|
||||
# key: disp
|
||||
# --
|
||||
display: none;
|
5
snippets/css-mode/ff
Normal file
5
snippets/css-mode/ff
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: font-family: ...
|
||||
# key: ff
|
||||
# --
|
||||
font-family: $1;
|
5
snippets/css-mode/fs
Normal file
5
snippets/css-mode/fs
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: font-size: ...
|
||||
# key: fs
|
||||
# --
|
||||
font-size: ${12px};
|
5
snippets/css-mode/mar.bottom
Normal file
5
snippets/css-mode/mar.bottom
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: margin-bottom: ...
|
||||
# key: mar
|
||||
# --
|
||||
margin-bottom: $1;
|
5
snippets/css-mode/mar.left
Normal file
5
snippets/css-mode/mar.left
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: margin-left: ...
|
||||
# key: mar
|
||||
# --
|
||||
margin-left: $1;
|
5
snippets/css-mode/mar.mar
Normal file
5
snippets/css-mode/mar.mar
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: margin: ...
|
||||
# key: mar
|
||||
# --
|
||||
margin: $1;
|
5
snippets/css-mode/mar.margin
Normal file
5
snippets/css-mode/mar.margin
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: margin top right bottom left
|
||||
# key: mar
|
||||
# --
|
||||
margin: ${top} ${right} ${bottom} ${left};
|
5
snippets/css-mode/mar.right
Normal file
5
snippets/css-mode/mar.right
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: margin-right: ...
|
||||
# key: mar
|
||||
# --
|
||||
margin-right: $1;
|
5
snippets/css-mode/mar.top
Normal file
5
snippets/css-mode/mar.top
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: margin-top: ...
|
||||
# key: mar
|
||||
# --
|
||||
margin-top: $1;
|
5
snippets/css-mode/pad.bottom
Normal file
5
snippets/css-mode/pad.bottom
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: padding-bottom: ...
|
||||
# key: pad
|
||||
# --
|
||||
padding-bottom: $1;
|
5
snippets/css-mode/pad.left
Normal file
5
snippets/css-mode/pad.left
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: padding-left: ...
|
||||
# key: pad
|
||||
# --
|
||||
padding-left: $1;
|
5
snippets/css-mode/pad.pad
Normal file
5
snippets/css-mode/pad.pad
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: padding: ...
|
||||
# key: pad
|
||||
# --
|
||||
padding: $1;
|
5
snippets/css-mode/pad.padding
Normal file
5
snippets/css-mode/pad.padding
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: padding: top right bottom left
|
||||
# key: pad
|
||||
# --
|
||||
padding: ${top} ${right} ${bottom} ${left};
|
5
snippets/css-mode/pad.right
Normal file
5
snippets/css-mode/pad.right
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: padding-right: ...
|
||||
# key: pad
|
||||
# --
|
||||
padding-right: $1;
|
5
snippets/css-mode/pad.top
Normal file
5
snippets/css-mode/pad.top
Normal file
@ -0,0 +1,5 @@
|
||||
# contributor: rejeep <johan.rejeep@gmail.com>
|
||||
# name: padding-top: ...
|
||||
# key: pad
|
||||
# --
|
||||
padding-top: $1;
|
7
snippets/emacs-lisp-mode/.read_me
Normal file
7
snippets/emacs-lisp-mode/.read_me
Normal file
@ -0,0 +1,7 @@
|
||||
-*- coding: utf-8 -*-
|
||||
Originally started by Xah Lee (xahlee.org) on 2009-02-22
|
||||
Released under GPL 3.
|
||||
|
||||
Feel free to add missing ones or modify existing ones to improve.
|
||||
|
||||
Those starting with “x-” are supposed to be idiom templates. Not sure it's very useful. They might start with “i-” or "id-" in the future.
|
1
snippets/emacs-lisp-mode/.yas-parents
Normal file
1
snippets/emacs-lisp-mode/.yas-parents
Normal file
@ -0,0 +1 @@
|
||||
text-mode
|
6
snippets/emacs-lisp-mode/add-hook.yasnippet
Executable file
6
snippets/emacs-lisp-mode/add-hook.yasnippet
Executable file
@ -0,0 +1,6 @@
|
||||
# contributor: Xah Lee (XahLee.org)
|
||||
# name: add-hook
|
||||
# key: add-hook
|
||||
# key: ah
|
||||
# --
|
||||
(add-hook HOOK$0 FUNCTION)
|
6
snippets/emacs-lisp-mode/and.yasnippet
Executable file
6
snippets/emacs-lisp-mode/and.yasnippet
Executable file
@ -0,0 +1,6 @@
|
||||
# contributor: Xah Lee (XahLee.org)
|
||||
# name: and
|
||||
# key: and
|
||||
# key: a
|
||||
# --
|
||||
(and $0)
|
5
snippets/emacs-lisp-mode/append.yasnippet
Executable file
5
snippets/emacs-lisp-mode/append.yasnippet
Executable file
@ -0,0 +1,5 @@
|
||||
# contributor: Xah Lee (XahLee.org)
|
||||
# name: append
|
||||
# key: append
|
||||
# --
|
||||
(append $0 )
|
5
snippets/emacs-lisp-mode/apply.yasnippet
Executable file
5
snippets/emacs-lisp-mode/apply.yasnippet
Executable file
@ -0,0 +1,5 @@
|
||||
# contributor: Xah Lee (XahLee.org)
|
||||
# name: apply
|
||||
# key: apply
|
||||
# --
|
||||
(apply $0 )
|
5
snippets/emacs-lisp-mode/aref.yasnippet
Executable file
5
snippets/emacs-lisp-mode/aref.yasnippet
Executable file
@ -0,0 +1,5 @@
|
||||
# contributor: Xah Lee (XahLee.org)
|
||||
# name: aref
|
||||
# key: aref
|
||||
# --
|
||||
(aref ARRAY$0 INDEX)
|
5
snippets/emacs-lisp-mode/aset.yasnippet
Executable file
5
snippets/emacs-lisp-mode/aset.yasnippet
Executable file
@ -0,0 +1,5 @@
|
||||
# contributor: Xah Lee (XahLee.org)
|
||||
# name: aset
|
||||
# key: aset
|
||||
# --
|
||||
(aset ARRAY$0 IDX NEWELT)
|
5
snippets/emacs-lisp-mode/assq.yasnippet
Executable file
5
snippets/emacs-lisp-mode/assq.yasnippet
Executable file
@ -0,0 +1,5 @@
|
||||
# contributor: Xah Lee (XahLee.org)
|
||||
# name: assq
|
||||
# key: assq
|
||||
# --
|
||||
(assq KEY$0 LIST)
|
5
snippets/emacs-lisp-mode/autoload.yasnippet
Executable file
5
snippets/emacs-lisp-mode/autoload.yasnippet
Executable file
@ -0,0 +1,5 @@
|
||||
# contributor: Xah Lee (XahLee.org)
|
||||
# name: autoload
|
||||
# key: autoload
|
||||
# --
|
||||
(autoload 'FUNCNAME$0 "FILENAME" &optional "DOCSTRING" INTERACTIVE TYPE)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user