Mercurial > hg > xemacs-beta
comparison lisp/x11/x-select.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 376386a54a3c |
children | 8eaf7971accc |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | 13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 ;; General Public License for more details. | 15 ;; General Public License for more details. |
16 | 16 |
17 ;; You should have received a copy of the GNU General Public License | 17 ;; You should have received a copy of the GNU General Public License |
18 ;; along with XEmacs; see the file COPYING. If not, write to the Free | 18 ;; along with XEmacs; see the file COPYING. If not, write to the |
19 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 ;; Boston, MA 02111-1307, USA. | |
20 | 21 |
21 ;;; The selection code requires us to use certain symbols whose names are | 22 ;;; The selection code requires us to use certain symbols whose names are |
22 ;;; all upper-case; this may seem tasteless, but it makes there be a 1:1 | 23 ;;; all upper-case; this may seem tasteless, but it makes there be a 1:1 |
23 ;;; correspondence between these symbols and X Atoms (which are upcased). | 24 ;;; correspondence between these symbols and X Atoms (which are upcased). |
24 | 25 |
25 ;;; Synched up with: FSF 19.30 (select.el). | 26 ;;; Synched up with: FSF 19.30 (select.el). |
26 | 27 |
27 ;;; Code: | 28 ;;; Code: |
28 | 29 |
29 (defvar x-selected-text-type 'STRING | 30 (defvar x-selected-text-type |
31 (if (featurep 'mule) 'COMPOUND_TEXT 'STRING) | |
30 "The type atom used to obtain selections from the X server.") | 32 "The type atom used to obtain selections from the X server.") |
31 | 33 |
32 (defun x-get-selection (&optional type data-type) | 34 (defun x-get-selection (&optional type data-type) |
33 "Return the value of an X Windows selection. | 35 "Return the value of an X Windows selection. |
34 The argument TYPE (default `PRIMARY') says which selection, | 36 The argument TYPE (default `PRIMARY') says which selection, |
35 and the argument DATA-TYPE (default `STRING') says how to convert the data." | 37 and the argument DATA-TYPE (default `STRING', or `COMPOUND_TEXT' under Mule) |
38 says how to convert the data." | |
36 (or type (setq type 'PRIMARY)) | 39 (or type (setq type 'PRIMARY)) |
37 (or data-type (setq data-type x-selected-text-type)) | 40 (or data-type (setq data-type x-selected-text-type)) |
38 (let ((text (x-get-selection-internal type data-type))) | 41 (let ((text (x-get-selection-internal type data-type))) |
39 (if (and (consp text) (symbolp (car text))) | 42 (if (and (consp text) (symbolp (car text))) |
40 (setq text (cdr text))) | 43 (setq text (cdr text))) |
255 ;;; this function is called by kill-buffer as if it were on the | 258 ;;; this function is called by kill-buffer as if it were on the |
256 ;;; kill-buffer-hook (though it isn't really). | 259 ;;; kill-buffer-hook (though it isn't really). |
257 | 260 |
258 (defun xselect-kill-buffer-hook () | 261 (defun xselect-kill-buffer-hook () |
259 ;; Probably the right thing is to write a C function to return a list | 262 ;; Probably the right thing is to write a C function to return a list |
260 ;; of the selections which emacs owns, since it could concievably own | 263 ;; of the selections which emacs owns, since it could conceivably own |
261 ;; a user-defined selection type that we've never heard of. | 264 ;; a user-defined selection type that we've never heard of. |
262 (xselect-kill-buffer-hook-1 'PRIMARY) | 265 (xselect-kill-buffer-hook-1 'PRIMARY) |
263 (xselect-kill-buffer-hook-1 'SECONDARY) | 266 (xselect-kill-buffer-hook-1 'SECONDARY) |
264 (xselect-kill-buffer-hook-1 'CLIPBOARD)) | 267 (xselect-kill-buffer-hook-1 'CLIPBOARD)) |
265 | 268 |
419 ;; force the string to be not in Compound Text format. | 422 ;; force the string to be not in Compound Text format. |
420 (if (stringp outval) | 423 (if (stringp outval) |
421 (cons 'STRING outval) | 424 (cons 'STRING outval) |
422 outval))) | 425 outval))) |
423 | 426 |
427 (defun xselect-convert-to-compound-text (selection type value) | |
428 ;; converts to compound text automatically | |
429 (xselect-convert-to-text selection type value)) | |
430 | |
424 (defun xselect-convert-to-length (selection type value) | 431 (defun xselect-convert-to-length (selection type value) |
425 (let ((value | 432 (let ((value |
426 (cond ((stringp value) | 433 (cond ((stringp value) |
427 (length value)) | 434 (length value)) |
428 ((extentp value) | 435 ((extentp value) |
595 (vector value)) | 602 (vector value)) |
596 | 603 |
597 (setq selection-converter-alist | 604 (setq selection-converter-alist |
598 '((TEXT . xselect-convert-to-text) | 605 '((TEXT . xselect-convert-to-text) |
599 (STRING . xselect-convert-to-string) | 606 (STRING . xselect-convert-to-string) |
607 (COMPOUND_TEXT . xselect-convert-to-compound-text) | |
600 (TARGETS . xselect-convert-to-targets) | 608 (TARGETS . xselect-convert-to-targets) |
601 (LENGTH . xselect-convert-to-length) | 609 (LENGTH . xselect-convert-to-length) |
602 (DELETE . xselect-convert-to-delete) | 610 (DELETE . xselect-convert-to-delete) |
603 (FILE_NAME . xselect-convert-to-filename) | 611 (FILE_NAME . xselect-convert-to-filename) |
604 (CHARACTER_POSITION . xselect-convert-to-charpos) | 612 (CHARACTER_POSITION . xselect-convert-to-charpos) |