diff options
author | David Aspinall <da@inf.ed.ac.uk> | 2008-07-24 09:51:53 +0000 |
---|---|---|
committer | David Aspinall <da@inf.ed.ac.uk> | 2008-07-24 09:51:53 +0000 |
commit | 76d6b0b2b1f039549d308a0d2c478a6b05869af9 (patch) | |
tree | 78cc7e13bf290a17e7006a6d4616a8a08e36ce8f /lib/holes.el | |
parent | 8f8e9388b582ad6d3ee6e1eea842a8d443d4ce89 (diff) |
Merge changes from Version4Branch.
Diffstat (limited to 'lib/holes.el')
-rw-r--r-- | lib/holes.el | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/lib/holes.el b/lib/holes.el index 8fe9139f..65b1cc18 100644 --- a/lib/holes.el +++ b/lib/holes.el @@ -1,6 +1,7 @@ ;;; holes.el --- a little piece of elisp to define holes in your buffer ;; ;; Copyright (C) 2001 Pierre Courtieu +;; ;; $Id$ ;; ;; This file uses spans, an interface for extent (XEmacs) and overlays @@ -29,7 +30,7 @@ ;;; History: ;; -(require 'span) +(eval-when-compile (require 'span)) (require 'cl) ;;; Help: @@ -128,19 +129,6 @@ is), which is annoying. ;;; Code: -(cond - ((featurep 'xemacs) - (defalias 'holes-region-exists-p 'region-exists-p) - (defalias 'holes-get-selection 'get-selection)) - (t - ;;Pierre: should do almost what region-exists-p does in XEmacs - (defun holes-region-exists-p nil - "Return t if the mark is active, nil otherwise." - mark-active) - (defun holes-get-selection nil "See `current-kill'." - (current-kill 0)))) - - ;;; initialization (defvar holes-default-hole (make-detached-span) "An empty detached hole used as the default hole. @@ -204,17 +192,17 @@ which should be removed when making the text into a hole.") (defun holes-region-beginning-or-nil () "Internal." - (and (holes-region-exists-p) (region-beginning)) + (and mark-active (region-beginning)) ) (defun holes-region-end-or-nil () "Internal." - (and (holes-region-exists-p) (region-end)) + (and mark-active (region-end)) ) (defun holes-copy-active-region () "Internal." - (assert (holes-region-exists-p) nil "the region is not active now.") + (assert mark-active nil "the region is not active now.") (copy-region-as-kill (region-beginning) (region-end)) (car kill-ring) ) @@ -540,7 +528,7 @@ goal(FIXME?). Use `replace-active-hole' instead." "Replace the active hole by STR, if no str is given, then put the selection instead." (if (not (holes-active-hole-exist-p)) () (holes-replace - (or str (holes-get-selection) (error "Nothing to put in hole")) + (or str (current-kill 0) (error "Nothing to put in hole")) holes-active-hole) )) @@ -557,8 +545,8 @@ following hole if it exists." (let ((nxthole (holes-next-after-active-hole))) (holes-replace-active-hole (or str - (and (holes-region-exists-p) (holes-copy-active-region)) - (holes-get-selection) (error "Nothing to put in hole"))) + (and mark-active (holes-copy-active-region)) + (current-kill 0) (error "Nothing to put in hole"))) (if nxthole (holes-set-active-hole nxthole) (setq holes-active-hole holes-default-hole)) ) @@ -573,6 +561,8 @@ Sets `holes-active-hole' to the next hole if it exists." (holes-replace-update-active-hole "") ) + +;;;###autoload (defun holes-set-make-active-hole (&optional start end) "Make a new hole between START and END or at point, and make it active." @@ -628,11 +618,11 @@ Sets `holes-active-hole' to the next hole if it exists." (save-excursion ;;HACK: nothing if one click (but a second is perhaps coming) (if (and (eq (holes-track-mouse-clicks) 1) - (not (holes-region-exists-p))) + (not mark-active)) () - (if (not (holes-region-exists-p)) + (if (not mark-active) (error "Nothing to put in hole") - (holes-replace-update-active-hole (holes-get-selection)) + (holes-replace-update-active-hole (current-kill 0)) (message "hole replaced") ) ) @@ -696,10 +686,10 @@ Sets `holes-active-hole' to the next hole if it exists." (holes-track-mouse-selection event) (if (and (eq (holes-track-mouse-clicks) 1) - (not (holes-region-exists-p))) + (not mark-active)) (holes-set-make-active-hole (point) (point)) - (if (holes-region-exists-p) + (if mark-active (holes-set-make-active-hole) (let ((ext (holes-hole-at-event event))) (if (and ext (holes-is-hole-p ext)) @@ -740,15 +730,9 @@ Destroy it and makes the next hole active if any." (defvar hole-map (let ((map (make-sparse-keymap))) - (cond - ((featurep 'xemacs) - (define-key map [(button1)] 'holes-mouse-set-active-hole) - (define-key map [(button3)] 'holes-mouse-destroy-hole) - (define-key map [(button2)] 'holes-mouse-forget-hole)) - (t - (define-key map [(mouse-1)] 'holes-mouse-set-active-hole) - (define-key map [(mouse-3)] 'holes-mouse-destroy-hole) - (define-key map [(mouse-2)] 'holes-mouse-forget-hole))) + (define-key map [(mouse-1)] 'holes-mouse-set-active-hole) + (define-key map [(mouse-3)] 'holes-mouse-destroy-hole) + (define-key map [(mouse-2)] 'holes-mouse-forget-hole) map) "Keymap to use on the holes's overlays. This keymap is used only when @@ -842,6 +826,7 @@ created. Return the number of holes created." +;;;###autoload (defun holes-abbrev-complete () "Complete abbrev by putting holes and indenting. Moves point at beginning of expanded text. Put this function as @@ -850,7 +835,7 @@ become holes." (holes-replace-string-by-holes-backward-jump last-abbrev-location)) - +;;;###autoload (defun holes-insert-and-expand (s) "Insert S, expand it and replace #s and @{]s by holes." ;; insert the expansion of abbrev s, and replace #s by holes. It was |