From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Ian Zimmerman Newsgroups: gmane.emacs.help Subject: Re: Browse skeleton positions Date: 11 Nov 2003 09:49:20 -0800 Organization: http://extra.newsguy.com Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <87smkuiyn3.fsf@newsguy.com> References: <87vfqnygi7.fsf@newsguy.com> <877k32jumc.fsf@newsguy.com> <87k76muvma.fsf@newsguy.com> <87y8uy69ag.fsf@newsguy.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1068575348 13893 80.91.224.253 (11 Nov 2003 18:29:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 11 Nov 2003 18:29:08 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Nov 11 19:29:05 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AJdGC-0005xG-00 for ; Tue, 11 Nov 2003 19:29:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AJe0W-0008Pc-Pm for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Nov 2003 14:16:56 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!pln-w!spln!dex!extra.newsguy.com!newsp.newsguy.com!enews3 Original-Newsgroups: gnu.emacs.help,gnu.emacs.sources Original-Followup-To: gnu.emacs.help Original-Lines: 250 Original-NNTP-Posting-Host: p-391.newsdawg.com User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-Xref: shelby.stanford.edu gnu.emacs.help:118134 gnu.emacs.sources:9794 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:14075 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:14075 ;;; skelposn.el --- browse skeleton positions after insertion ;; Copyright (C) Ian Zimmerman, October 2003 ;; Terms: GNU General Public License, Version 2 (defconst skeleton-position-mode-map (let ((kmap (make-sparse-keymap))) (suppress-keymap kmap) (define-key kmap "q" 'turn-off-skeleton-position-mode) (define-key kmap "\C-m" 'skeleton-position-exit) (define-key kmap "n" 'skeleton-position-next) (define-key kmap "p" 'skeleton-position-prev) (define-key kmap "a" 'skeleton-position-first) (define-key kmap "z" 'skeleton-position-last) kmap) "Keymap used in Skeleton Position mode.") (defvar skeleton-position-carpal-mode-prefix [?\C-c ?+] "*Prefix key sequence for commands in Skeleton Position Carpal mode.") (defconst skeleton-position-carpal-mode-map (let ((kmap (make-sparse-keymap))) (define-key kmap skeleton-position-carpal-mode-prefix skeleton-position-mode-map) kmap) "Keymap used in Skeleton Position Carpal mode.") (defvar skeleton-position-max-list-length 50 "*How many markers per buffer to keep in skeleton position mode. If nil or negative, the lists of markers are allowed to grow without limit, which can slow down Emacs dramatically.") ;;;###autoload (define-minor-mode skeleton-position-mode "Set or toggle the Skeleton Position minor mode. \\ This mode provides an interface to browse the list of interesting position after a skeleton is inserted. \\[skeleton-position-next] - Move to the next marker in `skeleton-position-marker-list'. \\[skeleton-position-prev] - Move to the previous marker in `skeleton-position-marker-list'. \\[skeleton-position-first] - Move to the first marker in `skeleton-position-marker-list'. \\[skeleton-position-last] - Move to the last marker in `skeleton-position-marker-list'. \\[skeleton-position-exit] - Clean up old skeleton positions and exit Skeleton Position mode." nil " SkelPosn" skeleton-position-mode-map) ;;;###autoload (defun turn-on-skeleton-position-mode () "Turn on the Skeleton Position minor mode." (interactive) (skeleton-position-mode 1)) (defun turn-off-skeleton-position-mode () "Turn off the Skeleton Position minor mode." (interactive) (skeleton-position-mode 0)) (defvar skeleton-position-marker-list nil "List of markers pointing to skeleton positions in a buffer.") (make-variable-buffer-local 'skeleton-position-marker-list) (defvar skeleton-position-push-mark nil "\\\ When set, causes \\[skeleton-position-next] and \\[skeleton-position-prev] \ in Skeleton Position mode to push a mark at point.") (make-variable-buffer-local 'skeleton-position-push-mark) (defvar skeleton-position-current nil "\\\ The last position visited by \\[skeleton-position-next] or \\[skeleton-position-prev] \ in Skeleton Position mode, as a pointer into `skeleton-position-marker-list'.") (make-variable-buffer-local 'skeleton-position-current) (defun skeleton-end-hook-skelposn () (setq skeleton-position-marker-list (append (nreverse (mapcar (lambda (p) (copy-marker p t)) skeleton-positions)) skeleton-position-marker-list)) (let ((l (length skeleton-position-marker-list))) (when (and (integerp skeleton-position-max-list-length) (>= skeleton-position-max-list-length 0) (< skeleton-position-max-list-length l)) (let* ((rest-length (- l skeleton-position-max-list-length)) (rest (nthcdr skeleton-position-max-list-length skeleton-position-marker-list)) (head (nbutlast skeleton-position-marker-list rest-length))) (when (and (consp skeleton-position-current) (memq (car skeleton-position-current) rest)) (setq skeleton-position-current nil)) (mapcar (lambda (m) (set-marker m nil)) rest) (setq skeleton-position-marker-list head)))) (when (and skeleton-position-marker-list (null skeleton-position-current)) (setq skeleton-position-push-mark t))) (unless (featurep 'skelposn) (add-hook 'skeleton-end-hook 'skeleton-end-hook-skelposn)) (defun skeleton-position-next (&optional n) "Move to the next marker in `skeleton-position-marker-list'. With an argument N, move to the Nth next marker on the list, after `skeleton-position-current' instead. If N is zero or negative, move to the Nth previous marker on the list. The first call after a skeleton is inserted pushes a mark before moving." (interactive "p") (if (< n 0) (skeleton-position-prev n) (unless skeleton-position-current (setq skeleton-position-current (last skeleton-position-marker-list))) (while (> n 0) (while (and skeleton-position-current (cdr skeleton-position-current) (> n 0)) (setq skeleton-position-current (cdr skeleton-position-current) n (1- n))) (when (> n 0) (setq n (1- n) skeleton-position-current skeleton-position-marker-list))) (when (null skeleton-position-current) (error "No more skeleton positions")) (when skeleton-position-push-mark (when (/= (point) (car skeleton-position-current)) (push-mark)) (setq skeleton-position-push-mark nil)) (goto-char (car skeleton-position-current)))) (defun skeleton-position-prev (&optional n) "Move to the previous marker in `skeleton-position-marker-list'. With an argument N, move to the Nth previous marker on the list, before `skeleton-position-current' instead. If N is zero or negative, move to the Nth next marker on the list. The first call after a skeleton is inserted pushes a mark before moving." (interactive "p") (if (< n 0) (skeleton-position-next n) (unless skeleton-position-current (setq skeleton-position-current skeleton-position-marker-list)) (setq skeleton-position-marker-list (nreverse skeleton-position-marker-list)) (unwind-protect (while (> n 0) (while (and skeleton-position-current (cdr skeleton-position-current) (> n 0)) (setq skeleton-position-current (cdr skeleton-position-current) n (1- n))) (when (> n 0) (setq n (1- n) skeleton-position-current skeleton-position-marker-list))) (setq skeleton-position-marker-list (nreverse skeleton-position-marker-list))) (when (null skeleton-position-current) (error "No more skeleton positions")) (when skeleton-position-push-mark (when (/= (point) (car skeleton-position-current)) (push-mark)) (setq skeleton-position-push-mark nil)) (goto-char (car skeleton-position-current)))) (defun skeleton-position-first () "Move to the first marker in `skeleton-position-marker-list'." (interactive) (setq skeleton-position-current skeleton-position-marker-list) (when (null skeleton-position-current) (error "No more skeleton positions")) (when skeleton-position-push-mark (when (/= (point) (car skeleton-position-current)) (push-mark)) (setq skeleton-position-push-mark nil)) (goto-char (car skeleton-position-current))) (defun skeleton-position-last () "Move to the last marker in `skeleton-position-marker-list'." (interactive) (setq skeleton-position-current (last skeleton-position-marker-list)) (when (null skeleton-position-current) (error "No more skeleton positions")) (when skeleton-position-push-mark (when (/= (point) (car skeleton-position-current)) (push-mark)) (setq skeleton-position-push-mark nil)) (goto-char (car skeleton-position-current))) (defun skeleton-position-cleanup () (when skeleton-position-current (let ((rest (cdr skeleton-position-current))) (setcdr skeleton-position-current nil) (setq skeleton-position-current nil) (mapcar (lambda (m) (set-marker m nil)) skeleton-position-marker-list) (setq skeleton-position-marker-list rest)))) (defun skeleton-position-exit () "Clean up old skeleton positions and exit Skeleton Position mode." (interactive) (skeleton-position-cleanup) (turn-off-skeleton-position-mode)) ;;;###autoload (define-minor-mode skeleton-position-carpal-mode "Set or toggle the Skeleton Position Carpal minor mode. \\ This mode provides an interface to browse the list of interesting position after a skeleton is inserted. It is like `skeleton-position-mode', but does not rebind any normal editing keystrokes. \\[skeleton-position-carpal-next] - Move to the next marker in `skeleton-position-marker-list'. \\[skeleton-position-carpal-prev] - Move to the previous marker in `skeleton-position-marker-list'. \\[skeleton-position-carpal-first] - Move to the first marker in `skeleton-position-marker-list'. \\[skeleton-position-carpal-last] - Move to the last marker in `skeleton-position-marker-list'. \\[skeleton-position-carpal-exit] - Clean up old skeleton positions and exit Skeleton Position Carpal mode." nil " SkelCarp" skeleton-position-carpal-mode-map) (defalias 'skeleton-position-carpal-next 'skeleton-position-next) (defalias 'skeleton-position-carpal-prev 'skeleton-position-prev) (defalias 'skeleton-position-carpal-first 'skeleton-position-first) (defalias 'skeleton-position-carpal-last 'skeleton-position-last) ;;;###autoload (defun turn-on-skeleton-position-carpal-mode () "Turn on the Skeleton Position Carpal minor mode." (interactive) (skeleton-position-carpal-mode 1)) (defun turn-off-skeleton-position-carpal-mode () "Turn off the Skeleton Position Carpal minor mode." (interactive) (skeleton-position-carpal-mode 0)) (defun skeleton-position-carpal-exit () "Clean up old skeleton positions and exit Skeleton Position Carpal mode." (interactive) (skeleton-position-cleanup) (turn-off-skeleton-position-carpal-mode)) ;;;###autoload (defun skeleton-position-reset () "Clean up all saved skeleton positions." (interactive) (mapcar (lambda (m) (set-marker m nil)) skeleton-position-marker-list) (setq skeleton-position-marker-list nil) (setq skeleton-position-current nil)) (provide 'skelposn) ;;; skelposn.el ends here -- "Rap music is our punishment for neglecting music education." An anonymous teacher