Manual
Smarty Mode Manual
1. Introduction
Smarty-Mode is a mode allowing easy edit of Smarty templates: highlight, templates, navigation
into source files...
Features (new features in bold) :
-
Completion
-
Customizable
-
Highlight
-
Menu
-
Stuttering
-
Templates
- -
Fonctions natives
- -
Fonctions utilisateur
- -
Modificateurs de variable
- -
Plugin
-
Smarty Formtool
-
Smarty Paginate
-
Smarty Validate
- -
Fonctions Non-Smarty
This manual describes Smarty Mode version 0.0.2.
2. Installation
2.1 Requirements
Smarty Mode is a XEmacs major mode that needs the following software/packages:
-
XEmacs.
-
`font-lock' mode generaly installed with XEmacs.
-
`assoc' mode generaly installed with XEmacs.
-
`easymenu' mode generaly installed with XEmacs.
-
`hippie-exp' mode generaly installed with XEmacs.
Before continuing, you must be sure to have all this packages installed.
2.2 Download
Two internet address to download Smarty Mode :
2.3 Installation
2.3.1 Installation
To install Smarty Mode you need to choose an installation directory (for example
`/usr/local/share/lisp' or `c:\lisp'). The administrator must have the write rights on
this directory.
With your favorite unzip software, unzip the archive in the installation directory.
Example:
| cd /usr/local/share/lisp
tar zxvf smarty-0.0.2.tar.gz
|
Now you have a `smarty' directory in the installation directory. This directory contains 2 files
`smarty-mode.el' and `smarty-mode.elc' and another directory `docs' containing the documentation.
You need to configure XEmacs. open you initialization file `init.el' (open the file or start
XEmacs then choose the Options menu and Edit Init File). Add the following lines
(the installation directory in this example is `/usr/local/share/lisp') :
| (setq load-path
(append (list "/usr/local/share/lisp/") load-path))
(autoload 'smarty-mode "smarty-mode" "Smarty Mode" t)
|
2.3.2 Update
The update is easy. You need to unzip the archive in the installation directory to remove the
old release.
Example:
| cd /usr/local/share/lisp
rm -rf smarty
tar zxvf smarty-0.0.2.tar.gz
|
2.4 Invoke Smarty-Mode
You have two possibilities to invoke the Smarty Mode.
- -
Manually: At each file opening you need to launch Smarty Mode with the following command:
M-x smarty-mode
- -
Automatically: Add the following linesin your initialization file `init.el' :
| (setq auto-mode-alist
(append
'(("\\.tpl$" . smarty-mode))
auto-mode-alist))
|
3. Customization
This chapter describes the differents parameters and functions that you can change to customize Smarty Mode.
To do that, open a Smarty file, click on the Smarty menu and choose Options
then Browse Options....
3.1 Parameters
3.1.1 Mode
Smarty Mode has 2 modes allowing to simplify the writing of Smarty templates. You can enable/disable
each mode individually.
-
- `smarty-electric-mode'
Type: boolean
Default value: `t'
Description: If `t'; enable automatic generation of template.
If `nil'; template generators can still be invoked through key bindings and
menu. Is indicated in the modeline by "/e" after the mode name and can be
toggled by `smarty-electric-mode'.
- `smarty-stutter-mode'
Type: boolean
Default value: `t'
Description: If `t'; enable the stuttering. Is indicated in
the modeline by "/s" after the mode name and can be toggled by `smarty-stutter-mode'.
3.1.2 Menu
Smarty Mode has also 1 menu that you can enable/disable. The menu Sources
is specific to each Smarty files opened.
-
- `smarty-source-file-menu'
Type: boolean
Default value: `t'
Description: If `t'; the Sources menu is enabled. This
menu contains the list of Smarty file located in the current directory. The Sources menu scans
the directory when a file is opened.
3.1.3 Menu
-
- `smarty-highlight-plugin-functions'
Type: boolean
Default value: `t'
Description: If `t'; the functions described
in the smarty plugins are highlighted.
3.1.4 Templates
3.1.4.1 Header
-
- `smarty-file-header'
Type: string
Default value: `""'
Description: String or file to insert as file header. If the string specifies an existing file name the contents
of the file is inserted; otherwise the string itself is inserted as file header.
Type `C-j' for newlines.
The follonwing keywords are supported: <filename>: replaced by
the file name. <author>: replaced by the user name and email address. <login>:
replaced by `user-login-name'. <company>: replaced by `smarty-company-name' content. <date>:
replaced by the current date. <year>: replaced by the current year. <copyright>: replaced by
`smarty-copyright-string' content. <cursor>: final cursor position.
- `smarty-file-footer'
Type: string
Default value: `""'
Description: String or file to insert as file footer.
See `smarty-file-header'
- `smarty-company-name'
Type: string
Default value: `""'
Description: Name of the company to insert in file header.
- `smarty-copyright-string'
Type: string
Default value: `""'
Description: Coryright string to insert in file header.
- `smarty-date-format'
Type: string
Default value: `"%Y-%m-%d"'
Description: Date format.
- `smarty-modify-date-prefix-string'
Type: string
Default value: `""'
Description: Prefix string of
modification date in Smarty file header.
- `smarty-modify-date-on-saving'
Type: bool
Default value: `nil'
Description: If `t'; update the modification date
when the buffer is saved.
3.1.5 Miscellaneous
-
- `smarty-left-delimiter'
Type: string
Default value: `""'
Description: Left escaping delimiter for Smarty templates.
- `smarty-right-delimiter'
Type: string
Default value: `""'
Description: Right escaping delimiter for Smarty templates.
- `smarty-intelligent-tab'
Type: bool
Default value: `t'
Description: If `t'; TAB does indentation; completion and
insert tabulations. If `nil'; TAB does only indentation.
- `smarty-word-completion-in-minibuffer'
Type: bool
Default value: `t'
Description: If `t'; enable completion in the
minibuffer.
- `smarty-word-completion-case-sensitive'
Type: bool
Default value: `nil'
Description: If `t'; completion is case
sensitive.
3.2 Functions
3.2.1 Mode
-
- `smarty-electric-mode'
Menu: Smarty -> Options -> Mode -> Electric Mode
Keybinding: C-c C-m C-e
Description: This functions is used to enable/disable the electric mode.
- `smarty-stutter-mode'
Menu: Smarty -> Options -> Mode -> Stutter Mode
Keybinding: C-c C-m C-s
Description: This function is used to enable/disable the stutter mode.
4. Menus
There are 2 menus: Smarty and Sources. All theses menus can be accessed
from the menubar or from the right click. This chapter describes each menus.
4.1 Smarty
This is the main menu of Smarty Mode. It allows an easy access to the main features of the Smarty Mode:
Templates (see Templates) and Options (see Customization).
This menu contains also 3 functions that are discussed in the next part.
4.1.1 Functions
-
- `smarty-show-messages'
Menu: Smarty -> Show Messages
Keybinding: C-c M-m
Description: This function opens the *Messages* buffer to display previous error messages.
- `smarty-doc-mode'
Menu: Smarty -> Smarty Mode Documentation
Keybinding: C-c C-h
Description: This function opens the *Help* buffer and prints in it the Smarty Mode documentation.
- `smarty-version'
Menu: Smarty -> Version
Keybinding: C-c C-v
Description: This function displays in the minibuffer the current Smarty Mode version with the timestamp.
4.2 Sources
The Sources menu shows the Smarty files in the current directory. If you add or delete a file in
the current directory, you need to refresh the menu.
4.2.1 Customization
-
- `smarty-source-file-menu'
Type: boolean
Default value: `t'
Description: If `t'; the Sources menu is enabled. This
menu contains the list of Smarty file located in the current directory. The Sources menu scans
the directory when a file is opened.
4.2.2 Functions
-
- `smarty-add-source-files-menu'
Menu: Sources -> *Rescan*
Keybinding: C-c C-s C-u
Description: This function is used to refresh the Sources menu.
5. Stuttering
The stutter mode is a mode that affects a function to a key. For example, when you use the ENTER
key, the associated function will create a new line and indent it.
5.1 Customization
-
- `smarty-stutter-mode'
Type: boolean
Default value: `t'
Description: If `t'; enable the stuttering. Is indicated in
the modeline by "/s" after the mode name and can be toggled by `smarty-stutter-mode'.
5.2 Functions
-
- SPACE
If in comment, indent the comment and add new line if necessary.
In other case, add a space.
- (
If the previous character is a `(', the `((' will be replaced by `['.
If the previous character is a `[', the `[(' will be replaced by `{'.
In other case, insert a `('.
- )
If the previous character is a `)', the `))' will be replaced by `]'.
If the previous character is a `]', the `])' will be replaced by `}'.
In other case, insert a `)'.
6. Templates
In the Smarty Mode, the Smarty functions (like if, while, for, fopen, fclose) are predefined in functions
called "Templates".
Each template can be invoked by the function name or by using the SPACE
key after the Smarty function name in the buffer (Note, using M-SPACE disable the template).
A template can be aborted by using the C-g or by lefting empty the tempate prompt (in the minibuffer).
6.1 Customization
-
- `smarty-electric-mode'
Type: boolean
Default value: `t'
Description: If `t'; enable automatic generation of template.
If `nil'; template generators can still be invoked through key bindings and
menu. Is indicated in the modeline by "/e" after the mode name and can be
toggled by `smarty-electric-mode'.
For a complete description of the template customizable variables, see Templates
6.2 Functions
6.2.1 Built-in Functions
-
- `smarty-template-capture'
Menu: Smarty -> Templates -> Build-in Functions -> capture
Keybinding: C-c C-t C-b a
Description: See the manual.
- `smarty-template-config-load'
Menu: Smarty -> Templates -> Build-in Functions -> config_load
Keybinding: C-c C-t C-b c
Description: See the manual.
- `smarty-template-else'
Menu: Smarty -> Templates -> Build-in Functions -> else
Keybinding: C-c C-t C-b M-e
Description: See the manual.
- `smarty-template-elseif'
Menu: Smarty -> Templates -> Build-in Functions -> elseif
Keybinding: C-c C-t C-b C-e
Description: See the manual.
- `smarty-template-foreach'
Menu: Smarty -> Templates -> Build-in Functions -> foreach
Keybinding: C-c C-t C-b C-f
Description: See the manual.
- `smarty-template-foreachelse'
Menu: Smarty -> Templates -> Build-in Functions -> foreachelse
Keybinding: C-c C-t C-b M-f
Description: See the manual.
- `smarty-template-if'
Menu: Smarty -> Templates -> Build-in Functions -> if
Keybinding: C-c C-t C-b f
Description: See the manual.
- `smarty-template-include'
Menu: Smarty -> Templates -> Build-in Functions -> include
Keybinding: C-c C-t C-b C-i
Description: See the manual.
- `smarty-template-include-php'
Menu: Smarty -> Templates -> Build-in Functions -> include_php
Keybinding: C-c C-t C-b M-i
Description: See the manual.
- `smarty-template-insert'
Menu: Smarty -> Templates -> Build-in Functions -> insert
Keybinding: C-c C-t C-b i
Description: See the manual.
- `smarty-template-ldelim'
Menu: Smarty -> Templates -> Build-in Functions -> ldelim
Keybinding: C-c C-t C-b l
Description: See the manual.
- `smarty-template-literal'
Menu: Smarty -> Templates -> Build-in Functions -> literal
Keybinding: C-c C-t C-b C-l
Description: See the manual.
- `smarty-template-php'
Menu: Smarty -> Templates -> Build-in Functions -> php
Keybinding: C-c C-t C-b p
Description: See the manual.
- `smarty-template-rdelim'
Menu: Smarty -> Templates -> Build-in Functions -> rdelim
Keybinding: C-c C-t C-b r
Description: See the manual.
- `smarty-template-section'
Menu: Smarty -> Templates -> Build-in Functions -> section
Keybinding: C-c C-t C-b C-s
Description: See the manual.
- `smarty-template-sectionelse'
Menu: Smarty -> Templates -> Build-in Functions -> sectionelse
Keybinding: C-c C-t C-b M-s
Description: See the manual.
- `smarty-template-strip'
Menu: Smarty -> Templates -> Build-in Functions -> strip
Keybinding: C-c C-t C-b s
Description: See the manual.
6.2.2 Custom Functions
-
- `smarty-template-assign'
Menu: Smarty -> Templates -> Custom Functions -> assign
Keybinding: C-c C-t C-c a
Description: See the manual.
- `smarty-template-counter'
Menu: Smarty -> Templates -> Custom Functions -> counter
Keybinding: C-c C-t C-c o
Description: See the manual.
- `smarty-template-cycle'
Menu: Smarty -> Templates -> Custom Functions -> cycle
Keybinding: C-c C-t C-c c
Description: See the manual.
- `smarty-template-debug'
Menu: Smarty -> Templates -> Custom Functions -> debug
Keybinding: C-c C-t C-c d
Description: See the manual.
- `smarty-template-eval'
Menu: Smarty -> Templates -> Custom Functions -> eval
Keybinding: C-c C-t C-c e
Description: See the manual.
- `smarty-template-fetch'
Menu: Smarty -> Templates -> Custom Functions -> fetch
Keybinding: C-c C-t C-c f
Description: See the manual.
- `smarty-template-html-checkboxes'
Menu: Smarty -> Templates -> Custom Functions -> html_checkboxes
Keybinding: C-c C-t C-c C-h c
Description: See the manual.
- `smarty-template-html-image'
Menu: Smarty -> Templates -> Custom Functions -> html_image
Keybinding: C-c C-t C-c C-h i
Description: See the manual.
- `smarty-template-html-options'
Menu: Smarty -> Templates -> Custom Functions -> html_options
Keybinding: C-c C-t C-c C-h o
Description: See the manual.
- `smarty-template-html-radios'
Menu: Smarty -> Templates -> Custom Functions -> html_radios
Keybinding: C-c C-t C-c C-h r
Description: See the manual.
- `smarty-template-html-select-date'
Menu: Smarty -> Templates -> Custom Functions -> html_select_date
Keybinding: C-c C-t C-c C-h d
Description: See the manual.
- `smarty-template-html-select-time'
Menu: Smarty -> Templates -> Custom Functions -> html_select_time
Keybinding: C-c C-t C-c C-h m
Description: See the manual.
- `smarty-template-html-table'
Menu: Smarty -> Templates -> Custom Functions -> html_table
Keybinding: C-c C-t C-c C-h t
Description: See the manual.
- `smarty-template-mailto'
Menu: Smarty -> Templates -> Custom Functions -> mailto
Keybinding: C-c C-t C-c i
Description: See the manual.
- `smarty-template-math'
Menu: Smarty -> Templates -> Custom Functions -> math
Keybinding: C-c C-t C-c h
Description: See the manual.
- `smarty-template-popup'
Menu: Smarty -> Templates -> Custom Functions -> popup
Keybinding: C-c C-t C-c C-p
Description: See the manual.
- `smarty-template-popup-init'
Menu: Smarty -> Templates -> Custom Functions -> popup_init
Keybinding: C-c C-t C-c M-p
Description: See the manual.
- `smarty-template-textformat'
Menu: Smarty -> Templates -> Custom Functions -> textformat
Keybinding: C-c C-t C-c t
Description: See the manual.
6.2.3 Variable Modifiers
-
- `smarty-template-capitalize'
Menu: Smarty -> Templates -> Variable Modifiers -> capitalize
Keybinding: C-c C-t C-v p
Description: See the manual.
- `smarty-template-cat'
Menu: Smarty -> Templates -> Variable Modifiers -> cat
Keybinding: C-c C-t C-v c
Description: See the manual.
- `smarty-template-count-characters'
Menu: Smarty -> Templates -> Variable Modifiers -> count_characters
Keybinding: C-c C-t C-v C-c c
Description: See the manual.
- `smarty-template-count-paragraphs'
Menu: Smarty -> Templates -> Variable Modifiers -> count_paragraphs
Keybinding: C-c C-t C-v C-c p
Description: See the manual.
- `smarty-template-count-sentences'
Menu: Smarty -> Templates -> Variable Modifiers -> count_sentences
Keybinding: C-c C-t C-v C-c s
Description: See the manual.
- `smarty-template-count-words'
Menu: Smarty -> Templates -> Variable Modifiers -> count_words
Keybinding: C-c C-t C-v C-c w
Description: See the manual.
- `smarty-template-date-format'
Menu: Smarty -> Templates -> Variable Modifiers -> date_format
Keybinding: C-c C-t C-v f
Description: See the manual.
- `smarty-template-default'
Menu: Smarty -> Templates -> Variable Modifiers -> default
Keybinding: C-c C-t C-v d
Description: See the manual.
- `smarty-template-escape'
Menu: Smarty -> Templates -> Variable Modifiers -> escape
Keybinding: C-c C-t C-v e
Description: See the manual.
- `smarty-template-indent'
Menu: Smarty -> Templates -> Variable Modifiers -> indent
Keybinding: C-c C-t C-v i
Description: See the manual.
- `smarty-template-lower'
Menu: Smarty -> Templates -> Variable Modifiers -> lower
Keybinding: C-c C-t C-v l
Description: See the manual.
- `smarty-template-nl2br'
Menu: Smarty -> Templates -> Variable Modifiers -> nl2br
Keybinding: C-c C-t C-v n
Description: See the manual.
- `smarty-template-regex-replace'
Menu: Smarty -> Templates -> Variable Modifiers -> regex_replace
Keybinding: C-c C-t C-v x
Description: See the manual.
- `smarty-template-replace'
Menu: Smarty -> Templates -> Variable Modifiers -> replace
Keybinding: C-c C-t C-v C-p
Description: See the manual.
- `smarty-template-spacify'
Menu: Smarty -> Templates -> Variable Modifiers -> spacify
Keybinding: C-c C-t C-v y
Description: See the manual.
- `smarty-template-string-format'
Menu: Smarty -> Templates -> Variable Modifiers -> string_format
Keybinding: C-c C-t C-v s
Description: See the manual.
- `smarty-template-vstrip'
Menu: Smarty -> Templates -> Variable Modifiers -> strip
Keybinding: C-c C-t C-v C-s
Description: See the manual.
- `smarty-template-strip-tags'
Menu: Smarty -> Templates -> Variable Modifiers -> strip_tags
Keybinding: C-c C-t C-v M-s
Description: See the manual.
- `smarty-template-truncate'
Menu: Smarty -> Templates -> Variable Modifiers -> truncate
Keybinding: C-c C-t C-v t
Description: See the manual.
- `smarty-template-upper'
Menu: Smarty -> Templates -> Variable Modifiers -> upper
Keybinding: C-c C-t C-v u
Description: See the manual.
- `smarty-template-wordwrap'
Menu: Smarty -> Templates -> Variable Modifiers -> wordwrap
Keybinding: C-c C-t C-v w
Description: See the manual.
6.2.4 Plugins Functions
6.2.4.1 Smarty Formtool
-
- `smarty-template-formtool-checkall'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyFormtool -> formtool_checkall
Keybinding: none
Description: See the plugin manual.
- `smarty-template-formtool-copy'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyFormtool -> formtool_copy
Keybinding: none
Description: See the plugin manual.
- `smarty-template-formtool-count-chars'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyFormtool -> formtool_count_chars
Keybinding: none
Description: See the plugin manual.
- `smarty-template-formtool-init'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyFormtool -> formtool_init
Keybinding: none
Description: See the plugin manual.
- `smarty-template-formtool-move'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyFormtool -> formtool_move
Keybinding: none
Description: See the plugin manual.
- `smarty-template-formtool-moveall'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyFormtool -> formtool_moveall
Keybinding: none
Description: See the plugin manual.
- `smarty-template-formtool-movedown'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyFormtool -> formtool_movedown
Keybinding: none
Description: See the plugin manual.
- `smarty-template-formtool-moveup'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyFormtool -> formtool_moveup
Keybinding: none
Description: See the plugin manual.
- `smarty-template-formtool-remove'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyFormtool -> formtool_remove
Keybinding: none
Description: See the plugin manual.
- `smarty-template-formtool-rename'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyFormtool -> formtool_rename
Keybinding: none
Description: See the plugin manual.
- `smarty-template-formtool-save'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyFormtool -> formtool_save
Keybinding: none
Description: See the plugin manual.
- `smarty-template-formtool-selectall'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyFormtool -> formtool_selectall
Keybinding: none
Description: See the plugin manual.
6.2.4.2 Smarty Paginate
-
- `smarty-template-paginate-first'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyPaginate -> paginate_first
Keybinding: none
Description: See the plugin manual.
- `smarty-template-paginate-last'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyPaginate -> paginate_last
Keybinding: none
Description: See the plugin manual.
- `smarty-template-paginate-middle'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyPaginate -> paginate_middle
Keybinding: none
Description: See the plugin manual.
- `smarty-template-paginate-next'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyPaginate -> paginate_next
Keybinding: none
Description: See the plugin manual.
- `smarty-template-paginate-prev'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyPaginate -> paginate_prev
Keybinding: none
Description: See the plugin manual.
6.2.4.3 Smarty Validate
-
- `smarty-template-validate'
Menu: Smarty -> Templates -> Plugins (Functions) -> SmartyValidate -> validate
Keybinding: none
Description: See the plugin manual.
6.2.5 Fonctions Non-Smarty
-
- `smarty-template-header'
Menu: Smarty -> Templates -> Insert Header
Keybinding: C-c C-t C-h
Description: This function is used to insert a header in the current buffer.
- `smarty-template-footer'
Menu: Smarty -> Templates -> Insert Footer
Keybinding: C-c C-t C-f
Description: This function is used to insert a footer in the current buffer.
- `smarty-template-insert-date'
Menu: Smarty -> Templates -> Insert Date
Keybinding: C-c C-t C-d i
Description: This function is used to insert the date in the current buffer.
- `smarty-template-modify'
Menu: Smarty -> Templates -> Modify Date
Keybinding: C-c C-t C-d m
Description: This function is used to modify the last modification date in the current buffer.
7. Bugs, Help
-
To report bugs: Bugtracker
-
To obtain help you can post on the dedicated forum: Forum
Index
Customizations variables Index
Functions Index
Stuttering Index
Table of Contents
Short Table of Contents
About This Document
This document was generated by Vincent DEBOUT on November, 19 2006 using texi2html 1.76.
The buttons in the navigation panels have the following meaning:
Button |
Name |
Go to |
From 1.2.3 go to |
[ < ] |
Back |
previous section in reading order |
1.2.2 |
[ > ] |
Forward |
next section in reading order |
1.2.4 |
[ << ] |
FastBack |
beginning of this chapter or previous chapter |
1 |
[ Up ] |
Up |
up section |
1.2 |
[ >> ] |
FastForward |
next chapter |
2 |
[Top] |
Top |
cover (top) of document |
|
[Contents] |
Contents |
table of contents |
|
[Index] |
Index |
index |
|
[ ? ] |
About |
about (help) |
|
where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:
- 1. Section One
- 1.1 Subsection One-One
- 1.2 Subsection One-Two
- 1.2.1 Subsubsection One-Two-One
- 1.2.2 Subsubsection One-Two-Two
- 1.2.3 Subsubsection One-Two-Three
<== Current Position
- 1.2.4 Subsubsection One-Two-Four
- 1.3 Subsection One-Three
- 1.4 Subsection One-Four
|