After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 460523 - document snippets additional functionality
document snippets additional functionality
Status: RESOLVED FIXED
Product: gedit
Classification: Applications
Component: docs
git master
Other Linux
: Normal normal
: ---
Assigned To: Maintainers of Gnome user documentation
Gedit maintainers
: 452586 453496 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-07-26 10:29 UTC by jessevdk@gmail.com
Modified: 2019-09-29 18:32 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description jessevdk@gmail.com 2007-07-26 10:29:19 UTC
Some functionality of snippets is currently not yet documented. Dnd has been added so that snippets can be activated by dropping files in a view. You can specify which mime-types a snippets should be activated with in the snippets manager. Multiple mime types can be specified delimited with comma's. You can also drop a file on the entry which will add the mime type of that file. The entry is a combo box with some basic mime-types which is just a convenient way to lookup most basic mime types.

Currently, if there are more snippets with the same mime-type, then only one snippet (the first found) is activated. With multiple files, every file is looked up and snippets are inserted in order.

Another thing that's a bit related to this, is that there are special functions that can be used in python placeholders. These are:

 - align(table): returns a string that when inserted in the view all items align like as in a table (the table is in the format [row1, row2, row3], with row = [col1, col2, col3])
 - readfile(filename): returns a string with the contents of the file 'filename'. This also works for remote files (uses gnomevfs)
 - filesize(filename): returns a number with the size in bytes of the file 'filename'. This also works for remote files (uses gnomevfs)
Comment 1 jessevdk@gmail.com 2007-07-26 10:39:56 UTC
I forgot to mention that there are some new environmental variables you can use in snippets activated by dnd:

- $GEDIT_DROP_FILENAME: the absolute filename of the dropped file
- $GEDIT_DROP_REL_FILENAME: the filename of the dropped file relative to the current document. This will try to resolve the relative location by matching the common prefix of both the current document and the dropped file. It inserts ../ for each level that the current document doesn't share with the dropped file, but only for 3 levels. If the difference is more than 3 levels this variable will contain the absolute path. It will also contain the absolute path if the protocols of the files differ (say file:// and http://). For a dropped directory, it will contain ./ if the dropped directory is the same as the directory the current document is in. If the document is unsaved, it will contain the absolute path
- $GEDIT_DROP_MIME_TYPE: the mime type of the dropped file

A snippet example:

Filename:          ${1:$GEDIT_DROP_FILENAME}
Relative filename: ${2:$GEDIT_DROP_REL_FILENAME}
Mime type:         ${3:$GEDIT_DROP_MIME_TYPE}

Contents ($< return filesize($GEDIT_DROP_FILENAME) >):
=========
$< return readfile($GEDIT_DROP_FILENAME) >
=========
Comment 2 Paolo Borelli 2009-12-29 14:23:01 UTC
I am putting all missing snippet documentation in a single bug.


Other things that need to be documented are:

 - regex placehoders (see bug #453496 which I am marking as duplicate)
 - things mentioned here http://blogs.gnome.org/jessevdk/2009/12/06/about-snippets/
Comment 3 Paolo Borelli 2009-12-29 14:23:52 UTC
*** Bug 453496 has been marked as a duplicate of this bug. ***
Comment 4 Paolo Borelli 2009-12-31 12:32:56 UTC
Other things to add:

 - syntax changes mentioned in bug #452586
Comment 5 Paolo Borelli 2009-12-31 12:33:15 UTC
*** Bug 452586 has been marked as a duplicate of this bug. ***
Comment 6 Jim Campbell 2013-02-23 09:13:19 UTC
Updating Mallard Snippets in gedit to include work from Jaromir Hradilek. 

See here: https://mail.gnome.org/archives/gnome-doc-list/2013-February/msg00007.html

Assigned to Jim Campbell. :)
Comment 7 Jim Campbell 2013-02-27 17:29:24 UTC
The mallard snippets have been merged into master for gedit 3.8.
Comment 8 Kat 2014-02-12 20:50:09 UTC
Hi, is this bug resolved now?
Comment 9 Paul Cutler 2017-03-19 21:33:53 UTC
Following up - with the mallard snippets being merged, is this bug now resolved?
Comment 10 André Klapper 2019-09-29 18:32:26 UTC
No replies, let's assume so.