GNOME Bugzilla – Bug 460523
document snippets additional functionality
Last modified: 2019-09-29 18:32:26 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)
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) > =========
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/
*** Bug 453496 has been marked as a duplicate of this bug. ***
Other things to add: - syntax changes mentioned in bug #452586
*** Bug 452586 has been marked as a duplicate of this bug. ***
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. :)
The mallard snippets have been merged into master for gedit 3.8.
Hi, is this bug resolved now?
Following up - with the mallard snippets being merged, is this bug now resolved?
No replies, let's assume so.