annotate src/select.c @ 5353:38e24b8be4ea

Improve the lexical scoping in #'block, #'return-from. lisp/ChangeLog addition: 2011-02-07 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el: * bytecomp.el (byte-compile-initial-macro-environment): Shadow `block', `return-from' here, we implement them differently when byte-compiling. * bytecomp.el (byte-compile-active-blocks): New. * bytecomp.el (byte-compile-block-1): New. * bytecomp.el (byte-compile-return-from-1): New. * bytecomp.el (return-from-1): New. * bytecomp.el (block-1): New. These are two aliases that exist to have their own associated byte-compile functions, which functions implement `block' and `return-from'. * cl-extra.el (cl-macroexpand-all): Fix a bug here when macros in the environment have been compiled. * cl-macs.el (block): * cl-macs.el (return): * cl-macs.el (return-from): Be more careful about lexical scope in these macros. * cl.el: * cl.el ('cl-block-wrapper): Removed. * cl.el ('cl-block-throw): Removed. These aren't needed in code generated by this XEmacs. They shouldn't be needed in code generated by XEmacs 21.4, but if it turns out the packages do need them, we can put them back. 2011-01-30 Mike Sperber <mike@xemacs.org> * font-lock.el (font-lock-fontify-pending-extents): Don't fail if `font-lock-mode' is unset, which can happen in the middle of `revert-buffer'. 2011-01-23 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (delete): * cl-macs.el (delq): * cl-macs.el (remove): * cl-macs.el (remq): Don't use the compiler macro if these functions were given the wrong number of arguments, as happens in lisp-tests.el. * cl-seq.el (remove, remq): Removed. I added these to subr.el, and forgot to remove them from here. 2011-01-22 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-setq, byte-compile-set): Remove kludge allowing keywords' values to be set, all the code that does that is gone. * cl-compat.el (elt-satisfies-test-p): * faces.el (set-face-parent): * faces.el (face-doc-string): * gtk-font-menu.el: * gtk-font-menu.el (gtk-reset-device-font-menus): * msw-font-menu.el: * msw-font-menu.el (mswindows-reset-device-font-menus): * package-get.el (package-get-installedp): * select.el (select-convert-from-image-data): * sound.el: * sound.el (load-sound-file): * x-font-menu.el (x-reset-device-font-menus-core): Don't quote keywords, they're self-quoting, and the win from backward-compatibility is sufficiently small now that the style problem overrides it. 2011-01-22 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (block, return-from): Require that NAME be a symbol in these macros, as always documented in the #'block docstring and as required by Common Lisp. * descr-text.el (unidata-initialize-unihan-database): Correct the use of non-symbols in #'block and #'return-from in this function. 2011-01-15 Aidan Kehoe <kehoea@parhasard.net> * cl-extra.el (concatenate): Accept more complicated TYPEs in this function, handing the sequences over to #'coerce if we don't understand them here. * cl-macs.el (inline): Don't proclaim #'concatenate as inline, its compiler macro is more useful than doing that. 2011-01-11 Aidan Kehoe <kehoea@parhasard.net> * subr.el (delete, delq, remove, remq): Move #'remove, #'remq here, they don't belong in cl-seq.el; move #'delete, #'delq here from fns.c, implement them in terms of #'delete*, allowing support for sequences generally. * update-elc.el (do-autoload-commands): Use #'delete*, not #'delq here, now the latter's no longer dumped. * cl-macs.el (delete, delq): Add compiler macros transforming #'delete and #'delq to #'delete* calls. 2011-01-10 Aidan Kehoe <kehoea@parhasard.net> * dialog.el (make-dialog-box): Correct a misplaced parenthesis here, thank you Mats Lidell in 87zkr9gqrh.fsf@mail.contactor.se ! 2011-01-02 Aidan Kehoe <kehoea@parhasard.net> * dialog.el (make-dialog-box): * list-mode.el (display-completion-list): These functions used to use cl-parsing-keywords; change them to use defun* instead, fixing the build. (Not sure what led to me not including this change in d1b17a33450b!) 2011-01-02 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (define-star-compiler-macros): Make sure the form has ITEM and LIST specified before attempting to change to calls with explicit tests; necessary for some tests in lisp-tests.el to compile correctly. (stable-union, stable-intersection): Add compiler macros for these functions, in the same way we do for most of the other functions in cl-seq.el. 2011-01-01 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (dolist, dotimes, do-symbols, macrolet) (symbol-macrolet): Define these macros with defmacro* instead of parsing the argument list by hand, for the sake of style and readability; use backquote where appropriate, instead of calling #'list and and friends, for the same reason. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * x-misc.el (device-x-display): Provide this function, documented in the Lispref for years, but not existing previously. Thank you Julian Bradfield, thank you Jeff Mincy. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * cl-seq.el: Move the heavy lifting from this file to C. Dump the cl-parsing-keywords macro, but don't use defun* for the functions we define that do take keywords, dynamic scope lossage makes that not practical. * subr.el (sort, fillarray): Move these aliases here. (map-plist): #'nsublis is now built-in, but at this point #'eql isn't necessarily available as a test; use #'eq. * obsolete.el (cl-delete-duplicates): Make this available for old compiler macros and old code. (memql): Document that this is equivalent to #'member*, and worse. * cl.el (adjoin, subst): Removed. These are in C. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * simple.el (assoc-ignore-case): Remove a duplicate definition of this function (it's already in subr.el). * iso8859-1.el (char-width): On non-Mule, make this function equivalent to that produced by (constantly 1), but preserve its docstring. * subr.el (subst-char-in-string): Define this in terms of #'substitute, #'nsubstitute. (string-width): Define this using #'reduce and #'char-width. (char-width): Give this a simpler definition, it makes far more sense to check for mule at load time and redefine, as we do in iso8859-1.el. (store-substring): Implement this in terms of #'replace, now #'replace is cheap. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * update-elc.el (lisp-files-needed-for-byte-compilation) (lisp-files-needing-early-byte-compilation): cl-macs belongs in the former, not the latter, it is as fundamental as bytecomp.el. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * cl.el: Provde the Common Lisp program-error, type-error as error symbols. This doesn't nearly go far enough for anyone using the Common Lisp errors. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (delete-duplicates): If the form has an incorrect number of arguments, don't attempt a compiler macroexpansion. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (cl-safe-expr-p): Forms that start with the symbol lambda are also safe. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (= < > <= >=): For these functions' compiler macros, the optimisation is safe even if the first and the last arguments have side effects, since they're only used the once. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (inline-side-effect-free-compiler-macros): Unroll a loop here at macro-expansion time, so these compiler macros are compiled. Use #'eql instead of #'eq in a couple of places for better style. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-extra.el (notany, notevery): Avoid some dynamic scope stupidity with local variable names in these functions, when they weren't prefixed with cl-; go into some more detail in the doc strings. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * byte-optimize.el (side-effect-free-fns): #'remove, #'remq are free of side-effects. (side-effect-and-error-free-fns): Drop dot, dot-marker from the list. 2010-11-17 Aidan Kehoe <kehoea@parhasard.net> * cl-extra.el (coerce): In the argument list, name the first argument OBJECT, not X; the former name was always used in the doc string and is clearer. Handle vector type specifications which include the length of the target sequence, error if there's a mismatch. * cl-macs.el (cl-make-type-test): Handle type specifications starting with the symbol 'eql. 2010-11-14 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (eql): Don't remove the byte-compile property of this symbol. That was necessary to override a bug in bytecomp.el where #'eql was confused with #'eq, which bug we no longer have. If neither expression is constant, don't attempt to handle the expression in this compiler macro, leave it to byte-compile-eql, which produces better code anyway. * bytecomp.el (eq): #'eql is not the function associated with the byte-eq byte code. (byte-compile-eql): Add an explicit compile method for this function, for cases where the cl-macs compiler macro hasn't reduced it to #'eq or #'equal. 2010-10-25 Aidan Kehoe <kehoea@parhasard.net> Add compiler macros and compilation sanity-checking for various functions that take keywords. * byte-optimize.el (side-effect-free-fns): #'symbol-value is side-effect free and not error free. * bytecomp.el (byte-compile-normal-call): Check keyword argument lists for sanity; store information about the positions where keyword arguments start using the new byte-compile-keyword-start property. * cl-macs.el (cl-const-expr-val): Take a new optional argument, cl-not-constant, defaulting to nil, in this function; return it if the expression is not constant. (cl-non-fixnum-number-p): Make this into a separate function, we want to pass it to #'every. (eql): Use it. (define-star-compiler-macros): Use the same code to generate the member*, assoc* and rassoc* compiler macros; special-case some code in #'add-to-list in subr.el. (remove, remq): Add compiler macros for these two functions, in preparation for #'remove being in C. (define-foo-if-compiler-macros): Transform (remove-if-not ...) calls to (remove ... :if-not) at compile time, which will be a real win once the latter is in C. (define-substitute-if-compiler-macros) (define-subst-if-compiler-macros): Similarly for these functions. (delete-duplicates): Change this compiler macro to use #'plists-equal; if we don't have information about the type of SEQUENCE at compile time, don't bother attempting to inline the call, the function will be in C soon enough. (equalp): Remove an old commented-out compiler macro for this, if we want to see it it's in version control. (subst-char-in-string): Transform this to a call to nsubstitute or nsubstitute, if that is appropriate. * cl.el (ldiff): Don't call setf here, this makes for a load-time dependency problem in cl-macs.el 2010-06-14 Stephen J. Turnbull <stephen@xemacs.org> * term/vt100.el: Refer to XEmacs, not GNU Emacs, in permissions. * term/bg-mouse.el: * term/sup-mouse.el: Put copyright notice in canonical "Copyright DATE AUTHOR" form. Refer to XEmacs, not GNU Emacs, in permissions. * site-load.el: Add permission boilerplate. * mule/canna-leim.el: * alist.el: Refer to XEmacs, not APEL/this program, in permissions. * mule/canna-leim.el: Remove my copyright, I've assigned it to the FSF. 2010-06-14 Stephen J. Turnbull <stephen@xemacs.org> * gtk.el: * gtk-widget-accessors.el: * gtk-package.el: * gtk-marshal.el: * gtk-compose.el: * gnome.el: Add copyright notice based on internal evidence. 2010-06-14 Stephen J. Turnbull <stephen@xemacs.org> * easymenu.el: Add reference to COPYING to permission notice. * gutter.el: * gutter-items.el: * menubar-items.el: Fix typo "Xmacs" in permissions notice. 2010-06-14 Stephen J. Turnbull <stephen@xemacs.org> * auto-save.el: * font.el: * fontconfig.el: * mule/kinsoku.el: Add "part of XEmacs" text to permission notice. 2010-10-14 Aidan Kehoe <kehoea@parhasard.net> * byte-optimize.el (side-effect-free-fns): * cl-macs.el (remf, getf): * cl-extra.el (tailp, cl-set-getf, cl-do-remf): * cl.el (ldiff, endp): Tighten up Common Lisp compatibility for #'ldiff, #'endp, #'tailp; add circularity checking for the first two. #'cl-set-getf and #'cl-do-remf were Lisp implementations of #'plist-put and #'plist-remprop; change the names to aliases, changes the macros that use them to using #'plist-put and #'plist-remprop directly. 2010-10-12 Aidan Kehoe <kehoea@parhasard.net> * abbrev.el (fundamental-mode-abbrev-table, global-abbrev-table): Create both these abbrev tables using the usual #'define-abbrev-table calls, rather than attempting to special-case them. * cl-extra.el: Force cl-macs to be loaded here, if cl-extra.el is being loaded interpreted. Previously other, later files would redundantly call (load "cl-macs") when interpreted, it's more reasonable to do it here, once. * cmdloop.el (read-quoted-char-radix): Use defcustom here, we don't have any dump-order dependencies that would prevent that. * custom.el (eval-when-compile): Don't load cl-macs when interpreted or when byte-compiling, rely on cl-extra.el in the former case and the appropriate entry in bytecomp-load-hook in the latter. Get rid of custom-declare-variable-list, we have no dump-time dependencies that would require it. * faces.el (eval-when-compile): Don't load cl-macs when interpreted or when byte-compiling. * packages.el: Remove some inaccurate comments. * post-gc.el (cleanup-simple-finalizers): Use #'delete-if-not here, now the order of preloaded-file-list has been changed to make it available. * subr.el (custom-declare-variable-list): Remove. No need for it. Also remove a stub define-abbrev-table from this file, given the current order of preloaded-file-list there's no need for it. 2010-10-10 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-constp) Forms quoted with FUNCTION are also constant. (byte-compile-initial-macro-environment): In #'the, if FORM is constant and does not match TYPE, warn at byte-compile time. 2010-10-10 Aidan Kehoe <kehoea@parhasard.net> * backquote.el (bq-vector-contents, bq-list*): Remove; the former is equivalent to (append VECTOR nil), the latter to (list* ...). (bq-process-2): Use (append VECTOR nil) instead of using #'bq-vector-contents to convert to a list. (bq-process-1): Now we use list* instead of bq-list * subr.el (list*): Moved from cl.el, since it is now required to be available the first time a backquoted form is encountered. * cl.el (list*): Move to subr.el. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * test-harness.el (Check-Message): Add an omitted comma here, thank you the buildbot. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * hash-table.el (hash-table-key-list, hash-table-value-list) (hash-table-key-value-alist, hash-table-key-value-plist): Remove some useless #'nreverse calls in these files; our hash tables have no order, it's not helpful to pretend they do. * behavior.el (read-behavior): Do the same in this file, in some code evidently copied from hash-table.el. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * info.el (Info-insert-dir): * format.el (format-deannotate-region): * files.el (cd, save-buffers-kill-emacs): Use #'some, #'every and related functions for applying boolean operations to lists, instead of rolling our own ones that cons and don't short-circuit. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-initial-macro-environment): * cl-macs.el (the): Rephrase the docstring, make its implementation when compiling files a little nicer. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * descr-text.el (unidata-initialize-unicodedata-database) (unidata-initialize-unihan-database, describe-char-unicode-data) (describe-char-unicode-data): Wrap calls to the database functions with (with-fboundp ...), avoiding byte compile warnings on builds without support for the database functions. (describe-char): (reduce #'max ...), not (apply #'max ...), no need to cons needlessly. (describe-char): Remove a redundant lambda wrapping #'extent-properties. (describe-char-unicode-data): Call #'nsubst when replacing "" with nil in the result of #'split-string, instead of consing inside mapcar. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * x-faces.el (x-available-font-sizes): * specifier.el (let-specifier): * package-ui.el (pui-add-required-packages): * msw-faces.el (mswindows-available-font-sizes): * modeline.el (modeline-minor-mode-menu): * minibuf.el (minibuf-directory-files): Replace the O2N (delq nil (mapcar (lambda (W) (and X Y)) Z)) with the ON (mapcan (lambda (W) (and X (list Y))) Z) in these files. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (= < > <= >=): When these functions are handed more than two arguments, and those arguments have no side effects, transform to a series of two argument calls, avoiding funcall in the byte-compiled code. * mule/mule-cmds.el (finish-set-language-environment): Take advantage of this change in a function called 256 times at startup. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-function-form, byte-compile-quote) (byte-compile-quote-form): Warn at compile time, and error at runtime, if a (quote ...) or a (function ...) form attempts to quote more than one object. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * byte-optimize.el (byte-optimize-apply): Transform (apply 'nconc (mapcar ...)) to (mapcan ...); warn about use of the first idiom. * update-elc.el (do-autoload-commands): * packages.el (packages-find-package-library-path): * frame.el (frame-list): * extents.el (extent-descendants): * etags.el (buffer-tag-table-files): * dumped-lisp.el (preloaded-file-list): * device.el (device-list): * bytecomp-runtime.el (proclaim-inline, proclaim-notinline) Use #'mapcan, not (apply #'nconc (mapcar ...) in all these files. * bytecomp-runtime.el (eval-when-compile, eval-and-compile): In passing, mention that these macros also evaluate the body when interpreted. tests/ChangeLog addition: 2011-02-07 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: Test lexical scope for `block', `return-from'; add a Known-Bug-Expect-Failure for a contorted example that fails when byte-compiled.
author Aidan Kehoe <kehoea@parhasard.net>
date Mon, 07 Feb 2011 12:01:24 +0000
parents 8608eadee6ba
children a9094f28f9a9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
1 /* Generic selection processing for XEmacs
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
2 Copyright (C) 1999 Free Software Foundation, Inc.
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
3 Copyright (C) 1999 Andy Piper.
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
4
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
5 This file is part of XEmacs.
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
6
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
10 later version.
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
11
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
15 for more details.
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
16
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
21
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
22 /* Synched up with: Not synched with FSF. */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
23
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
24 #include <config.h>
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
25 #include "lisp.h"
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
26
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
27 #include "buffer.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 843
diff changeset
28 #include "device-impl.h"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
29 #include "extents.h"
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
30 #include "console.h"
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
31 #include "fontcolor.h"
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
32
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
33 #include "frame.h"
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
34 #include "opaque.h"
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
35 #include "select.h"
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
36
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
37 /* X Atoms */
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
38 Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP,
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
39 QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL,
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
40 QATOM_PAIR, QCOMPOUND_TEXT;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
41
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
42 /* Windows clipboard formats */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
43 Lisp_Object QCF_TEXT, QCF_BITMAP, QCF_METAFILEPICT, QCF_SYLK, QCF_DIF,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
44 QCF_TIFF, QCF_OEMTEXT, QCF_DIB, QCF_DIBV5, QCF_PALETTE, QCF_PENDATA,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
45 QCF_RIFF, QCF_WAVE, QCF_UNICODETEXT, QCF_ENHMETAFILE, QCF_HDROP, QCF_LOCALE,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
46 QCF_OWNERDISPLAY, QCF_DSPTEXT, QCF_DSPBITMAP, QCF_DSPMETAFILEPICT,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
47 QCF_DSPENHMETAFILE;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
48
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
49 /* Selection strategy symbols */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
50 Lisp_Object Qreplace_all, Qreplace_existing;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
51
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
52 /* "Selection owner couldn't convert selection" */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
53 Lisp_Object Qselection_conversion_error;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
54
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
55 /* A couple of Lisp functions */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
56 Lisp_Object Qselect_convert_in, Qselect_convert_out, Qselect_coerce;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
57
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
58 /* These are alists whose CARs are selection-types (whose names are the same
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
59 as the names of X Atoms or Windows clipboard formats) and whose CDRs are
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
60 the names of Lisp functions to call to convert the given Emacs selection
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
61 value to a string representing the given selection type. This is for
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
62 elisp-level extension of the emacs selection handling.
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
63 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
64 Lisp_Object Vselection_converter_out_alist;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
65 Lisp_Object Vselection_converter_in_alist;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
66 Lisp_Object Vselection_coercion_alist;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
67 Lisp_Object Vselection_appender_alist;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
68 Lisp_Object Vselection_buffer_killed_alist;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
69 Lisp_Object Vselection_coercible_types;
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
70
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
71 Lisp_Object Vlost_selection_hooks;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
72
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
73 /* This is an association list whose elements are of the form
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
74 ( selection-name selection-value selection-timestamp )
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
75 selection-name is a lisp symbol, whose name is the name of an X Atom.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
76 selection-value is a list of cons pairs that emacs owns for that selection.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
77 Each pair consists of (type . value), where type is nil or a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
78 selection data type, and value is any type of Lisp object.
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
79 selection-timestamp is the time at which emacs began owning this selection,
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
80 as a cons of two 16-bit numbers (making a 32 bit time).
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
81 If there is an entry in this alist, then it can be assumed that emacs owns
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
82 that selection.
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
83 The only (eq) parts of this list that are visible from elisp are the
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
84 selection-values.
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
85 */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
86 Lisp_Object Vselection_alist;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
87
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
88 /* Given a selection-name and desired type, this looks up our local copy of
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
89 the selection value and converts it to the type. */
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
90 static Lisp_Object
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
91 get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type)
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
92 {
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
93 Lisp_Object local_value = assq_no_quit (selection_symbol, Vselection_alist);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
94
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
95 if (!NILP (local_value))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
96 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
97 Lisp_Object value_list = XCAR (XCDR (local_value));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
98 Lisp_Object value;
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
99
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
100 /* First try to find an entry of the appropriate type */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
101 value = assq_no_quit (target_type, value_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
102
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
103 if (!NILP (value))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
104 return XCDR (value);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
105 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
106
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
107 return Qnil;
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
108 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
109
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2757
diff changeset
110 /* #### Should perhaps handle `MULTIPLE'. The code below is now completely
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
111 broken due to a re-organization of get_local_selection, but I've left
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
112 it here should anyone show an interest - ajh */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
113 #if 0
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
114 else if (CONSP (target_type) &&
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
115 XCAR (target_type) == QMULTIPLE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
116 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
117 Lisp_Object pairs = XCDR (target_type);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
118 int len = XVECTOR_LENGTH (pairs);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
119 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
120 /* If the target is MULTIPLE, then target_type looks like
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
121 (MULTIPLE . [[SELECTION1 TARGET1] [SELECTION2 TARGET2] ... ])
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
122 We modify the second element of each pair in the vector and
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
123 return it as [[SELECTION1 <value1>] [SELECTION2 <value2>] ... ]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
124 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
125 for (i = 0; i < len; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
126 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
127 Lisp_Object pair = XVECTOR_DATA (pairs) [i];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
128 XVECTOR_DATA (pair) [1] =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
129 x_get_local_selection (XVECTOR_DATA (pair) [0],
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
130 XVECTOR_DATA (pair) [1]);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
131 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
132 return pairs;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
133 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
134 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
135
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
136 DEFUN ("own-selection-internal", Fown_selection_internal, 2, 5, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
137 Give the selection SELECTION-NAME the value SELECTION-VALUE.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
138 SELECTION-NAME is a symbol, typically PRIMARY, SECONDARY, or CLIPBOARD.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
139 SELECTION-VALUE is typically a string, or a cons of two markers, but may be
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
140 anything that the functions on selection-converter-out-alist know about.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
141 Optional arg HOW-TO-ADD specifies how the selection will be combined
843
f46864126a0d [xemacs-hg @ 2002-05-15 15:27:40 by stephent]
stephent
parents: 829
diff changeset
142 with any existing selection(s) - see `own-selection' for more
f46864126a0d [xemacs-hg @ 2002-05-15 15:27:40 by stephent]
stephent
parents: 829
diff changeset
143 information.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
144 Optional arg DATA-TYPE is a window-system-specific type.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
145 Optional arg DEVICE specifies the device on which to assert the selection.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
146 It defaults to the selected device.
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
147 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
148 (selection_name, selection_value, how_to_add, data_type, device))
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
149 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
150 Lisp_Object selection_time, selection_data, prev_value = Qnil,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
151 value_list = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
152 Lisp_Object prev_real_value = Qnil;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 414
diff changeset
153 struct gcpro gcpro1;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
154 int owned_p = 0;
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
155
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
156 CHECK_SYMBOL (selection_name);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
157 if (NILP (selection_value))
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
158 invalid_argument ("`selection-value' may not be nil", Qunbound);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
159
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
160 if (NILP (device))
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
161 device = Fselected_device (Qnil);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
162
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
163 if (!EQ (how_to_add, Qappend) && !EQ (how_to_add, Qt)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
164 && !EQ (how_to_add, Qreplace_existing)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
165 && !EQ (how_to_add, Qreplace_all) && !NILP (how_to_add))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
166 invalid_constant ("`how-to-add' must be nil, append, replace_all, "
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
167 "replace_existing or t", how_to_add);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
168
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
169 #ifdef MULE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
170 if (NILP (data_type))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
171 data_type = QCOMPOUND_TEXT;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
172 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
173 if (NILP (data_type))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
174 data_type = QSTRING;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
175 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
176
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
177 /* Examine the how-to-add argument */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
178 if (EQ (how_to_add, Qreplace_all) || NILP (how_to_add))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
179 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
180 Lisp_Object local_selection_data = assq_no_quit (selection_name,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
181 Vselection_alist);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
182
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
183 if (!NILP (local_selection_data))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
184 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
185 owned_p = 1;
5338
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
186 Vselection_alist
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
187 = delq_no_quit (local_selection_data, Vselection_alist);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
188 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
189 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
190 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
191 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
192 /* Look for a previous value */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
193 prev_value = assq_no_quit (selection_name, Vselection_alist);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
194
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
195 if (!NILP (prev_value))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
196 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
197 owned_p = 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
198 value_list = XCAR (XCDR (prev_value));
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
199 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 414
diff changeset
200
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
201 if (!NILP (value_list))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
202 prev_real_value = assq_no_quit (data_type, value_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
203 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
204
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
205 /* Append values if necessary */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
206 if (!NILP (value_list) && (EQ (how_to_add, Qappend) || EQ (how_to_add, Qt)))
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
207 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
208 /* Did we have anything of this type previously? */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
209 if (!NILP (prev_real_value))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
210 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
211 if ((NILP (data_type) && STRINGP (selection_value)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
212 && STRINGP (XCDR (prev_real_value)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
213 || !NILP (data_type))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
214 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
215 Lisp_Object function = assq_no_quit (data_type,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
216 Vselection_appender_alist);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
217
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
218 if (NILP (function))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
219 signal_error (Qinvalid_argument,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
220 "Cannot append selections of supplied types (no function)",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
221 data_type);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
222
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
223 function = XCDR (function);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
224
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
225 selection_value = call4 (function,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
226 selection_name,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
227 data_type,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
228 XCDR (prev_real_value),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
229 selection_value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
230
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
231 if (NILP (selection_value))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
232 signal_error (Qinvalid_argument,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
233 "Cannot append selections of supplied types (function returned nil)",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
234 data_type);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
235 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
236 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
237 signal_error_2 (Qinvalid_argument, "Cannot append selections of supplied types (data type nil and both values not strings)",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
238 XCDR (prev_real_value),
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
239 selection_value);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
240 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
241
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
242 selection_data = Fcons (data_type, selection_value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
243 value_list = Fcons (selection_data, value_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
244 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
245
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
246 if (!NILP (prev_real_value))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
247 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
248 Lisp_Object rest; /* We know it isn't the CAR, so it's easy. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
249
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
250 /* Delete the old type entry from the list */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
251 for (rest = value_list; !NILP (rest); rest = Fcdr (rest))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
252 if (EQ (prev_real_value, Fcar (XCDR (rest))))
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
253 {
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
254 XCDR (rest) = Fcdr (XCDR (rest));
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
255 break;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
256 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
257 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
258 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
259 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
260 value_list = Fcons (Fcons (data_type, selection_value),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
261 value_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
262 }
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
263
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
264 /* Complete the local cache update; note that we destructively
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
265 modify the current list entry if there is one */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
266 if (NILP (prev_value))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
267 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
268 selection_data = list3 (selection_name, value_list, Qnil);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
269 Vselection_alist = Fcons (selection_data, Vselection_alist);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
270 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
271 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
272 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
273 selection_data = prev_value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
274 Fsetcar (XCDR (selection_data), value_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
275 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
276
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
277 GCPRO1 (selection_data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
278
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
279 /* have to do device specific stuff last so that methods can access the
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
280 selection_alist */
2620
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
281
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
282 /* If you are re-implementing this for another redisplay type, either make
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
283 certain that the selection time will fit within thirty-two bits, or
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
284 redesign get-xemacs-selection-timestamp to return, say, a bignum, and
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
285 convert the device-specific timestamp to a bignum before storing it in
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
286 this list. The current practice is to blindly assume that the timestamp
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
287 is thirty-two bits, which will work for extant architectures. */
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
288
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
289 if (HAS_DEVMETH_P (XDEVICE (device), own_selection))
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
290 selection_time = DEVMETH (XDEVICE (device), own_selection,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
291 (selection_name, selection_value,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 456
diff changeset
292 how_to_add, data_type, owned_p));
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
293 else
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
294 selection_time = Qnil;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
295
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
296 Fsetcar (XCDR (XCDR (selection_data)), selection_time);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
297
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 414
diff changeset
298 UNGCPRO;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 414
diff changeset
299
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
300 return selection_value;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
301 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
302
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
303 DEFUN ("register-selection-data-type", Fregister_selection_data_type, 1,2,0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
304 Register a new selection data type DATA-TYPE, optionally on the specified
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
305 DEVICE. Returns the device-specific data type identifier, or nil if the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
306 device does not support this feature or the registration fails. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
307 (data_type, device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
308 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
309 /* Check arguments */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
310 CHECK_STRING (data_type);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
311
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
312 if (NILP (device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
313 device = Fselected_device (Qnil);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
314
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
315 if (HAS_DEVMETH_P (XDEVICE (device), register_selection_data_type))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
316 return DEVMETH (XDEVICE (device), register_selection_data_type,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
317 (data_type));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
318 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
319 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
320 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
321
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
322 DEFUN ("selection-data-type-name", Fselection_data_type_name, 1, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
323 Retrieve the name of the specified selection data type DATA-TYPE, optionally
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
324 on the specified DEVICE. Returns either a string or a symbol on success, and
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
325 nil if the device does not support this feature or the type is not known. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
326 (data_type, device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
327 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
328 if (NILP (device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
329 device = Fselected_device (Qnil);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
330
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
331 if (HAS_DEVMETH_P (XDEVICE (device), selection_data_type_name))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
332 return DEVMETH (XDEVICE (device), selection_data_type_name, (data_type));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
333 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
334 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
335 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
336
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
337 DEFUN ("available-selection-types", Favailable_selection_types, 1, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
338 Retrieve a list of currently available types of selection associated with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
339 the given SELECTION-NAME, optionally on the specified DEVICE. This list
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
340 does not take into account any possible conversions that might take place,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
341 so it should be taken as a minimal estimate of what is available.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
342 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
343 (selection_name, device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
344 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
345 Lisp_Object types = Qnil, rest;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
346 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
347
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
348 CHECK_SYMBOL (selection_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
349
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
350 if (NILP (device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
351 device = Fselected_device (Qnil);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
352
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
353 GCPRO1 (types);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
354
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
355 /* First check the device */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
356 if (HAS_DEVMETH_P (XDEVICE (device), available_selection_types))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
357 types = DEVMETH (XDEVICE (device), available_selection_types,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
358 (selection_name));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
359
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
360 /* Now look in the list */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
361 rest = assq_no_quit (selection_name, Vselection_alist);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
362
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
363 if (NILP (rest))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
364 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
365 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
366
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
367 return types;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
368 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
369
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
370 /* Examine the types and cons them onto the front of the list */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
371 for (rest = XCAR (XCDR (rest)); !NILP (rest); rest = XCDR (rest))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
372 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
373 Lisp_Object value = XCDR (XCAR (rest));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
374 Lisp_Object type = XCAR (XCAR (rest));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
375
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
376 types = Fcons (type, types);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
377
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
378 if ((STRINGP (value) || EXTENTP (value))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
379 && (NILP (type) || EQ (type, QSTRING)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
380 || EQ (type, QTEXT) || EQ (type, QCOMPOUND_TEXT)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
381 types = Fcons (QTEXT, Fcons (QCOMPOUND_TEXT, Fcons (QSTRING, types)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
382 else if (INTP (value) && NILP (type))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
383 types = Fcons (QINTEGER, types);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
384 else if (SYMBOLP (value) && NILP (type))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
385 types = Fcons (QATOM, types);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
386 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
387
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
388 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
389
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
390 return types;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
391 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
392
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
393 /* remove a selection from our local copy
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
394 */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
395 void
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
396 handle_selection_clear (Lisp_Object selection_symbol)
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
397 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
398 Lisp_Object local_selection_data = assq_no_quit (selection_symbol,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
399 Vselection_alist);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
400
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
401 /* Well, we already believe that we don't own it, so that's just fine. */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
402 if (NILP (local_selection_data)) return;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
403
5338
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
404 /* Otherwise, we're really honest and truly being told to drop it. */
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
405 Vselection_alist = delq_no_quit (local_selection_data, Vselection_alist);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
406
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
407 /* Let random lisp code notice that the selection has been stolen.
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
408 */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
409 {
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
410 Lisp_Object rest;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
411 Lisp_Object val = Vlost_selection_hooks;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
412 if (!UNBOUNDP (val) && !NILP (val))
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
413 {
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
414 if (CONSP (val) && !EQ (XCAR (val), Qlambda))
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
415 for (rest = val; !NILP (rest); rest = Fcdr (rest))
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
416 call1 (Fcar (rest), selection_symbol);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
417 else
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
418 call1 (val, selection_symbol);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
419 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
420 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
421 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
422
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
423 DEFUN ("disown-selection-internal", Fdisown_selection_internal, 1, 3, 0, /*
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
424 If we own the named selection, then disown it (make there be no selection).
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
425 */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
426 (selection_name, selection_time, device))
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
427 {
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
428 if (NILP (assq_no_quit (selection_name, Vselection_alist)))
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
429 return Qnil; /* Don't disown the selection when we're not the owner. */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
430
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
431 if (NILP (device))
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
432 device = Fselected_device (Qnil);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
433
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
434 MAYBE_DEVMETH (XDEVICE (device), disown_selection,
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
435 (selection_name, selection_time));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
436
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
437 handle_selection_clear (selection_name);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
438
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
439 return Qt;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
440 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
441
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
442 DEFUN ("selection-owner-p", Fselection_owner_p, 0, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
443 Return t if the current emacs process owns SELECTION.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
444 SELECTION should be the name of the selection in question, typically one of
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
445 the symbols PRIMARY, SECONDARY, or CLIPBOARD. (For convenience, the symbol
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
446 nil is the same as PRIMARY, and t is the same as SECONDARY.)
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
447 */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
448 (selection))
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
449 {
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
450 CHECK_SYMBOL (selection);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
451 if (EQ (selection, Qnil)) selection = QPRIMARY;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
452 else if (EQ (selection, Qt)) selection = QSECONDARY;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
453
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
454 return NILP (Fassq (selection, Vselection_alist)) ? Qnil : Qt;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
455 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
456
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
457 DEFUN ("selection-exists-p", Fselection_exists_p, 0, 3, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
458 Whether there is currently an owner for SELECTION.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
459 SELECTION should be the name of the selection in question, typically one of
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
460 the symbols PRIMARY, SECONDARY, or CLIPBOARD. (For convenience, the symbol
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
461 nil is the same as PRIMARY, and t is the same as SECONDARY.)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
462 Optionally, the window-system DATA-TYPE and the DEVICE may be specified.
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
463 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
464 (selection, data_type, device))
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
465 {
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
466 CHECK_SYMBOL (selection);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
467 if (NILP (data_type)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
468 && !NILP (Fselection_owner_p (selection)))
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
469 return Qt;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
470
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
471 if (NILP (device))
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
472 device = Fselected_device (Qnil);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
473
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
474 return HAS_DEVMETH_P (XDEVICE (device), selection_exists_p) ?
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
475 DEVMETH (XDEVICE (device), selection_exists_p, (selection, data_type))
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
476 : Qnil;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
477 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
478
2620
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
479 Lisp_Object
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
480 get_selection_raw_time(Lisp_Object selection)
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
481 {
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
482 Lisp_Object local_value = assq_no_quit (selection, Vselection_alist);
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
483
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
484 if (!NILP (local_value))
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
485 {
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
486 return XCAR (XCDR (XCDR (local_value)));
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
487 }
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
488 return Qnil;
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
489 }
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
490
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
491 /* Get the timestamp of the given selection */
2620
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
492 DEFUN ("get-xemacs-selection-timestamp", Fget_selection_timestamp, 1, 1, 0, /*
2757
7844ab77b582 [xemacs-hg @ 2005-05-05 17:10:19 by aidan]
aidan
parents: 2620
diff changeset
493 Return timestamp for SELECTION, if it belongs to XEmacs and exists.
2620
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
494
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
495 The timestamp is a cons of two integers, the first being the higher-order
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
496 sixteen bits of the device-specific thirty-two-bit quantity, the second
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
497 being the lower-order sixteen bits of same. Expect to see this API change
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
498 when and if redisplay on a window system with timestamps wider than 32bits
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
499 happens.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
500 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
501 (selection))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
502 {
2620
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
503 Lisp_Object val = get_selection_raw_time(selection);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
504
2620
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
505 if (!NILP (val))
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
506 {
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
507 return word_to_lisp(* (UINT_32_BIT *) XOPAQUE_DATA (val));
5e906dd5c3e9 [xemacs-hg @ 2005-02-28 20:21:43 by aidan]
aidan
parents: 872
diff changeset
508 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
509
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
510 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
511 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
512
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
513 /* Request the selection value from the owner. If we are the owner,
843
f46864126a0d [xemacs-hg @ 2002-05-15 15:27:40 by stephent]
stephent
parents: 829
diff changeset
514 simply return our selection value. If we are not the owner, this
f46864126a0d [xemacs-hg @ 2002-05-15 15:27:40 by stephent]
stephent
parents: 829
diff changeset
515 will block until all of the data has arrived.
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
516 */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
517 DEFUN ("get-selection-internal", Fget_selection_internal, 2, 3, 0, /*
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
518 Return text selected from some window-system window.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
519 SELECTION is a symbol, typically PRIMARY, SECONDARY, or CLIPBOARD.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
520 TARGET-TYPE is the type of data desired, typically STRING or COMPOUND_TEXT.
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
521 Under Mule, if the resultant data comes back as 8-bit data in type
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
522 TEXT or COMPOUND_TEXT, it will be decoded as Compound Text.
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
523 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
524 (selection, target_type, device))
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
525 {
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
526 /* This function can GC */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
527 Lisp_Object val = Qnil;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
528 struct gcpro gcpro1, gcpro2;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
529 GCPRO2 (target_type, val);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
530 CHECK_SYMBOL (selection);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
531
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
532 if (NILP (device))
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
533 device = Fselected_device (Qnil);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
534
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
535 #ifdef MULE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
536 if (NILP (target_type))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
537 target_type = QCOMPOUND_TEXT;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
538 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
539 if (NILP (target_type))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
540 target_type = QSTRING;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
541 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
542
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
543 #if 0 /* #### MULTIPLE doesn't work yet and probably never will */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
544 if (CONSP (target_type) &&
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
545 XCAR (target_type) == QMULTIPLE)
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
546 {
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
547 CHECK_VECTOR (XCDR (target_type));
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
548 /* So we don't destructively modify this... */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
549 target_type = copy_multiple_data (target_type);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
550 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
551 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
552
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
553 /* Used to check that target_type was a symbol. This is no longer
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
554 necessarily the case, because the type might be registered with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
555 the device (in which case target_type would be a device-specific
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
556 identifier - probably an integer) - ajh */
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
557
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
558 val = get_local_selection (selection, target_type);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
559
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
560 if (!NILP (val))
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
561 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
562 /* If we get something from the local cache, we may need to convert
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
563 it slightly - to do this, we call select-coerce */
843
f46864126a0d [xemacs-hg @ 2002-05-15 15:27:40 by stephent]
stephent
parents: 829
diff changeset
564 val = call3 (Qselect_coerce, selection, target_type, val);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
565 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
566 else if (HAS_DEVMETH_P (XDEVICE (device), get_foreign_selection))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
567 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
568 /* Nothing in the local cache; try the window system */
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
569 val = DEVMETH (XDEVICE (device), get_foreign_selection,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
570 (selection, target_type));
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
571 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
572
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
573 if (NILP (val))
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
574 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
575 /* Still nothing. Try coercion. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
576
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
577 /* Try looking in selection-coercible-types to see if any of
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
578 them are present for this selection. We try them *in order*;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
579 the first for which a conversion succeeds gets returned. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
580 EXTERNAL_LIST_LOOP_2 (element, Vselection_coercible_types)
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
581 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
582 val = get_local_selection (selection, element);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
583
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
584 if (NILP (val))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
585 continue;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
586
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
587 val = call3 (Qselect_coerce, selection, target_type, val);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
588
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
589 if (!NILP (val))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
590 break;
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
591 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
592 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
593
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
594 /* Used to call clean_local_selection here... but that really belonged
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
595 in Lisp (so the equivalent is now built-in to the INTEGER conversion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
596 function select-convert-from-integer) - ajh */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
597
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
598 UNGCPRO;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
599 return val;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
600 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
601
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
602 /* These are convenient interfaces to the lisp code in select.el;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
603 this way we can rename them easily rather than having to hunt everywhere.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
604 Also, this gives us access to get_local_selection so that convert_out
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
605 can retrieve the internal selection value automatically if passed a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
606 value of Qnil. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
607 Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
608 select_convert_in (Lisp_Object selection,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
609 Lisp_Object type,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
610 Lisp_Object value)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
611 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
612 return call3 (Qselect_convert_in, selection, type, value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
613 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
614
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
615 Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
616 select_coerce (Lisp_Object selection,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
617 Lisp_Object type,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
618 Lisp_Object value)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
619 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
620 return call3 (Qselect_coerce, selection, type, value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
621 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
622
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
623 Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
624 select_convert_out (Lisp_Object selection,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
625 Lisp_Object type,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
626 Lisp_Object value)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
627 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
628 if (NILP (value))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
629 value = get_local_selection (selection, type);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
630
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
631 if (NILP (value))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
632 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
633 /* Try looking in selection-coercible-types to see if any of
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
634 them are present for this selection. We try them *in order*;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
635 the first for which a conversion succeeds gets returned. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
636 EXTERNAL_LIST_LOOP_2 (element, Vselection_coercible_types)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
637 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
638 Lisp_Object ret;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
639
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
640 value = get_local_selection (selection, element);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
641
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
642 if (NILP (value))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
643 continue;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
644
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
645 ret = call3 (Qselect_convert_out, selection, type, value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
646
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
647 if (!NILP (ret))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
648 return ret;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
649 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
650
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
651 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
652 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
653
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
654 return call3 (Qselect_convert_out, selection, type, value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
655 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
656
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
657
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
658 /* Gets called from kill-buffer; this lets us dispose of buffer-dependent
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
659 selections (or alternatively make them independent of the buffer) when
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
660 it gets vaped. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
661 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
662 select_notify_buffer_kill (Lisp_Object buffer)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
663 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
664 Lisp_Object rest;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
665 struct gcpro gcpro1, gcpro2, gcpro3;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
666
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
667 /* For each element of Vselection_alist */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
668 for (rest = Vselection_alist;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
669 !NILP (rest);)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
670 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
671 Lisp_Object selection, values, prev = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
672
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
673 selection = XCAR (rest);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
674
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
675 for (values = XCAR (XCDR (selection));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
676 !NILP (values);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
677 values = XCDR (values))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
678 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
679 Lisp_Object value, handler_fn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
680
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
681 /* Extract the (type . value) pair. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
682 value = XCAR (values);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
683
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
684 /* Find the handler function (if any). */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
685 handler_fn = Fcdr (Fassq (XCAR (value),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
686 Vselection_buffer_killed_alist));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
687
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
688 if (!NILP (handler_fn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
689 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
690 Lisp_Object newval;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
691
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
692 /* Protect ourselves, just in case some tomfool calls
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
693 own-selection from with the buffer-killed handler, then
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
694 causes a GC. Just as a note, *don't do this*. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
695 GCPRO3 (rest, values, value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
696
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
697 newval = call4 (handler_fn, XCAR (selection), XCAR (value),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
698 XCDR (value), buffer);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
699
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
700 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
701
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
702 /* Set or delete the value (by destructively modifying
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
703 the list). */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
704 if (!NILP (newval))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
705 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
706 Fsetcdr (value, newval);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
707
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
708 prev = values;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
709 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
710 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
711 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
712 if (NILP (prev))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
713 Fsetcar (XCDR (selection), XCDR (values));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
714 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
715 Fsetcdr (prev, XCDR (values));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
716 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
717 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
718 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
719 prev = values;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
720 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
721
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
722 /* If we have no values for this selection */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
723 if (NILP (XCAR (XCDR (selection))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
724 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
725 /* Move on to the next element *first* */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
726 rest = XCDR (rest);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
727
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
728 /* Protect it and disown this selection */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
729 GCPRO1 (rest);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
730
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
731 Fdisown_selection_internal (XCAR (selection), Qnil, Qnil);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
732
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
733 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
734 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
735 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
736 rest = XCDR (rest);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
737 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
738 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
739
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
740
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
741 void
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
742 syms_of_select (void)
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
743 {
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
744 DEFSUBR (Fown_selection_internal);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
745 DEFSUBR (Fget_selection_internal);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
746 DEFSUBR (Fget_selection_timestamp);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
747 DEFSUBR (Fselection_exists_p);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
748 DEFSUBR (Fdisown_selection_internal);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
749 DEFSUBR (Fselection_owner_p);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
750 DEFSUBR (Favailable_selection_types);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
751 DEFSUBR (Fregister_selection_data_type);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
752 DEFSUBR (Fselection_data_type_name);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
753
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
754 /* Lisp Functions */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
755 DEFSYMBOL (Qselect_convert_in);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
756 DEFSYMBOL (Qselect_convert_out);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
757 DEFSYMBOL (Qselect_coerce);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
758
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
759 /* X Atoms */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
760 DEFSYMBOL (QPRIMARY);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
761 DEFSYMBOL (QSECONDARY);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
762 DEFSYMBOL (QSTRING);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
763 DEFSYMBOL (QINTEGER);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
764 DEFSYMBOL (QCLIPBOARD);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
765 DEFSYMBOL (QTIMESTAMP);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
766 DEFSYMBOL (QTEXT);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
767 DEFSYMBOL (QDELETE);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
768 DEFSYMBOL (QMULTIPLE);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
769 DEFSYMBOL (QINCR);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
770 defsymbol (&QEMACS_TMP, "_EMACS_TMP_");
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
771 DEFSYMBOL (QTARGETS);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
772 DEFSYMBOL (QATOM);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
773 defsymbol (&QATOM_PAIR, "ATOM_PAIR");
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
774 defsymbol (&QCOMPOUND_TEXT, "COMPOUND_TEXT");
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
775 DEFSYMBOL (QNULL);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
776
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
777 /* Windows formats - these all start with CF_ */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
778 defsymbol (&QCF_TEXT, "CF_TEXT");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
779 defsymbol (&QCF_BITMAP, "CF_BITMAP");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
780 defsymbol (&QCF_METAFILEPICT, "CF_METAFILEPICT");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
781 defsymbol (&QCF_SYLK, "CF_SYLK");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
782 defsymbol (&QCF_DIF, "CF_DIF");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
783 defsymbol (&QCF_TIFF, "CF_TIFF");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
784 defsymbol (&QCF_OEMTEXT, "CF_OEMTEXT");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
785 defsymbol (&QCF_DIB, "CF_DIB");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
786 defsymbol (&QCF_DIBV5, "CF_DIBV5");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
787 defsymbol (&QCF_PALETTE, "CF_PALETTE");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
788 defsymbol (&QCF_PENDATA, "CF_PENDATA");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
789 defsymbol (&QCF_RIFF, "CF_RIFF");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
790 defsymbol (&QCF_WAVE, "CF_WAVE");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
791 defsymbol (&QCF_UNICODETEXT, "CF_UNICODETEXT");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
792 defsymbol (&QCF_ENHMETAFILE, "CF_ENHMETAFILE");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
793 defsymbol (&QCF_HDROP, "CF_HDROP");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
794 defsymbol (&QCF_LOCALE, "CF_LOCALE");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
795 defsymbol (&QCF_OWNERDISPLAY, "CF_OWNERDISPLAY");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
796 defsymbol (&QCF_DSPTEXT, "CF_DSPTEXT");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
797 defsymbol (&QCF_DSPBITMAP, "CF_DSPBITMAP");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
798 defsymbol (&QCF_DSPMETAFILEPICT, "CF_DSPMETAFILEPICT");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
799 defsymbol (&QCF_DSPENHMETAFILE, "CF_DSPENHMETAFILE");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
800
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
801 /* Selection strategies */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
802 DEFSYMBOL (Qreplace_all);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
803 DEFSYMBOL (Qreplace_existing);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
804
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 458
diff changeset
805 DEFERROR_STANDARD (Qselection_conversion_error, Qconversion_error);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
806 }
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
807
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
808 void
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
809 vars_of_select (void)
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
810 {
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
811 Vselection_alist = Qnil;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
812 staticpro (&Vselection_alist);
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
813
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
814 DEFVAR_LISP ("selection-converter-alist", &Vselection_converter_out_alist /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
815 An alist associating selection-types (such as STRING and TIMESTAMP) with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
816 functions. This is an alias for `selection-converter-out-alist', and should
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
817 be considered obsolete. Use the new name instead. */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
818
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
819 DEFVAR_LISP ("selection-converter-out-alist",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
820 &Vselection_converter_out_alist /*
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
821 An alist associating selection-types (such as STRING and TIMESTAMP) with
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
822 functions. These functions will be called with three args: the name
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
823 of the selection (typically PRIMARY, SECONDARY, or CLIPBOARD); a
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
824 desired type to which the selection should be converted; and the local
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
825 selection value (whatever had been passed to `own-selection').
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
826
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
827 The return type of these functions depends upon the device in question;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
828 for mswindows, a string should be returned containing data in the requested
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
829 format, or nil to indicate that the conversion could not be done. Additionally,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
830 it is permissible to return a cons of the form (DATA-TYPE . STRING) suggesting
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
831 a new data type to use instead.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
832
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
833 For X, the return value should be one of:
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
834
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
835 -- nil (the conversion could not be done)
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
836 -- a cons of a symbol and any of the following values; the symbol
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
837 explicitly specifies the type that will be sent.
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
838 -- a string (If the type is not specified, then if Mule support exists,
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
839 the string will be converted to Compound Text and sent in
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2757
diff changeset
840 the `COMPOUND_TEXT' format; otherwise (no Mule support),
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2757
diff changeset
841 the string will be left as-is and sent in the `STRING'
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
842 format. If the type is specified, the string will be
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
843 left as-is (or converted to binary format under Mule).
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
844 In all cases, 8-bit data it sent.)
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
845 -- a character (With Mule support, will be converted to Compound Text
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
846 whether or not a type is specified. If a type is not
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2757
diff changeset
847 specified, a type of `STRING' or `COMPOUND_TEXT' will be
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
848 sent, as for strings.)
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2757
diff changeset
849 -- the symbol `NULL' (Indicates that there is no meaningful return value.
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2757
diff changeset
850 Empty 32-bit data with a type of `NULL' will be sent.)
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
851 -- a symbol (Will be converted into an atom. If the type is not specified,
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2757
diff changeset
852 a type of `ATOM' will be sent.)
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
853 -- an integer (Will be converted into a 16-bit or 32-bit integer depending
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
854 on the value. If the type is not specified, a type of
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2757
diff changeset
855 `INTEGER' will be sent.)
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
856 -- a cons (HIGH . LOW) of integers (Will be converted into a 32-bit integer.
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
857 If the type is not specified, a type of
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2757
diff changeset
858 `INTEGER' will be sent.)
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
859 -- a vector of symbols (Will be converted into a list of atoms. If the type
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2757
diff changeset
860 is not specified, a type of `ATOM' will be sent.)
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
861 -- a vector of integers (Will be converted into a list of 16-bit integers.
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2757
diff changeset
862 If the type is not specified, a type of `INTEGER'
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
863 will be sent.)
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
864 -- a vector of integers and/or conses (HIGH . LOW) of integers
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
865 (Will be converted into a list of 16-bit integers.
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2757
diff changeset
866 If the type is not specified, a type of `INTEGER'
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
867 will be sent.)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
868 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
869 Vselection_converter_out_alist = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
870
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
871 DEFVAR_LISP ("selection-converter-in-alist",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
872 &Vselection_converter_in_alist /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
873 An alist associating selection-types (such as STRING and TIMESTAMP) with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
874 functions. These functions will be called with three args: the name
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
875 of the selection (typically PRIMARY, SECONDARY or CLIPBOARD); the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
876 type from which the selection should be converted; and the selection
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
877 value. These functions should return a suitable representation of the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
878 value, or nil to indicate that the conversion was not possible.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
879
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
880 See also `selection-converter-out-alist'. */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
881 Vselection_converter_in_alist = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
882
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
883 DEFVAR_LISP ("selection-coercion-alist",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
884 &Vselection_coercion_alist /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
885 An alist associating selection-types (such as STRING and TIMESTAMP) with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
886 functions. These functions will be called with three args; the name
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
887 of the selection (typically PRIMARY, SECONDARY or CLIPBOARD); the type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
888 from which the selection should be converted, and the selection value.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
889 The value passed will be *exactly the same value* that was given to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
890 `own-selection'; it should be converted into something suitable for
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
891 return to a program calling `get-selection' with the appropriate
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
892 parameters.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
893
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
894 See also `selection-converter-in-alist' and
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
895 `selection-converter-out-alist'. */);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
896 Vselection_coercion_alist = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
897
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
898 DEFVAR_LISP ("selection-appender-alist",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
899 &Vselection_appender_alist /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
900 An alist associating selection-types (such as STRING and TIMESTAMP) with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
901 functions. These functions will be called with four args; the name
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
902 of the selection (typically PRIMARY, SECONDARY or CLIPBOARD); the type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
903 of the selection; and two selection values. The functions are expected to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
904 return a value representing the catenation of the two values, or nil to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
905 indicate that this was not possible. */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
906 Vselection_appender_alist = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
907
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
908 DEFVAR_LISP ("selection-buffer-killed-alist",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
909 &Vselection_buffer_killed_alist /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
910 An alist associating selection-types (such as STRING and TIMESTAMP) with
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
911 functions. These functions will be called whenever a buffer is killed,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
912 with four args: the name of the selection (typically PRIMARY, SECONDARY
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
913 or CLIPBOARD); the type of the selection; the value of the selection; and
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
914 the buffer that has just been killed. These functions should return a new
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
915 selection value, or nil to indicate that the selection value should be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
916 deleted. */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
917 Vselection_buffer_killed_alist = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
918
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
919 DEFVAR_LISP ("selection-coercible-types",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
920 &Vselection_coercible_types /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
921 A list of selection types that are coercible---that is, types that may be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
922 automatically converted to another type. Selection values with types in this
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
923 list may be subject to conversion attempts to other types. */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
924 Vselection_coercible_types = Qnil;
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
925
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
926 DEFVAR_LISP ("lost-selection-hooks", &Vlost_selection_hooks /*
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
927 A function or functions to be called after we have been notified
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
928 that we have lost the selection. The function(s) will be called with one
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
929 argument, a symbol naming the selection (typically PRIMARY, SECONDARY, or
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
930 CLIPBOARD).
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
931 */ );
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
932 Vlost_selection_hooks = Qunbound;
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents:
diff changeset
933 }