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) :
-
Customizable
-
Highlight
-
Menu
-
Stuttering
-
Templates
This manual describes Smarty Mode version 0.0.1.
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.1.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.1.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 2 menus tha you can enable/disable. The menus Index and Sources
are 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 Templates
3.1.3.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.4 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: none
Description:
- `smarty-template-config-load'
Menu: Smarty -> Templates -> Build-in Functions -> config_load
Keybinding: none
Description:
- `smarty-template-else'
Menu: Smarty -> Templates -> Build-in Functions -> else
Keybinding: none
Description:
- `smarty-template-elseif'
Menu: Smarty -> Templates -> Build-in Functions -> elseif
Keybinding: none
Description:
- `smarty-template-foreach'
Menu: Smarty -> Templates -> Build-in Functions -> foreach
Keybinding: none
Description:
- `smarty-template-foreachelse'
Menu: Smarty -> Templates -> Build-in Functions -> foreachelse
Keybinding: none
Description:
- `smarty-template-if'
Menu: Smarty -> Templates -> Build-in Functions -> if
Keybinding: none
Description:
- `smarty-template-include'
Menu: Smarty -> Templates -> Build-in Functions -> include
Keybinding: none
Description:
- `smarty-template-include-php'
Menu: Smarty -> Templates -> Build-in Functions -> include_php
Keybinding: none
Description:
- `smarty-template-insert'
Menu: Smarty -> Templates -> Build-in Functions -> insert
Keybinding: none
Description:
- `smarty-template-ldelim'
Menu: Smarty -> Templates -> Build-in Functions -> ldelim
Keybinding: none
Description:
- `smarty-template-literal'
Menu: Smarty -> Templates -> Build-in Functions -> literal
Keybinding: none
Description:
- `smarty-template-php'
Menu: Smarty -> Templates -> Build-in Functions -> php
Keybinding: none
Description:
- `smarty-template-rdelim'
Menu: Smarty -> Templates -> Build-in Functions -> rdelim
Keybinding: none
Description:
- `smarty-template-section'
Menu: Smarty -> Templates -> Build-in Functions -> section
Keybinding: none
Description:
- `smarty-template-sectionelse'
Menu: Smarty -> Templates -> Build-in Functions -> sectionelse
Keybinding: none
Description:
- `smarty-template-strip'
Menu: Smarty -> Templates -> Build-in Functions -> strip
Keybinding: none
Description:
6.2.2 Custom Functions
-
- `smarty-template-assign'
Menu: Smarty -> Templates -> Custom Functions -> assign
Keybinding: none
Description:
- `smarty-template-counter'
Menu: Smarty -> Templates -> Custom Functions -> counter
Keybinding: none
Description:
- `smarty-template-cycle'
Menu: Smarty -> Templates -> Custom Functions -> cycle
Keybinding: none
Description:
- `smarty-template-debug'
Menu: Smarty -> Templates -> Custom Functions -> debug
Keybinding: none
Description:
- `smarty-template-eval'
Menu: Smarty -> Templates -> Custom Functions -> eval
Keybinding: none
Description:
- `smarty-template-fetch'
Menu: Smarty -> Templates -> Custom Functions -> fetch
Keybinding: none
Description:
- `smarty-template-html-checkboxes'
Menu: Smarty -> Templates -> Custom Functions -> html_checkboxes
Keybinding: none
Description:
- `smarty-template-html-image'
Menu: Smarty -> Templates -> Custom Functions -> html_image
Keybinding: none
Description:
- `smarty-template-html-options'
Menu: Smarty -> Templates -> Custom Functions -> html_options
Keybinding: none
Description:
- `smarty-template-html-radios'
Menu: Smarty -> Templates -> Custom Functions -> html_radios
Keybinding: none
Description:
- `smarty-template-html-select-date'
Menu: Smarty -> Templates -> Custom Functions -> html_select_date
Keybinding: none
Description:
- `smarty-template-html-select-time'
Menu: Smarty -> Templates -> Custom Functions -> html_select_time
Keybinding: none
Description:
- `smarty-template-html-table'
Menu: Smarty -> Templates -> Custom Functions -> html_table
Keybinding: none
Description:
- `smarty-template-mailto'
Menu: Smarty -> Templates -> Custom Functions -> mailto
Keybinding: none
Description:
- `smarty-template-math'
Menu: Smarty -> Templates -> Custom Functions -> math
Keybinding: none
Description:
- `smarty-template-popup'
Menu: Smarty -> Templates -> Custom Functions -> popup
Keybinding: none
Description:
- `smarty-template-popup-init'
Menu: Smarty -> Templates -> Custom Functions -> popup_init
Keybinding: none
Description:
- `smarty-template-textformat'
Menu: Smarty -> Templates -> Custom Functions -> textformat
Keybinding: none
Description:
6.2.3 Variable Modifiers
-
- `smarty-template-capitalize'
Menu: Smarty -> Templates -> Variable Modifiers -> capitalize
Keybinding: none
Description:
- `smarty-template-cat'
Menu: Smarty -> Templates -> Variable Modifiers -> cat
Keybinding: none
Description:
- `smarty-template-count-characters'
Menu: Smarty -> Templates -> Variable Modifiers -> count_characters
Keybinding: none
Description:
- `smarty-template-count-paragraphs'
Menu: Smarty -> Templates -> Variable Modifiers -> count_paragraphs
Keybinding: none
Description:
- `smarty-template-count-sentences'
Menu: Smarty -> Templates -> Variable Modifiers -> count_sentences
Keybinding: none
Description:
- `smarty-template-count-words'
Menu: Smarty -> Templates -> Variable Modifiers -> count_words
Keybinding: none
Description:
- `smarty-template-date-format'
Menu: Smarty -> Templates -> Variable Modifiers -> date_format
Keybinding: none
Description:
- `smarty-template-default'
Menu: Smarty -> Templates -> Variable Modifiers -> default
Keybinding: none
Description:
- `smarty-template-escape'
Menu: Smarty -> Templates -> Variable Modifiers -> escape
Keybinding: none
Description:
- `smarty-template-indent'
Menu: Smarty -> Templates -> Variable Modifiers -> indent
Keybinding: none
Description:
- `smarty-template-lower'
Menu: Smarty -> Templates -> Variable Modifiers -> lower
Keybinding: none
Description:
- `smarty-template-nl2br'
Menu: Smarty -> Templates -> Variable Modifiers -> nl2br
Keybinding: none
Description:
- `smarty-template-regex-replace'
Menu: Smarty -> Templates -> Variable Modifiers -> regex_replace
Keybinding: none
Description:
- `smarty-template-replace'
Menu: Smarty -> Templates -> Variable Modifiers -> replace
Keybinding: none
Description:
- `smarty-template-spacify'
Menu: Smarty -> Templates -> Variable Modifiers -> spacify
Keybinding: none
Description:
- `smarty-template-string-format'
Menu: Smarty -> Templates -> Variable Modifiers -> string_format
Keybinding: none
Description:
- `smarty-template-vstrip'
Menu: Smarty -> Templates -> Variable Modifiers -> strip
Keybinding: none
Description:
- `smarty-template-strip-tags'
Menu: Smarty -> Templates -> Variable Modifiers -> strip_tags
Keybinding: none
Description:
- `smarty-template-truncate'
Menu: Smarty -> Templates -> Variable Modifiers -> truncate
Keybinding: none
Description:
- `smarty-template-upper'
Menu: Smarty -> Templates -> Variable Modifiers -> upper
Keybinding: none
Description:
- `smarty-template-wordwrap'
Menu: Smarty -> Templates -> Variable Modifiers -> wordwrap
Keybinding: none
Description:
6.2.4 Non-Smarty Functions
-
- `smarty-template-header'
Menu: Smarty -> Templates -> Insert Header
Keybinding: none
Description: This function is used to insert a header in the current buffer.
- `smarty-template-footer'
Menu: Smarty -> Templates -> Insert Footer
Keybinding: none
Description: This function is used to insert a footer in the current buffer.
- `smarty-template-insert-date'
Menu: Smarty -> Templates -> Insert Date
Keybinding: none
Description: This function is used to insert the date in the current buffer.
- `smarty-template-modify'
Menu: Smarty -> Templates -> Modify Date
Keybinding: none
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, 12 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
|