]> code.delx.au - gnu-emacs-elpa/commitdiff
Emacs 24.x compatibility
authorLeo Liu <sdl.web@gmail.com>
Thu, 17 Oct 2013 07:01:02 +0000 (15:01 +0800)
committerLeo Liu <sdl.web@gmail.com>
Thu, 17 Oct 2013 07:01:02 +0000 (15:01 +0800)
easy-kill.el

index 1728f41ff447df3b6e2b3d08b897f6bcdf2823ba..1d10ea9edb4f90eac57968d3e118a85b856aceff 100644 (file)
 (eval-when-compile (require 'cl))
 (require 'thingatpt)
 
+(eval-and-compile
+  (or (fboundp 'set-temporary-overlay-map) ; new in 24.3
+      (defun set-temporary-overlay-map (map &optional keep-pred)
+        (let* ((clearfunsym (make-symbol "clear-temporary-overlay-map"))
+               (overlaysym (make-symbol "t"))
+               (alist (list (cons overlaysym map)))
+               (clearfun
+                `(lambda ()
+                   (unless ,(cond ((null keep-pred) nil)
+                                  ((eq t keep-pred)
+                                   `(eq this-command
+                                        (lookup-key ',map
+                                                    (this-command-keys-vector))))
+                                  (t `(funcall ',keep-pred)))
+                     (set ',overlaysym nil) ;Just in case.
+                     (remove-hook 'pre-command-hook ',clearfunsym)
+                     (setq emulation-mode-map-alists
+                           (delq ',alist emulation-mode-map-alists))))))
+          (set overlaysym overlaysym)
+          (fset clearfunsym clearfun)
+          (add-hook 'pre-command-hook clearfunsym)
+          (push alist emulation-mode-map-alists)))))
+
 (defcustom easy-kill-alist
   '((?w . word)
     (?s . sexp)