What's new? | Help | Directory | Sign in
Google
smart-snippet
Textmate-like Emacs template extension with smarter behavior
  
  
  
  
    
Search
for
Updated Dec 20, 2007 by pluskid
Labels: Featured, Phase-Support
FAQ  
Frequently Asked Questions.

Why the snippet doesn't expand?

Make sure you've opened abbrev-mode for your current major-mode. You can enable abbrev-mode globally by:

(setq-default abbrev-mode t)

Or you can enable abbrev-mode for some particular mode. E.g. for c-mode:

(add-hook 'c-mode-hook
          '(lambda () (abbrev-mode 1)))

Does it support Emacs 21?

It is developed under Emacs 23 and (hopefully) capable to Emacs 21. You need to add the definition of looking-back from Emacs 22 if you are using Emacs 21:

(defun looking-back (regexp &optional limit greedy)
  "Return non-nil if text before point matches regular expression REGEXP.
Like `looking-at' except matches before point, and is slower.
LIMIT if non-nil speeds up the search by specifying how far back the
match can start.

If GREEDY is non-nil, extend the match backwards as far as possible,
stopping when a single additional previous character cannot be part
of a match for REGEXP."
  (let ((start (point))
	(pos
	 (save-excursion
	   (and (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t)
		(point)))))
    (if (and greedy pos)
	(save-restriction
	  (narrow-to-region (point-min) start)
	  (while (and (> pos (point-min))
		      (save-excursion
			(goto-char pos)
			(backward-char 1)
			(looking-at (concat "\\(?:"  regexp "\\)\\'"))))
	    (setq pos (1- pos)))
	  (save-excursion
	    (goto-char pos)
	    (looking-at (concat "\\(?:"  regexp "\\)\\'")))))
    (not (null pos))))

If there's still problems, please go to The general discussion group.


Sign in to add a comment