# HG changeset patch # User Aidan Kehoe <kehoea@parhasard.net> # Date 1324636480 0 # Node ID cc1ec4c93a671cbec82c4db176461a026e23aaf7 # Parent b0d712bbc2a61e75a6fa5d587b87b5016bb8cf74 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. diff -r b0d712bbc2a6 -r cc1ec4c93a67 lisp/ChangeLog --- 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. diff -r b0d712bbc2a6 -r cc1ec4c93a67 lisp/select.el --- 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)