Mercurial > hg > xemacs-beta
changeset 5618:cc1ec4c93a67
Improve Lisp style in a few places, select.el
lisp/ChangeLog addition:
2011-12-23 Aidan Kehoe <kehoea@parhasard.net>
* select.el (activate-region-as-selection):
* select.el (select-make-extent-for-selection):
* select.el (select-convert-in):
* select.el (select-convert-out):
* select.el (select-coerce):
* select.el (select-convert-to-targets):
Improve Lisp style in a few places here; don't re-implement
#'delete-duplicates, use #'funcall instead of consing up a list to
pass to #'apply.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Fri, 23 Dec 2011 10:34:40 +0000 |
parents | b0d712bbc2a6 |
children | 75ad4969a16d |
files | lisp/ChangeLog lisp/select.el |
diffstat | 2 files changed, 23 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Fri Dec 23 10:56:16 2011 +0100 +++ b/lisp/ChangeLog Fri Dec 23 10:34:40 2011 +0000 @@ -1,3 +1,15 @@ +2011-12-23 Aidan Kehoe <kehoea@parhasard.net> + + * select.el (activate-region-as-selection): + * select.el (select-make-extent-for-selection): + * select.el (select-convert-in): + * select.el (select-convert-out): + * select.el (select-coerce): + * select.el (select-convert-to-targets): + Improve Lisp style in a few places here; don't re-implement + #'delete-duplicates, use #'funcall instead of consing up a list to + pass to #'apply. + 2011-12-23 Didier Verna <didier@xemacs.org> * cl-macs.el (face-flush-p): New defsetf.
--- a/lisp/select.el Fri Dec 23 10:56:16 2011 +0100 +++ b/lisp/select.el Fri Dec 23 10:34:40 2011 +0000 @@ -256,9 +256,7 @@ primary selection." (disown-selection-internal (if secondary-p 'SECONDARY 'PRIMARY)) (when (and selection-sets-clipboard - (or (not secondary-p) - (eq secondary-p 'PRIMARY) - (eq secondary-p 'CLIPBOARD))) + (memq secondary-p '(nil PRIMARY CLIPBOARD))) (disown-selection-internal 'CLIPBOARD))) ;; selections and active regions @@ -428,29 +426,25 @@ "Attempt to convert the specified external VALUE to the specified DATA-TYPE, for the specified SELECTION. Return nil if this is impossible, or a suitable internal representation otherwise." - (when value - (let ((handler-fn (cdr (assq type selection-converter-in-alist)))) - (if handler-fn - (apply handler-fn (list selection type value)) - value)))) + (and value + (funcall (or (cdr (assq type selection-converter-in-alist)) #'ignore) + selection type value))) (defun select-convert-out (selection type value) "Attempt to convert the specified internal VALUE for the specified DATA-TYPE and SELECTION. Return nil if this is impossible, or a suitable external representation otherwise." - (when value - (let ((handler-fn (cdr (assq type selection-converter-out-alist)))) - (when handler-fn - (apply handler-fn (list selection type value)))))) + (and value + (funcall (or (cdr (assq type selection-converter-out-alist)) #'ignore) + selection type value))) (defun select-coerce (selection type value) "Attempt to convert the specified internal VALUE to a representation suitable for return from `get-selection' in the specified DATA-TYPE. Return nil if this is impossible, or a suitable representation otherwise." - (when value - (let ((handler-fn (cdr (assq type selection-coercion-alist)))) - (when handler-fn - (apply handler-fn (list selection type value)))))) + (and value + (funcall (or (cdr (assq type selection-conversion-alist)) #'ignore) + selection type value))) ;; The rest of the functions on this "page" are conversion handlers, ;; append handlers and buffer-kill handlers. @@ -550,14 +544,7 @@ (defun select-convert-to-targets (selection type value) ;; return a vector of atoms, but remove duplicates first. - (let* ((all (cons 'TIMESTAMP (mapcar 'car selection-converter-alist))) - (rest all)) - (while rest - (cond ((memq (car rest) (cdr rest)) - (setcdr rest (delq (car rest) (cdr rest)))) - (t - (setq rest (cdr rest))))) - (apply 'vector all))) + (delete-duplicates (map 'vector #'car selection-converter-out-alist))) (defun select-convert-to-delete (selection type value) (disown-selection-internal selection)