help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Skeleton With Embedded Quotes


From: Tim Johnson
Subject: Re: Skeleton With Embedded Quotes
Date: Tue, 22 Nov 2005 07:32:37 -0900
User-agent: Mutt/1.4.2.1i

* gamename <namesagame-usenet@yahoo.com> [051120 12:37]:
> Hi,
 
  Hello:

> I'm trying to create a skeleton for a debug statement in tcl.  I want
> the skeleton to produce something like this:
> 
> mylib::debug " "
> 
> (The cursor would be placed between the quotations.)
> 
> Unfortunately, skeleton uses double quotes as the delimiter for its own
> definition.  So, how do you get skeleton to print double quotes?  Here
> is what I have so Far:
 
  I'm not entirely sure what you are up to here, since your approach
  differs from mine, but you can escape a double quote with a backslash.
  I use the elisp 'insert function for inserting debug stubs.

>
> (define-skeleton tcl-debug
>   "Tcl debug statement"  nil
>   > "mylib::debug " \ \n)

You might find the code below useful as an example - bear in mind, that
I am pretty new to elisp.

(defun debug-stub-global ()
    " Insert debugging code for non-class variable"
    (interactive "*")
    (cond ((string-equal mode-name "Rebol Mode")
           (beginning-of-line-text)
           (insert "dbg ")
           (tj-next-whitespace)
           (insert " ;; DEBUG STUB"))
         ((string-equal mode-name "JavaScript")
           (let (cur-word)
             (setq cur-word (current-word))
             (beginning-of-line-text)
             (kill-line)
             (insert (concat "alert('" cur-word ": ' + " cur-word ");"))))
         ((string-equal mode-name "Python")
           (let (cur-word)
             (setq cur-word (current-word))
             (beginning-of-line-text)
             (kill-line)
             (insert (concat "print \"<BR>" cur-word " = \", " cur-word " # 
DEBUG " cur-word))))
         (t(message "NOT IMPLEMENTED FOR THIS MODE!"))))
;; this should be the only dependency:
(defun tj-next-whitespace ()
  "Move cursor to next whitespace OR end of line."
  (interactive)
  (re-search-forward "$\\|[\t ]"))

HTH
-- 
Tim Johnson <tim@johnsons-web.com>
      http://www.alaska-internet-solutions.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]