 
 (require 'popup)
 (require 'pos-tip)
-;; for `return' macro
+
 (eval-when-compile
-  (require 'cl))
+  (require 'cl-lib))
 
 
 ;;; Variables:
 
-(defconst popup-kill-ring-version "0.2.8"
+(defgroup popup-kill-ring nil
+  "interactively insert item from kill-ring"
+  :group  'convenience
+  :prefix "popup-kill-ring-")
+
+
+(defconst popup-kill-ring-version "0.2.11"
   "Version of `popup-kill-ring'")
 
 
-(defvar popup-kill-ring-popup-width 30
-  "*Width of popup item.")
-
-(defvar popup-kill-ring-popup-margin-left 2
-  "*Width of `popup-menu*' margin-left.")
-
-(defvar popup-kill-ring-popup-margin-right 2
-  "*Width of `popup-menu*' margin-right.")
-
-(defvar popup-kill-ring-timeout 1
-  "*Time of displaying `pos-tip-show' help tooltip.")
-
-(defvar popup-kill-ring-kill-ring-show-func 'popup-kill-ring-pos-tip-show
-  "*Function of displaying the contents of `kill-ring'.
+(defcustom popup-kill-ring-popup-width 30
+  "Width of popup item."
+  :type  'integer
+  :group 'popup-kill-ring)
+
+(defcustom popup-kill-ring-popup-margin-left 2
+  "Width of `popup-menu*' margin-left."
+  :type 'integer
+  :group 'popup-kill-ring)
+
+(defcustom popup-kill-ring-popup-margin-right 2
+  "Width of `popup-menu*' margin-right."
+  :type 'integer
+  :group 'popup-kill-ring)
+
+(defcustom popup-kill-ring-timeout 1
+  "Time of displaying `pos-tip-show' help tooltip."
+  :type 'integer
+  :group 'popup-kill-ring)
+
+(defcustom popup-kill-ring-kill-ring-show-func 'popup-kill-ring-pos-tip-show
+  "Function of displaying the contents of `kill-ring'.
 This function requires two arguments `str' and `pos'.
 `str' is string of displaying. `pos' is point of displaying.
-Default value is `popup-kill-ring-pos-tip-show'.")
-
-(defvar popup-kill-ring-pos-tip-color nil
-  "*Face for `pos-tip-show'.
-See docstring of `pos-tip-show'.")
-
-(defvar popup-kill-ring-interactive-insert nil
-  "*Non-nil means that insert selected item of `popup-menu*' interactively.")
-
-(defvar popup-kill-ring-isearch t
-  "*Non-nil means that passes `t' to `isearch' option of `popup-menu*'")
-
-(defvar popup-kill-ring-item-min-width 3
-  "*The number that shows minimum width of displaying `kill-ring' item
-of `popup-menu*'")
-
-(defvar popup-kill-ring-item-size-max nil
-  "*The number that means max each item size of `popup-menu'.
+Default value is `popup-kill-ring-pos-tip-show'."
+  :type 'function
+  :group 'popup-kill-ring)
+
+(defcustom popup-kill-ring-pos-tip-color nil
+  "Face for `pos-tip-show'.
+See docstring of `pos-tip-show'."
+  :type 'face
+  :group 'popup-kill-ring)
+
+(defcustom popup-kill-ring-interactive-insert nil
+  "Non-nil means that insert selected item of `popup-menu*' interactively."
+  :type 'boolean
+  :group 'popup-kill-ring)
+
+(defcustom popup-kill-ring-isearch t
+  "Non-nil means that passes `t' to `isearch' option of `popup-menu*'"
+  :type 'boolean
+  :group 'popup-kill-ring)
+
+(defcustom popup-kill-ring-item-min-width 3
+  "The number that shows minimum width of displaying `kill-ring' item
+of `popup-menu*'"
+  :type 'integer
+  :group 'popup-kill-ring)
+
+(defcustom popup-kill-ring-item-size-max nil
+  "The number that means max each item size of `popup-menu'.
 If item size is longer than this number, it's truncated.
-Nil means that item does not be truncate.")
-
-(defvar popup-kill-ring-interactive-insert-face 'highlight
-  "*The face for interactively inserted string when
-`popup-kill-ring-interactive-insert' is `t'.")
-
-(defvar popup-kill-ring-last-used-move-first t
-  "*Non-nil means that last selected `kill-ring' item comes first of
-`kill-ring'.")
+Nil means that item does not be truncate."
+  :type 'integer
+  :group 'popup-kill-ring)
+
+(defcustom popup-kill-ring-interactive-insert-face 'highlight
+  "The face for interactively inserted string when
+`popup-kill-ring-interactive-insert' is `t'."
+  :type 'face
+  :group 'popup-kill-ring)
+
+(defcustom popup-kill-ring-last-used-move-first t
+  "Non-nil means that last selected `kill-ring' item comes first of
+`kill-ring'."
+  :type 'boolean
+  :group 'popup-kill-ring)
 
 ;; key setting for `popup-menu*'.
 (defvar popup-kill-ring-keymap
   (let ((keymap (make-sparse-keymap)))
     (set-keymap-parent keymap popup-menu-keymap)
-    (define-key keymap "\r" 'popup-kill-ring-select)
-    (define-key keymap "\C-n" 'popup-kill-ring-next)
-    (define-key keymap "\C-p" 'popup-kill-ring-previous)
-    (define-key keymap [down] 'popup-kill-ring-next)
-    (define-key keymap [up] 'popup-kill-ring-previous)
-    (define-key keymap "\C-f" 'popup-kill-ring-current)
-    (define-key keymap "\C-b" 'popup-kill-ring-hide)
-    (define-key keymap [right] 'popup-kill-ring-current)
-    (define-key keymap [left] 'popup-kill-ring-hide)
+    (define-key keymap (kbd "RET")     'popup-kill-ring-select)
+    (define-key keymap (kbd "C-n")     'popup-kill-ring-next)
+    (define-key keymap (kbd "C-p")     'popup-kill-ring-previous)
+    (define-key keymap (kbd "<down>")  'popup-kill-ring-next)
+    (define-key keymap (kbd "<up>")    'popup-kill-ring-previous)
+    (define-key keymap (kbd "C-f")     'popup-kill-ring-current)
+    (define-key keymap (kbd "C-b")     'popup-kill-ring-hide)
+    (define-key keymap (kbd "<right>") 'popup-kill-ring-current)
+    (define-key keymap (kbd "<left>")  'popup-kill-ring-hide)
     keymap)
     "A keymap for `popup-menu*' of `popup-kill-ring'.")
 

;;; popup-kill-ring.el --- interactively insert item from kill-ring

;; Copyright (C) 2010  khiker

;; Author: khiker <khiker.mail+elisp@gmail.com>
;; Keywords: popup, kill-ring, pos-tip
;; Package-Requires: ((pos-tip "0.4.5") (popup "0.5"))

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by

        ;; item of `popup-menu*' from inserted string to `current-buffer'.
        (unless (string= (buffer-substring (car p) (cdr p)) item)
          (delete-region (car p) (cdr p))
          (cl-return item)))
      (cl-return))
    (cl-return item)))

(defun popup-kill-ring-next ()
  (interactive)
