From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Norbert Caudéran" Newsgroups: gmane.emacs.help Subject: Re: what do fellow emacsen use for editing cold fusion? Date: Wed, 7 May 2003 12:49:19 +0200 Organization: Wanadoo, l'internet avec France Telecom Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org X-Trace: main.gmane.org 1052305866 23601 80.91.224.249 (7 May 2003 11:11:06 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 7 May 2003 11:11:06 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Wed May 07 13:11:03 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19DMou-000670-00 for ; Wed, 07 May 2003 13:10:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19DMfi-0007I4-00 for gnu-help-gnu-emacs@m.gmane.org; Wed, 07 May 2003 07:01:14 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!nntp.cs.ubc.ca!freenix!wanadoo.fr!not-for-mail Original-Newsgroups: comp.emacs,gnu.emacs.help Original-Lines: 2823 Original-NNTP-Posting-Host: abordeaux-102-2-1-132.abo.wanadoo.fr Original-X-Trace: news-reader12.wanadoo.fr 1052305021 25664 81.48.9.132 (7 May 2003 10:57:01 GMT) Original-X-Complaints-To: abuse@wanadoo.fr Original-NNTP-Posting-Date: 7 May 2003 10:57:01 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Original-Xref: shelby.stanford.edu comp.emacs:79073 gnu.emacs.help:112877 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:9373 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:9373 I use a modified version of html-helper-mode.el (cfml-helper-mode.el) and a small module to browse homesite help (help-url.el which is copied/inspired from JDE). You could use the doc hosted by your dev server. Those two modules are quick and dirty hacks...I have to say that I often use homesite too, but taht's bad (tm) ! Hope this helps, Norbert in my dot emacs I have : (setq cfml-helper-verbose '()) (autoload 'cfml-helper-mode "cfml-helper-mode" "Yay Cold Fusion" t) (setq auto-mode-alist (cons '("\\.cfm$" . cfml-helper-mode) auto-mode-alist)) ------------8<----------cfml-helper-mode.el----------------8<--------------- -- ;;; cfml-helper-mode.el --- Major mode for composing cfml files. ;;; mostly html-helper-mode.el ;;; v 3.0.4jolly ;; Mantainer : Gian Uberto "Saint" Lauri ;; * ;; * works only from DEI, Padova. ;; http://www.gest.unipd.it/~saint/ ;; Original Author: Nelson Minar ;; Original version Maintainer: Nelson Minar ;; Changes by by: Gian Uberto Lauri , * ;; * works only from DEI, Padova. ;; Credits : Larry Smith and Tony Graham for the ASP/PHP matching regexp ;; prototype. ;; Stan Lanning for the defadvice code that prevents indenting ;; of
, for the defadvice code that leaves the cursor
;;           where it is during narrowing to script code, enhancments to
;;           the scripting narrowing
;;           Charles Curley for the commentary of tempo.el behaviour
;;           Samir Barjoud for giving me the luser cap when I didn't notice
;;           that *ALL* I needed to write  cfml-helper-match-asp-php was in
;;           font-lock.el.
;;           Theodore A. Jump for fixing fold tags in this source (after I
;;           broke them
;;           David J. Biesack for suggesting a good version checking.

;; URL: http://www.gest.unipd.it/~saint/cfml-helper-mode.el.gz

;; Created: 01 Feb 1994
;; $Id: cfml-helper-mode.el,v 3.0.4jolly 1998/08/06 18:53:03 nelson Exp $
;; Keywords: HTML major-mode

;; LCD Archive Entry:
;; cfml-helper-mode|Gian Uberto Lauri|lauri@eng.it|
;; Major mode for editing HTML.|
;; 26-Oct-99|Version
3.?.?|http://www.gest.unipd.it/~saint/cfml-helper-mode.el.gz

;; Copyright (C) 1994 Nelson Minar
;; Copyright (C) 1995 Nelson Minar and Ulrik Dickow
;; Copyright (C) 1999 Nelson Minar, Ulrik Dickow and Gian Uberto Lauri

;; 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 2, 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 GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, 675 Massachusettes Ave,
;; Cambridge, MA 02139, USA.

;;{{{ Commentary

;; Installation:
;;   Add this line in your .emacs:
;;     (autoload 'cfml-helper-mode "cfml-helper-mode" "Yay HTML" t)
;;   To invoke cfml-helper-mode automatically on .html files, do this:
;;     (setq auto-mode-alist (cons '("\\.html$" . cfml-helper-mode)
auto-mode-alist))
;;   To invoke cfml-helper-mode automatically on .asp files, do this:
;;     (setq auto-mode-alist (cons '("\\.asp$" . cfml-helper-mode)
auto-mode-alist))
;;   To invoke cfml-helper-mode automatically on .phtml files, do this:
;;     (setq auto-mode-alist (cons '("\\.phtml$" . cfml-helper-mode)
auto-mode-alist))

;;
;;   This mode requires another lisp file, tempo.el. This can be
;;     retrieved from ftp://ftp.lysator.liu.se/pub/emacs/tempo.el
;;   Xemacs users need to have auc-menu installed.
;;   Emacs 18 users need to have auc-menu and add-hook installed.
;;   If your OS has broken 14 character filenames
;;      this mode will also work with the name "html-mode.el".

;; Configuration:
;;   see the "user variables" section, or the documentation on configuration
;;   in http://www.santafe.edu/~nelson/tools/. There are variables you want
to
;;   configure, particularly cfml-helper-address-string and
;;   cfml-helper-use-expert-menu

;; See also: http://www.gest.unipd.it/~saint/hth.html for further details
;; regarding server code support.

;; Description:
;;   cfml-helper-mode makes it easier to write HTML documents. This mode
;;   handles inserting HTML codes in a variety of ways (keybindings, menus,
;;   completion in the buffer). It also supports indentation, timestamps,
;;   skeletons for new documents, hilit19 patterns, and a variety of other
;;   things. For the full skinny, see the HTML documentation that comes
;;   with the package or is at http://www.santafe.edu/~nelson/tools/

;; Thank yous:
;;   David Kågedal  for the tempo code which
;;     forms the core of the HTML insertion, as well as the HTML+ tag.
;;   Marc Hedlund  for general encouragement and
;;     many helpful suggestions, especially with HTML/2.0 compliance
;;     and form design.
;;   Ulrik Dickow  for the font-lock code
;;   Denis Howe  for writing browse-url.
;;   Magnus Homann  and Jamshid Afshar
;;      for timestamp suggestions.
;;   Everyone who sent me a version of menus (16 in all!)
;;   Marc Andreessen  for writing the original html-mode

;; The newest version of cfml-helper-mode should always be available from
;;   http://www.gest.unipd.it/~saint/hth.html

;; Changes moved to hhm-changelog

;; This code was writting using folding.el, a wonderful folding editor
;; minor mode for emacs. That's what the strange {{{ comments are for.

;;}}}

;;{{{ Code:

(defconst cfml-helper-mode-version
  (progn
    (let ((revs "$Revision: 3.0.4jolly$")
   (lastchar 0))
      ; revs is a string of single byte characters
      (set 'lastchar (1- (string-width revs)))
      (substring revs 11 lastchar))))

;;{{{ user variables

;;{{{ defcustoms
(defgroup cfml-helper nil
  "Customizing cfml-helper-mode"
  :group 'languages
  :group 'hypermedia
  :group 'local)

(defgroup cfml-helper-faces nil
  "Customizing cfml-helper-mode custom faces"
  :group 'cfml-helper
  :group 'faces)

;; Default distribution doesn't include visual-basic-mode
(defcustom cfml-helper-mode-uses-visual-basic nil
  "Non nil to require visual-basic-mode"
  :type 'boolean
  :initialize 'custom-initialize-default
  :group 'cfml-helper
  :require 'cfml-helper-mode)

;; Default distribution doesn't include jde
;;
;; Suggestion by :
;; Jari Aalto 
;;
;;    I think that people that have installed JDE, use it, so
;;    it would be logical to preset this automatically using
;;    `locate-library'
(defcustom cfml-helper-mode-uses-JDE (locate-library "jde")
  "No nil to use jde instead of java-mode"
  :type 'boolean
  :initialize 'custom-initialize-default
  :group 'cfml-helper
  :require 'cfml-helper-mode)

(defcustom cfml-helper-mode-uses-bold-italic nil
  "Non nil to use the bold-italic font (if your font supports it)"
  :type 'boolean
  :initialize 'custom-initialize-default
  :group 'cfml-helper
  :require 'cfml-helper-mode)

(defcustom cfml-helper-mode-uses-KG-style nil
  "Non nil to make Emacs consider PHP/ASP code blocks beginning in
the first column"
  :type 'boolean
  :initialize 'custom-initialize-default
  :group 'cfml-helper
  :require 'cfml-helper-mode)

(defcustom cfml-helper-mode-global-JSP-not-ASP t
  "Non nil to make Emacs consider <% %> blocks as JSP (global default
behaviour)"
  :type 'boolean
  :initialize 'custom-initialize-default
  :group 'cfml-helper
  :require 'cfml-helper-mode)

(defcustom cfml-helper-mode-insert-attributes-always nil
  "non nil to make Emacs insert empty tag attributes when tempo-interactive
is nil"
  :type 'boolean
  :initialize 'custom-initialize-default
  :group 'cfml-helper
  :require 'cfml-helper-mode)
;;}}}

;;{{{ defvars...
(defvar cfml-helper-mode-local-JSP-not-ASP
  cfml-helper-mode-global-JSP-not-ASP
  "Non nil to make Emacs consider <% %> blocks as JSP (buffer local
behaviour)")

(defvar cfml-helper-mode-run-the-mode t "When t, make the local variables,
else skip")
;; Visual basic mode is not in the standard distribution, so I let the user
;; override cfml-helper-mode-uses-visual-basic with a nil value.
(cond (cfml-helper-mode-uses-visual-basic (require 'visual-basic-mode)))
(cond (cfml-helper-mode-uses-JDE (require 'jde)))
(require 'cc-mode)
(require 'cl)

;; Set this to be whatever signature you want on the bottom of your pages.
(defvar cfml-helper-address-string ""
  "*The default author string of each file.")

;; Features; these are all good to have on. (see also tempo.el)

(defvar cfml-helper-use-expert-menu t
  "*If not nil, then use the full HTML menu.")

(defvar cfml-helper-do-write-file-hooks t
  "*If not nil, then modify `local-write-file-hooks' to do timestamps.")

(defvar cfml-helper-build-new-buffer t
  "*If not nil, then insert `cfml-helper-new-buffer-strings' for new
buffers.")

;; variables to configure (these defaults are reasonable.)

(defvar cfml-helper-htmldtd-version "\n"
  "*Version of HTML DTD you're using.")

(defvar cfml-helper-user-menu nil
  "*Extra items to put in the HTML expert menu.
The value of this symbol is appended to the beginning of the expert
menu that is handed off to easymenu for definition. It should be a
list of vectors or lists which themselves are vectors (for submenus).")

(defvar cfml-helper-basic-offset 2
  "*Basic indentation size used for list indentation")

;; Wed Jan 10 09:35:53 2001 Saint
;;
;; fixing indentation
;;(defvar cfml-helper-item-continue-indent 2
;;  "*Indentation of lines that follow a 
  • item. ;;Default is 2, the length of things like \"
  • \" and \"
    \".") (defvar cfml-helper-never-indent nil "*If not nil, the indentation code for cfml-helper is turned off.") ;; hooks (see also tempo.el) ;; On prompts... Charles Curley (http://w3.trib.com/~ccurley/): It took ;; some time to figure this out... The (p "prompt: ") and (r "prompt: ;; ") entries indicate where the prompting mode should prompt for a ;; field in the tag. (p ) indicates a parameter, such as the color of a ;; tag. (r ) indicates a region, where the text to be surrounded ;; by the tag should go, such as the text to be turned that color. The ;; difference is this: when prompting mode is turned off and the user ;; is surrounding a region with the tag, the (r ) (region) parameter ;; indicates where the surrounded region will go. The first (p ) ;; (parameter) is where the cursor will go, ready to input the first ;; parameter to the tag. ;; So when you have prompting on, and use the font with color and size ;; tag, put the cursor where you want the modified text to go. Start ;; inserting the tag. You will be prompted for the color, the size, and ;; then the text to display that way. When you have prompting turned ;; off, and don't have a region blocked, insert the font tag, and the ;; cursor will be at the the first parameter. Then tab over to the ;; space between the two parts of the tag, and type in your text. If ;; you have region blocked, C-u followed by the tag will surround the ;; region with the tag. The blocked region goes into the (r ) ;; parameter. Then the cursor is placed at the first (p ) location, ;; ready for you to type in a parameter, such as the color of the text. (defvar cfml-helper-mode-hook nil "*Hook run when cfml-helper-mode is started.") (defvar cfml-helper-load-hook nil "*Hook run when cfml-helper-mode is loaded.") (defvar cfml-helper-timestamp-hook 'cfml-helper-default-insert-timestamp "*Hook called for timestamp insertion. Override this for your own timestamp styles.") ;; strings you might want to change (defvar cfml-helper-new-buffer-template '(cfml-helper-htmldtd-version " \n" "" p "\n\n\n" "\n" "

    " p "

    \n\n" p "\n\n
    \n" "
    " cfml-helper-address-string "
    \n" cfml-helper-timestamp-start cfml-helper-timestamp-end "\n \n") "*Template for new buffers. Inserted by `cfml-helper-insert-new-buffer-strings' if `cfml-helper-build-new-buffer' is set to t") (defvar cfml-helper-new-ASP-buffer-template '("<%@ LANGUAGE=\"" p "\" %>\n" " \n" "<%\n\n%>\n" "\n" "<% ' %>\n" "\n\n") "*Template for new ASP buffers. Inserted by `cfml-helper-insert-new-ASP-buffer-strings' if `cfml-helper-build-new-buffer' is set to t") (defvar cfml-helper-new-PHP-buffer-template '(" \n" "" "\n" "\n" "\n\n" ) "*Template for new PHP buffers. Inserted by `cfml-helper-insert-new-PHP-buffer-strings' if `cfml-helper-build-new-buffer' is set to t") ;; Someone has some better idea ? (defvar cfml-helper-new-JSP-buffer-template '(" \n" "<%\n\n%>\n" "\n" "<% ' %>\n" "\n\n") "*Template for new JSP buffers. Inserted by `cfml-helper-insert-new-ASP-buffer-strings' if `cfml-helper-build-new-buffer' is set to t") (defvar cfml-helper-timestamp-start " " "*Start delimiter for timestamps. Everything between `cfml-helper-timestamp-start' and `cfml-helper-timestamp-end' will be deleted and replaced with the output of the functions `cfml-helper-timestamp-hook' if `cfml-helper-do-write-file-hooks' is t") (defvar cfml-helper-timestamp-end "" "*End delimiter for timestamps. Everything between `cfml-helper-timestamp-start' and `cfml-helper-timestamp-end' will be deleted and replaced with the output of the function `cfml-helper-insert-timestamp' if `cfml-helper-do-write-file-hooks' is t") ;; control over what types of tags to load. By default, we load all the ;; ones we know of. (defvar cfml-helper-types-to-install '(anchor list header logical phys textel entity image table head form script) "*List of tag types to install when cfml-helper-mode is first loaded. If you want to not install some type of tag, override this variable. Order is significant: menus go in this order.") ;; emacs18 detection. (defvar cfml-helper-emacs18 (and (boundp 'emacs-version) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19"))) "I'll do minimal emacs18 support, grumble.") ;;}}} end of defvars ;;}}} end of user variables ;;{{{ Prologue (require 'tempo) ;essential part of cfml-helper-mode (condition-case nil ;menu support, standard in emacs19 (require 'auc-menu) ;add-on for XEmacs. *why* does this (error (require 'easymenu))) ;package have to have two names? ;; Wed Mar 28 09:55:29 2001 Saint ;; ;; Placing here (require 'psgml-html ) after a suggestion from Graham ;; Gough who explored the faces problem with XEmacs (many thanks) (if (string-match "XEmacs\\|Lucid" (emacs-version)) ;; This will initialize cfml-helper-bold-face (require 'psgml-html)) (require 'font-lock) ;;}}} ;;{{{ cfml-helper-mode-syntax-table and cfml-helper-mode-abbrev-table ;; emacs doesn't seem to be able to really handle SGML like syntax. In ;; particular, comments are a loss. ;; We do try this, though: give < and > matching semantics (defvar cfml-helper-mode-syntax-table nil "Syntax table for cfml-helper.") (if cfml-helper-mode-syntax-table () (setq cfml-helper-mode-syntax-table (make-syntax-table text-mode-syntax-table)) (modify-syntax-entry ?< "(> " cfml-helper-mode-syntax-table) (modify-syntax-entry ?> ")< " cfml-helper-mode-syntax-table) (modify-syntax-entry ?\" ". " cfml-helper-mode-syntax-table) (modify-syntax-entry ?\\ ". " cfml-helper-mode-syntax-table) (modify-syntax-entry ?' "w " cfml-helper-mode-syntax-table)) (defvar cfml-helper-mode-abbrev-table nil "Abbrev table used while in cfml-helper-mode.") (define-abbrev-table 'cfml-helper-mode-abbrev-table ()) ;;}}} ;;{{{ type based keymap and menu variable and function setup ;; Our basic keymap. (defvar cfml-helper-mode-map (make-sparse-keymap) "Keymap for cfml-helper") (defvar cfml-helper-mode-menu nil "Menu for cfml-helper. Clobbered and rebuilt by `cfml-helper-install-menu'") ;; cfml-helper-mode has a concept of "type" of tags. Each type is a ;; list of tags that all go together in one keymap and one menu. ;; Types can be added to the system after cfml-helper has been loaded, ;; briefly by doing cfml-helper-add-type-to-alist, then ;; cfml-helper-install-type, then cfml-helper-add-tag (for each tag) ;; then cfml-helper-rebuild-menu. See the mode documentation for more detail. (defconst cfml-helper-type-alist nil "Alist: type of tag -> keymap, keybinding, menu, menu string. Add to this with `cfml-helper-add-type-to-alist'.") (defun cfml-helper-keymap-for (type) "Accessor function for alist: for type, return keymap or nil" (nth 0 (cdr-safe (assq type cfml-helper-type-alist)))) (defun cfml-helper-key-for (type) "Accessor function for alist: for type, return keybinding or nil" (nth 1 (cdr-safe (assq type cfml-helper-type-alist)))) (defun cfml-helper-menu-for (type) "Accessor function for alist: for type, return menu or nil" (nth 2 (cdr-safe (assq type cfml-helper-type-alist)))) (defun cfml-helper-menu-string-for (type) "Accessor function for alist: for type, return menustring or nil" (nth 3 (cdr-safe (assq type cfml-helper-type-alist)))) (defun cfml-helper-normalized-menu-for (type) "Helper function for building menus from submenus: add on string to menu." (cons (cfml-helper-menu-string-for type) (eval (cfml-helper-menu-for type)))) (defun cfml-helper-add-type-to-alist (type) "Add a type specification to the alist. The spec goes (type . (keymap-symbol keyprefix menu-symbol menu-string)). See code for an example." (setq cfml-helper-type-alist (cons type cfml-helper-type-alist))) ;; Here are the types provided by cfml-helper-mode. (mapcar 'cfml-helper-add-type-to-alist '((entity . (nil nil cfml-helper-entity-menu "Insert Character Entities")) (textel . (nil nil cfml-helper-textel-menu "Insert Text Elements")) (head . (cfml-helper-head-map "\C-c\C-h" cfml-helper-head-menu "Insert Structural Elements")) (header . (cfml-helper-header-map "\C-c\M-h" cfml-helper-header-menu "Insert Headers")) (anchor . (cfml-helper-anchor-map "\C-c\C-a" cfml-helper-anchor-menu "Insert Hyperlinks")) (logical . (cfml-helper-logical-map "\C-c\M-l" cfml-helper-logical-menu "Insert Logical Styles")) (phys . (cfml-helper-phys-map "\C-c\C-p" cfml-helper-phys-menu "Insert Physical Styles")) (list . (cfml-helper-list-map "\C-c\C-l" cfml-helper-list-menu "Insert List Elements")) (form . (cfml-helper-form-map "\C-c\C-f" cfml-helper-form-menu "Insert Form Elements")) (image . (cfml-helper-image-map "\C-c\C-i" cfml-helper-image-menu "Insert Inlined Images")) (table . (cfml-helper-table-map "\C-c\C-t" cfml-helper-table-menu "Insert Tables")) (script . (cfml-helper-script-map "\C-c\C-s" cfml-helper-script-menu "Insert Scripts")) )) ;; Once cfml-helper-mde is aware of a type, it can then install the ;; type: arrange for keybindings, menus, etc. (defconst cfml-helper-installed-types nil "The types that have been installed (used when building menus). There is no support for removing a type once it has been installed.") ;; For easy ASP/JSP switch (defun cfml-helper-use-JSP-this-buffer () (interactive) (setq cfml-helper-mode-local-JSP-not-ASP t) (setq mode-name "HTML/JSP helper") (setq major-mode 'jsp-cfml-helper-mode)) (defun cfml-helper-use-ASP-this-buffer () (interactive) (cond (cfml-helper-mode-uses-visual-basic (setq cfml-helper-mode-local-JSP-not-ASP nil) (setq mode-name "HTML/ASP helper") (setq major-mode 'asp-cfml-helper-mode)) (t (error "Visual basic mode required for ASP")))) (defun cfml-helper-install-type (type) "Install a new tag type: add it to the keymap, menu structures, etc. For this to work, the type must first have been added to the list of types with cfml-helper-add-type-to-alist." (setq cfml-helper-installed-types (cons type cfml-helper-installed-types)) (let ((keymap (cfml-helper-keymap-for type)) (key (cfml-helper-key-for type)) (menu (cfml-helper-menu-for type)) (menu-string (cfml-helper-menu-string-for type))) (and key (progn (set keymap nil) (define-prefix-command keymap) (if cfml-helper-emacs18 (progn (set keymap (make-sparse-keymap)) (define-key cfml-helper-mode-map key (eval keymap))) (define-key cfml-helper-mode-map key keymap)))) (and menu (progn (set menu nil))))) ;; install the default types. (mapcar 'cfml-helper-install-type cfml-helper-types-to-install) ;; special mode keys (mapcar (function (lambda (l) (define-key cfml-helper-mode-map (car l) (nth 1 l)))) '(("\M-\C-f" tempo-forward-mark) ("\M-\C-b" tempo-backward-mark) ("\M-\t" tempo-complete-tag))) ;; Extra commands that HTML helper supports that aren't insertions (defvar cfml-helper-mode-functions-map nil "Keymap for extra HTML mode functions") (define-prefix-command 'cfml-helper-mode-functions-map) (define-key cfml-helper-mode-map "\C-c\C-z" 'cfml-helper-mode-functions-map) (define-key cfml-helper-mode-functions-map "t" 'cfml-helper-insert-timestamp-delimiter-at-point) (define-key cfml-helper-mode-functions-map "a" 'html-script-narrow-to-asp) (define-key cfml-helper-mode-functions-map "p" 'html-script-narrow-to-php) (define-key cfml-helper-mode-functions-map "b" 'html-script-narrow-to-vbscript) (define-key cfml-helper-mode-functions-map "j" 'html-script-narrow-to-javascript) ;; indentation keys - only rebind these if the user wants indentation (if cfml-helper-never-indent () (define-key cfml-helper-mode-map "\t" 'cfml-helper-indent-command) (define-key cfml-helper-mode-map "\C-m" 'newline-and-indent)) ;; browse url stuff (if (fboundp 'browse-url-of-file) (define-key cfml-helper-mode-functions-map "v" 'browse-url-of-file)) ;; Fri Jan 12 18:30:32 2001 Saint ;; ;; Jack Vinson supplies this code to handle the case when ;; browse-url-browser-function is a list and not a function (it can be ;; a list, says its documentation) ;; ;; Replacing : ;; (if (and (boundp 'browse-url-browser-function) ;; (fboundp browse-url-browser-function)) ;; (define-key cfml-helper-mode-functions-map "u" ;; browse-url-browser-function)) (if (boundp 'browse-url-browser-function) (let ((bf browse-url-browser-function) re) (while (consp bf) (setq re (car (car bf)) bf (if (string-match re "http") (cdr (car bf)) ; The function (cdr bf)))) ; More pairs (or bf (error "No browser in browse-url-browser-function for = general URL's")) (fboundp bf) (define-key cfml-helper-mode-functions-map "u" bf) )) ;;}}} ;;{{{ cfml-helper-add-tag function for building basic tags (defvar cfml-helper-tempo-tags nil "List of tags used in completion.") ;; this while loop is awfully Cish ;; isn't there an emacs lisp function to do this? (defun cfml-helper-string-to-symbol (input-string) "Given a string, downcase it and replace spaces with -. We use this to turn menu entries into good symbols for functions. It's not entirely successful, but fortunately emacs lisp is forgiving." (let* ((s (copy-sequence input-string)) (l (1- (length s)))) (while (> l 0) (if (char-equal (aref s l) ?\ ) (aset s l ?\-)) (setq l (1- l))) (concat "html-" (downcase s)))) (defun cfml-helper-add-tag (l) "Add a new tag to cfml-helper-mode. Builds a tempo-template for the tag and puts it into the appropriate keymap if a key is requested. Format: `(cfml-helper-add-tag '(type keybinding completion-tag menu-name template doc)'" (let* ((type (car l)) (keymap (cfml-helper-keymap-for type)) (menu (cfml-helper-menu-for type)) (key (nth 1 l)) (completer (nth 2 l)) (name (nth 3 l)) (tag (nth 4 l)) (doc (nth 5 l)) (command (if (string-equal completer "function") (nth 4 l) (tempo-define-template (cfml-helper-string-to-symbol name) tag completer doc 'cfml-helper-tempo-tags)))) (if (null (memq type cfml-helper-installed-types)) ;type loaded? t ;no, do nothing. (if (stringp key) ;bind key somewhere? (if keymap ;special keymap? (define-key (eval keymap) key command) ;t: bind to prefix (define-key cfml-helper-mode-map key command));nil: bind to global t) (if menu ;is there a menu? (set menu ;good, cons it in (cons (vector name command t) (eval menu)))) ))) ;; for backwards compatability (fset 'cfml-helper-add-cookie 'cfml-helper-add-tag) ;;}}} ;;{{{ most of the HTML tags (defun cfml-helper-insert-or-wipe (string) "Propmts for the value of an optional attribute named STRING and inserts it in the current buffer. Inserts nothing if the users replies with a null string." (cond ((and (stringp string) tempo-interactive) (let ((val (read-from-minibuffer (concat string " :")))) (cond ((> (string-width val) 0) (insert-string (concat " " string "=\"" val "\"" ))) ))) ;; just to tell that there's something weird in the calling ;; code... But behaves like a no op if tempo-interactive is ;; nil (tempo-interactive (error (concat "Wrong type argument: stringp, " string))) ;; Wed Mar 28 10:06:24 2001 Saint ;; ;; To insert empty attributes if ;; cfml-helper-mode-insert-attributes-always is non nil ((and (stringp string) cfml-helper-mode-insert-attributes-always) (insert-string (concat " " string "=\"\"" ))) )) ;; These tags are an attempt to be HTML/2.0 compliant, with the exception ;; of container

    ,

  • ,
    ,
    (we adopt 3.0 behaviour). ;; For reference see ;; order here is significant: within a tag type, menus and mode help ;; go in the reverse order of what you see here. Sorry about that, it's ;; not easy to fix. (mapcar 'cfml-helper-add-tag '( ;;entities (entity "\C-c#" "&#" "Ascii Code" ("&#" (r "Ascii: ") ";")) (entity "\C-c\"" """ "Quotation mark" (""")) (entity "\C-c$" "®" "Registered" ("®")) (entity "\C-c@" "©" "Copyright" ("©")) (entity "\C-c-" "­" "Soft Hyphen" ("­")) (entity "\C-c " " " "Nonbreaking Space" (" ")) (entity "\C-c&" "&" "Ampersand" ("&")) (entity "\C-c>" ">" "Greater Than" (">")) (entity "\C-c<" "<" "Less Than" ("<")) ;; letters with accents common in italian (entity "\C-ca" "à" "a` (&à)" ("à")) (entity "\C-ce" "è" "e` (&è)" ("è")) (entity "\C-cE" "é" "e' (&é)" ("é")) (entity "\C-co" "ò" "o` (&ò)" ("ò")) (entity "\C-ci" "ì" "i` (&ì)" ("ì")) (entity "\C-cu" "ù" "u` (&ù)" ("ù")) ;; logical styles (logical "b" "
    " "Blockquote" ("
    " (r "Quote: ") "
    ")) (logical "c" "" "Code" ("" (r "Code: ") "")) (logical "x" "" "Sample" ("" (r "Sample code") "")) (logical "r" "" "Citation" ("" (r "Citation: ") "")) (logical "k" "" "Keyboard Input" ("" (r "Keyboard: ") "")) (logical "v" "" "Variable" ("" (r "Variable: ") "")) (logical "d" "" "Definition" ("" (r "Definition: ") "")) (logical "a" "
    " "Address" ("
    " r "
    ")) (logical "e" "" "Emphasized" ("" (r "Text: ") "")) (logical "s" "" "Strong" ("" (r "Text: ") "")) (logical "p" "
    "  "Preformatted"
         ("
    " (r "Text: ") "
    ")) ;;physical styles (phys "s" "" "Strikethru" ("" (r "Text: ") "")) (phys "u" "" "Underline" ("" (r "Text: ") "")) (phys "i" "" "Italic" ("" (r "Text: ") "")) (phys "b" "" "Bold" ("" (r "Text: ") "")) (phys "f" "" "Fixed" ("" (r "Text: ") "")) (phys "c" "
    " "Center" ("
    " (r "Text: ") "
    ")) ;; html4.0 stuff, omitted ; (phys "5" "" 'r "")) ; (phys "l" "" 'r "")) ;;headers (header "6" "
    " "Header 6" ("
    " (r "Header: ") "
    ")) (header "5" "
    " "Header 5" ("
    " (r "Header: ") "
    ")) (header "4" "

    " "Header 4" ("

    " (r "Header: ") "

    ")) (header "3" "

    " "Header 3" ("

    " (r "Header: ") "

    ")) (header "2" "

    " "Header 2" ("

    " (r "Header: ") "

    ")) (header "1" "

    " "Header 1" ("

    " (r "Header: ") "

    ")) ;; forms (form "o" "
    \\|
  • \\|\\|") (defvar cfml-helper-any-list-start ;; "
    \\|
      \\|
        \\|\\|\\|") ;; "\\|\\|<cfinsert>\\| <table\\|<tr\\|<input\\|<cfoutput\\|<h1>\\|<h2>\\|<h3>\\|<h4>\\|<h5>\\|<h6>\ \|<center>\\|<frameset\\|<cfquery\\|<cfif\\|<cfelse\\|<cfloop\\|<cftransacti on>") (defvar cfml-helper-any-list-end "</dl>\\|</ul>\\|</ol>\\|</menu>\\|</dir>\\|</select>\\|</head>\\|\\ |\\|\\|\\|\\|\\|\\|\\|\\|\\|\\|\\|\\|\\|<\cfif>\ \|\\|") ; "
    \\|\\|\\|\\|\\|\\|\\|") (defvar cfml-helper-any-list (format "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)" cfml-helper-any-list-start cfml-helper-any-list-end cfml-helper-any-list-item-start cfml-helper-any-list-item-end)) ;; Wed Jan 10 09:50:53 2001 Saint ;; ;; New indentation. As for other modes leave a single indentation ;; sensible tag on each line. (defvar cfml-helper-indentation-list cfml-helper-any-list) ;; (format "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)" ;; cfml-helper-any-list-start ;; cfml-helper-any-list-end ;; cfml-helper-any-list-item-start)) (defvar cfml-helper-search-limit 2000 "limit on how far back we search") (defun cfml-helper-context-symbol () "Return the symbol the last match (against `cfml-helper-any-list') found." (cond ((match-beginning 1) 'list-start) ((match-beginning 2) 'list-end) ((match-beginning 3) 'item-start) ((match-beginning 4) 'item-end) (t 'error))) ; Wed Jan 10 09:53:46 2001 Saint ; ; Doesn't ignore item-end any more. (defun cfml-helper-guess-prev-context () "Figure out the last list-type tag before point relevant to indentation. Returns 'item-start if the last list tag is a list item start 'list-start if the last list tag is the start of a list 'item-end if the last list tag is the end of a list item 'list-end if the last list tag is the end of a list." (save-excursion (let* ((lim (max (point-min) (- (point) cfml-helper-search-limit))) (context (if (re-search-backward cfml-helper-indentation-list lim t) (cfml-helper-context-symbol) nil))) (cons context (current-indentation))))) (defun cfml-helper-print-prev-context () (interactive) (message "%s" (cfml-helper-guess-prev-context))) ;;}}} ;;{{{ indentation (defvar cfml-helper-buffers nil "buffers using cfml-helper-mode alist") (defvar cfml-helper-print-indent-info nil "If t, indent will print out information as a message.") (defun cfml-helper-indent-command () "Command for indenting HTML to the appropriate column. Calls `cfml-helper-indent' which tries to examine how many levels down in nested lists we are and does the appropriate indentation.' See also `cfml-helper-basic-offset' and `cfml-helper-never-indent'." (interactive) (cfml-helper-indent)) ;; some ideas borrowed from cc-mode.el. ;; Basic logic: ;; if this line is some sort of list token, indent according to prev context: ;; if previous context was a list-end or item-start, use its indentation ;; if previous context was a list start, indent forward basic-offset ;; ignore previous list-ends, their indentation is unreliable. ;; then if this is some sort of list-item, do special case fixups: ;; if this is a item start or end and previous was a list end, go back ;; item-continue-indent (the is probably indented for an
  • ;; if this is a list end and previous was a list end, go back ;; item-continue-indent (the is probably indented for an
  • ;; if this is a list end and prev *not* a list end, go back basic-offset ;; else if this line is not a list item, and previous line is a item-start ;; indent continue-indent, because this is part of the item ;; code to never indent
     sections. Many thanks to
    ;; Stan Lanning 
    (defun cfml-helper-indent-leave-alone-p ()
      (let* ((pre (save-excursion (search-backward "
    " nil t)))
      (endpre (save-excursion (search-backward "
    " pre t)))) (and pre (null endpre)))) (defadvice cfml-helper-indent (around leave-pre-alone activate) (cond ((not (cfml-helper-indent-leave-alone-p)) ad-do-it) (cfml-helper-print-indent-info (message "In
     -- skipping indentation"))
     (t nil)))
    
    (defun cfml-helper-indent ()
      "Indentation workhorse function."
      (if cfml-helper-never-indent
          ()
        (let ((m (point-marker))
       (bol (progn (beginning-of-line) (point))))
    
          ;; unindent the line
          (delete-region (point) (progn (back-to-indentation) (point)))
    
          (let* ((where (cfml-helper-guess-prev-context))
          (prev-context (car where))
          (this-context nil)
          (previ (cdr where))
          (newi (cond
          ((eq prev-context 'list-end) previ)
          ((eq prev-context 'item-start) previ)
          ((eq prev-context 'list-start) (+ previ cfml-helper-basic-offset))
          (t previ))))
    
     ;; newi is set to the basic indentation, now adjust indentation
     ;; based on what the current line is.
     (if (looking-at cfml-helper-any-list)
         (progn
           (setq this-context (cfml-helper-context-symbol))
           (cond
            ;; item start or end and last line was a list-end: go backwards
            ((and
       (or (eq this-context 'item-start) (eq this-context 'item-end))
       (eq prev-context 'list-end))
      (setq newi (- newi cfml-helper-basic-offset)))
    
            ;; end of list and last line was an end: go backwards twice
            ((and (eq this-context 'list-end) (eq prev-context 'list-end))
      ;; Wed Jan 10 09:35:53 2001 Saint
      ;;
      ;; fixing indentation
      ;;  (setq newi (- newi cfml-helper-basic-offset
    cfml-helper-item-continue-indent)))
      (setq newi (- newi cfml-helper-basic-offset)))
    
            ;; Any other end of list? Indent negative
            ((and (eq this-context 'list-end))
      (setq newi (- newi cfml-helper-basic-offset)))
    
            ;; start of list and last line beginning of item, go forwards
            ((and (eq this-context 'list-start)
           (eq prev-context 'item-start))
      (setq newi (+ newi cfml-helper-basic-offset)))))
    
       ;; default: no special case, indent forward for text
       (cond
        ;; last line an item? Beginning of continued item - go forward
        ((eq prev-context 'item-start)
         (setq newi (+ newi cfml-helper-basic-offset)))))
    
     (if cfml-helper-print-indent-info
         (message
          "Last Context: %s, This Context: %s, Previous: %s New: %s"
          prev-context this-context previ newi))
    
     ;; just in case
     (if (< newi 0)
         (setq newi 0))
     (indent-to newi newi)
    
     ;; adjust point to where it was before, or at start of indentation
     (goto-char (marker-position m))
     (if (< (current-column) (current-indentation))
         (back-to-indentation))))))
    
    ;;}}}
    
    ;;{{{ completion finder for tempo
    
    (defvar cfml-helper-completion-finder
      (if cfml-helper-emacs18
          'cfml-helper-emacs18-completion-finder
        "\\(\\(<\\|&\\).*\\)\\=")
      "Passed to tempo-use-tag-list, used to find tags to complete.")
    
    ;; The regexp finds everything between the last < or & and point,
    ;; which is good enough to match the tags HTML might complete.
    ;; emacs18 doesn't have the \= for regexps, though, so we do something
    ;; more hackish.
    
    (defun cfml-helper-emacs18-completion-finder ()
      "Unfortunately emacs18 doesn't support \\= in regexps, so we do this hack.
    If you have problems with it, maybe you should upgrade to emacs19 :-)"
      (let* ((where nil)
             (s (buffer-substring
                 (point)
                 (setq where (save-excursion
                               (re-search-backward "<\\|&" (min (point-min) 100)
    t)
                               (point))))))
        (cons s where)))
    
    ;;}}}
    
    ;;{{{ timestamps
    
    (defun cfml-helper-update-timestamp ()
      "Basic function for updating timestamps.
    It finds the timestamp in the buffer by looking for
    `cfml-helper-timestamp-start', deletes all text up to
    `cfml-helper-timestamp-end', and runs `cfml-helper-timestamp-hook' which
    will should insert an appropriate timestamp in the buffer."
      (save-excursion
        (goto-char (point-max))
        (if (not (search-backward cfml-helper-timestamp-start nil t))
     (message "timestamp delimiter start was not found")
          (let ((ts-start (+ (point) (length cfml-helper-timestamp-start)))
         (ts-end (if (search-forward cfml-helper-timestamp-end nil t)
       (- (point) (length cfml-helper-timestamp-end))
            nil)))
     (if (not ts-end)
         (message "timestamp delimiter end was not found. Type C-c C-t to insert
    one.")
       (delete-region ts-start ts-end)
       (goto-char ts-start)
       (run-hooks 'cfml-helper-timestamp-hook)))))
      nil)
    
    (defun cfml-helper-default-insert-timestamp ()
      "Default timestamp insertion function."
      (let ((time (current-time-string)))
        (insert "Last modified: "
         (substring time 0 20)
         (nth 1 (current-time-zone))
         " "
         (substring time -4)
         " ")))
    
    (defun cfml-helper-insert-timestamp-delimiter-at-point ()
      "Simple function that inserts timestamp delimiters at point.
    Useful for adding timestamps to existing buffers."
      (interactive)
      (insert cfml-helper-timestamp-start)
      (insert cfml-helper-timestamp-end))
    
    ;;}}}
    
    ;;{{{ cfml-helper-insert-new-buffer-strings
    
    (tempo-define-template "html-skeleton" cfml-helper-new-buffer-template
             nil
             "Insert a skeleton for a HTML document")
    
    (tempo-define-template "ASP-skeleton" cfml-helper-new-ASP-buffer-template
             nil
             "Insert a skeleton for a ASP document")
    
    (tempo-define-template "PHP-skeleton" cfml-helper-new-PHP-buffer-template
             nil
             "Insert a skeleton for a PHP document")
    
    (tempo-define-template "JSP-skeleton" cfml-helper-new-JSP-buffer-template
             nil
             "Insert a skeleton for a JSP document")
    
    (defun cfml-helper-insert-new-buffer-strings ()
      "Insert `cfml-helper-new-buffer-strings'."
      (tempo-template-html-skeleton))
    
    (defun cfml-helper-insert-new-ASP-buffer-strings ()
      "Insert `cfml-helper-new-ASP-buffer-strings' or
    `cfml-helper-new-JSP-buffer-string'."
      (cond (cfml-helper-mode-local-JSP-not-ASP
      (tempo-template-JSP-skeleton))
     (t
      (tempo-template-ASP-skeleton))))
    
    (defun cfml-helper-insert-new-PHP-buffer-strings ()
      "Insert `cfml-helper-new-PHP-buffer-strings'."
      (tempo-template-PHP-skeleton))
    
    ;;}}}
    
    ;;{{{ cfml-helper-mode
    
    (defun base-cfml-helper-mode (mode)
      "basic mode, called by the exported modes with MODE telling what
    is the mode to run (that's the skeleton to insert in empty files)"
      (kill-all-local-variables)
    
      (use-local-map cfml-helper-mode-map)
      (setq local-abbrev-table cfml-helper-mode-abbrev-table)
      (set-syntax-table cfml-helper-mode-syntax-table)
    
      (cond (cfml-helper-mode-run-the-mode
      (make-local-variable 'comment-start)
      (make-local-variable 'comment-end)
      (make-local-variable 'comment-column)
      (make-local-variable 'comment-start-skip)
      (make-local-variable 'indent-line-function)
      (make-local-variable 'cfml-helper-count)
      (make-local-variable 'cfml-helper-mode-local-JSP-not-ASP)
      (make-variable-buffer-local 'cfml-helper-mode-run-the-mode)
      (set 'cfml-helper-mode-run-the-mode nil)
      (cfml-helper-add-buffer (current-buffer) mode)))
    
      ;; font-lock setup for various emacsen: XEmacs, Emacs 19.29+, Emacs
    <19.29.
      ;; By Ulrik Dickow .  (Last update: 05-Sep-1995).
      (cond ((string-match "XEmacs\\|Lucid" (emacs-version)) ; XEmacs/Lucid
      (put major-mode 'font-lock-keywords-case-fold-search t)
      )
     ;; XEmacs (19.13, at least) guesses the rest correctly.
     ;; If any older XEmacsen don't, then tell me.
     ;;
     ((string-lessp "19.28.89" emacs-version) ; Emacs 19.29 and later
      (make-local-variable 'font-lock-defaults)
      (setq font-lock-defaults '(cfml-helper-font-lock-keywords t t)))
     ;;
     (t ; Emacs 19.28 and older
      (make-local-variable 'font-lock-keywords-case-fold-search)
      (make-local-variable 'font-lock-keywords)
      (make-local-variable 'font-lock-no-comments)
      (setq font-lock-keywords-case-fold-search t)
      (setq font-lock-keywords cfml-helper-font-lock-keywords)
      (setq font-lock-no-comments t)))
    
      (setq comment-start ""
     comment-start-skip "', but also e.g the single, complete
    declaration
    ;      ;; `c3 (still comment) ----c4- c4--   >'.
    ;      ;; Note that e.g. Netscape 3.01 Gold doesn't fully live up to the
    spec.
    
    ;      ;; A Regexp doesn't work well with big blocks...
    ;      ;;      '("', but also e.g the single, complete
    declaration
         ;; `c3 (still comment) ----c4- c4--   >'.
         ;; Note that e.g. Netscape 3.01 Gold doesn't fully live up to the spec.
    
         ;; That's krazy, strings higlight matches ) too, so i paint
         ;; parantheses...
         '("\\(<%\\|\\s(\\)" 1 font-lock-function-name-face t)
         '("\\(\\s)\\|%>\\)" 1 font-lock-function-name-face t)
         '("\\(<\\?\\|\\s(\\)" 1 font-lock-function-name-face t)
         '("\\(\\s)\\|\\?>\\)" 1 font-lock-function-name-face t)
         '("\\([\"]\\)" 0 font-lock-string-face t)
         ;; A Regexp doesn't work well with big blocks...
         ;;      '("" comment)
           ("[^<>]*\\(<[^>]*>[^<>]*\\)*>" nil comment) ;
           ("" "" defun)
           ("" "" bold) ;only colour inside tag
           ("" define)
           ("" nil define)
           ("" include)
           ("" include)
           ;; First  highlighting just handles unnested tags, then do nesting
           ("[^<]*" nil italic)
           ("" "" bold)
           ("" "" italic)
           ("" "" underline)
           ("&[^;\n]*;" nil string)
           ;; w3 org says that a tag is  not < element-name>
           ("<[^ \t]" ">" keyword))
         nil 'case-insensitive)
      nil)
    ;;}}}
    
    ;;{{{ indentation
    
    (defvar cfml-helper-print-indent-info nil
      "If t, indent will print out information as a message.")
    
    ;; some ideas borrowed from cc-mode.el.
    ;; Basic logic:
    ;;   if this line is some sort of list token, indent according to prev
    context:
    ;;     if previous context was a list-end or item-start, use its indentation
    ;;     if previous context was a list start, indent forward basic-offset
    ;;     ignore previous list-ends, their indentation is unreliable.
    ;;     then if this is some sort of list-item, do special case fixups:
    ;;       if this is a item start or end and previous was a list end, go back
    ;;           item-continue-indent (the  is probably indented for an
    
  • ;; if this is a list end and previous was a list end, go back ;; item-continue-indent (the is probably indented for an
  • ;; if this is a list end and prev *not* a list end, go back basic-offset ;; else if this line is not a list item, and previous line is a item-start ;; indent continue-indent, because this is part of the item ;;}}} ;;{{{ Script Narrowing and mode switch ;; These are for supporting html-script. With small changes can be useful for ;; javascript ;; Stan Lanning wrote these defadvice to preserve ;; cursor position. Thank you very much Stan! (defadvice html-script-narrow-to-asp (around save-excursion activate) (save-excursion ad-do-it)) (defadvice html-script-narrow-to-php (around save-excursion activate) (save-excursion ad-do-it)) (defadvice html-script-narrow-to-vbscript (around save-excursion activate) (save-excursion ad-do-it)) (defadvice html-script-narrow-to-javascript (around save-excursion activate) (save-excursion ad-do-it)) (defadvice html-script-release-region (around save-excursion activate) (save-excursion ad-do-it)) (defun html-script-narrow-to-asp () "Narrows to an JSP/ASP script and switches to either java-mode/JDE or visual-basic-mode. Does nothing if both cfml-helper-mode-uses-visual-basic and cfml-helper-mode-local-JSP-not-ASP are nil" (interactive) (cond ((html-script-choose-mode) (html-script-search-start-tag) (let ((beg (point))) (html-script-search-end-tag) (narrow-to-region beg (point))) (html-script-choose-server-mode) (goto-char 0)))) (defun html-script-search-start-tag () (cond ( cfml-helper-mode-uses-KG-style (search-backward-regexp "^<%") ) (t (search-backward "<%" )))) (defun html-script-search-end-tag () (cond ( cfml-helper-mode-uses-KG-style (search-forward-regexp "^%>" )) ( t (search-forward "%>" nil t)))) (defun html-script-choose-mode () (or cfml-helper-mode-uses-visual-basic cfml-helper-mode-local-JSP-not-ASP)) (defun html-script-choose-server-mode () (cond (cfml-helper-mode-local-JSP-not-ASP (cond (cfml-helper-mode-uses-JDE (cfml-helper-enters-jde-mode)) (t (java-mode)))) (t (visual-basic-mode)))) (defun html-script-narrow-to-php () "Narrows to an ASP script and setups c-mode" (interactive) (search-backward "" nil t) (narrow-to-region beg (point))) (c-mode) (goto-char 0)) (defun html-script-narrow-to-vbscript () "Narrows to a VB Script script and setups visual basic mode. Does nothing if cfml-helper-mode-uses-visual-basic is nil" (interactive) (cond (cfml-helper-mode-uses-visual-basic (search-backward-regexp "") (let ((beg (point))) (search-forward "" nil t) (narrow-to-region beg (point))) (visual-basic-mode) (goto-char 0)))) (defun html-script-narrow-to-javascript () "Narrows to a JavaScript script and setups java mode" (interactive) (search-backward-regexp "") (let ((beg (point))) (search-forward "" nil t) (narrow-to-region beg (point))) (cond (cfml-helper-mode-uses-JDE (jde-mode)) (t java-mode)) (goto-char 0)) (defun cfml-helper-add-buffer (buffer tag) (cond ((and cfml-helper-buffers (cfml-helper-buffer-listed)) (set 'cfml-helper-buffers (cons (cons buffer tag) cfml-helper-buffers ))) (t (set 'cfml-helper-buffers (list (cons buffer tag)))))) ;; Fri Aug 03 18:12:14 2001 Saint ;; ;; This function checks if the current buffer is not in ;; html-herlper-buffer list (defun cfml-helper-buffer-listed () (let ((retval t)) (mapcar (lambda (a) (cond ((eq (current-buffer) (car a)) (set 'retval nil)))) cfml-helper-buffers) retval)) ;;/Saint (defun cfml-helper-remove-buffer () (let ((nl nil)) (while cfml-helper-buffers (cond ((not (eq (current-buffer) (car (car cfml-helper-buffers)))) (set 'nl (cons (car cfml-helper-buffers) nl)) (set 'cfml-helper-buffers (cdr cfml-helper-buffers))) (t (set 'cfml-helper-buffers (cdr cfml-helper-buffers))))) (set 'cfml-helper-buffers nl))) (defun html-script-release-region () "widens the window to the complete buffer and runs cfml-helper-mode. MUST be interactive." (interactive) (mapcar (lambda (a) (cond ((eq (current-buffer) (car a)) (cfml-helper-seletct-appropriate-mode (cdr a))))) cfml-helper-buffers)) (defun cfml-helper-seletct-appropriate-mode( cfml-helper-used-mode) (interactive) (goto-char 0) (widen) (cond ((string= "HTML" cfml-helper-used-mode) (cfml-helper-mode-run)) ((string= "ASP" cfml-helper-used-mode) (asp-cfml-helper-mode-run)) ((string= "JSP" cfml-helper-used-mode) (jsp-cfml-helper-mode-run)) ((string= "PHP" cfml-helper-used-mode) (php-cfml-helper-mode-run)))) (defun html-script-release-setup() (interactive) (local-set-key html-script-toggle-key 'html-script-release-region)) (cond (cfml-helper-mode-uses-visual-basic (cond (visual-basic-mode-hook (add-hook 'visual-basic-mode-hook 'html-script-release-setup)) (t (setq visual-basic-mode-hook 'html-script-release-setup))))) (cond (c-mode-hook (add-hook 'c-mode-hook 'html-script-release-setup)) (t (setq c-mode-hook 'html-script-release-setup))) ;; Very Very ALPHA!!! ;; ;; Adding html-script-release-setup to jde-entering-java-buffer-hooks ;; (cond (cfml-helper-mode-uses-JDE (if (and cfml-helper-mode-uses-JDE (fboundp 'jde-mode)) (add-hook 'jde-mode-hook 'html-script-release-setup))) (t (cond (java-mode-hook (add-hook 'java-mode-hook 'html-script-release-setup)) (t (setq java-mode-hook 'html-script-release-setup)))) ) (defun cfml-helper-enters-jde-mode() (interactive) (and cfml-helper-mode-uses-JDE (fboundp 'jde-mode)) (add-hook 'jde-mode-hook 'html-script-release-setup) (jde-mode)) ;; Still from Stan Lanning here it comes the code for a "smart switch" to ;; the appropriate scripting mode. (defvar html-script-toggle-key [f4]) (defvar html-script-narrow-alist `((,(regexp-quote "<%") . html-script-narrow-to-asp) (,(regexp-quote "" . html-script-narrow-to-vbscript) ("" . html-script-narrow-to-vbscript) ("" . html-script-narrow-to-javascript) ("" . html-script-narrow-to-javascript))) (defvar html-script-start-regexp (concat "\\(" (mapconcat (lambda (x) (car x)) html-script-narrow-alist "\\|") "\\)")) (defun html-script-toggle-narrow () (interactive) (let ((handler-fn (save-excursion (if (re-search-backward html-script-start-regexp nil t) (catch 'handler-found (mapcar (lambda (p) (if (looking-at (car p)) (throw 'handler-found (cdr p)))) html-script-narrow-alist) nil))))) (if handler-fn (apply handler-fn nil) (error "No script tag found")))) (defun html-script-install-toggle-key () (local-set-key html-script-toggle-key 'html-script-toggle-narrow)) (add-hook 'cfml-helper-mode-hook 'html-script-install-toggle-key) (defadvice html-script-release-setup (after key-binding activate) (local-set-key html-script-toggle-key 'html-script-release-region)) ;;}}} ;; folding tags: End of code tree ;;}}} ;;{{{ Epilogue (provide 'cfml-helper-mode) (provide 'php-cfml-helper-mode) (provide 'asp-cfml-helper-mode) (provide 'jsp-cfml-helper-mode) (provide 'html-mode) ;for 14 character filename (cond ((boundp 'kill-buffer-hook) (add-hook 'kill-buffer-hook 'cfml-helper-remove-buffer)) (t (set 'kill-buffer-hook 'cfml-helper-remove-buffer))) (run-hooks 'html-load-hook) (run-hooks 'cfml-helper-load-hook) ;;}}} ;;; cfml-helper-mode.el ends here (cfml-helper-add-type-to-alist '(cf . (cf-html-map "\C-c\C-c" cf-html-menu "Insert Cold Fusion Elements"))) (cfml-helper-install-type 'cf) (cfml-helper-add-tag '(cf "u" "" "cf update" ("\n"))) (cfml-helper-add-tag '(cf "t" "" "cf table" ("" (p "Table definition: ") "\n\n"))) (cfml-helper-add-tag '(cf "s" "" "cf set" ("\n"))) (cfml-helper-add-tag '(cf "r" "" "cf report" ("" (p "Body: ") "\n\n"))) (cfml-helper-add-tag '(cf "q" "" "cf query" ("" (p "Body: ") "\n\n"))) (cfml-helper-add-tag '(cf "p" "" "cf param" ("\n"))) (cfml-helper-add-tag '(cf "o" "" "cf output" ("" (p "Text: ") "\n\n"))) (cfml-helper-add-tag '(cf "m" "" "cf mail" ("" (p "Body: ") "\n\n"))) (cfml-helper-add-tag '(cf "Q" "" "cf loop, query" ("" (p "Body: ") "\n\n"))) (cfml-helper-add-tag '(cf "L" "" "cf loop, list" ("" (p "Body: ") "\n\n"))) (cfml-helper-add-tag '(cf "I" "" "cf loop, index" ("" (p "Body: ") "\n\n"))) (cfml-helper-add-tag '(cf "C" "" "cf loop, conditional" ("" (p "Body: ") "\n\n"))) (cfml-helper-add-tag '(cf "w" "" "cf location" ("\n"))) (cfml-helper-add-tag '(cf "d" "" "cf insert" ("\n"))) (cfml-helper-add-tag '(cf "n" "" "cf include" ("\n"))) (cfml-helper-add-tag '(cf "i" "" "cf if" ("" (p "Body: ") "\n\n"))) (cfml-helper-add-tag '(cf "h" "" "cf header" ("\n"))) (cfml-helper-add-tag '(cf "f" "" "cf file" ("\n"))) (cfml-helper-add-tag '(cf "e" "" "cf error" ("\n"))) (cfml-helper-add-tag '(cf "k" "" "cf cookie" ("\n"))) (cfml-helper-add-tag '(cf "k" "" "cf content" ("\n"))) (cfml-helper-add-tag '(cf "c" "" "cf col" ("\n"))) (cfml-helper-add-tag '(cf "a" "" "cf abort" ("\n"))) (cfml-helper-add-tag '(cf "t" "" "cf application" ("\n"))) (cfml-helper-add-tag '(cf "a" "" "cf abort" ("\n"))) (cfml-helper-rebuild-menu) ------------8<----------/cfml-helper-mode.el----------------8<-------------- -- ------------8<----------help-url.el----------------8<----------------------- ---- ;;; help-url.el --- Un module pour se connecter aux aides en lignes de php ou de coldfusion ;; Copyright (C) 2003 Free Software Foundation, Inc. ;; Author: Norbert Caudéran ;; Keywords: ;; This file 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 2, or (at your option) ;; any later version. ;; This file 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 GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Commentary: ;; ;;; Code: (defvar help-url-cfm-base-help-url '("file:c:\\Program Files\\Allaire\\HomeSite 4.5\\Extensions\\Docs\\CFMLTags" "file:c:\\Program Files\\Allaire\\HomeSite 4.5\\Extensions\\Docs\\CFMLFunctions") "Les répertoires dans lesquels sont stockés les fichiers d'aide CFM, ou l'unique URL") (defvar help-url-php-base-help-url '("http://www.php.net/") "Les répertoires dans lesquels sont stockés les fichiers d'aide PHP, ou l'unique URL") (defun word-2-url-cfm (base word) "Crée l'url cfm" (concat base "\\" word ".htm") ) (defun word-2-url-php (base word) "Crée l'url php" (concat base word) ) (fset 'word-2-url 'word-2-url-cfm) (setq help-url-base-help-url help-url-cfm-base-help-url) (defun help-url-find-page (word) "Crée une liste d'url possibles à partir du mot clé" (setq nberr 0) (dolist (url (mapcar (lambda (base) (word-2-url base word)) help-url-base-help-url)) (condition-case err (browse-url url) (error (setq nberr (+ nberr 1))))) (if (eq nberr (length help-url-cfml-base-help-url)) (concat "Pas d'aide disponible pour " word) "Affichage du fichier d'aide")) (defun help-url-at-word () "Affiche la page d'aide du mot courant" (interactive) (message (help-url-find-page (current-word t)))) (global-set-key [C-f4] 'help-url-at-word) (provide 'help-url) ;;; help-url.el ends here ------------8<----------/help-url.el----------------8<---------------------- ----