From mboxrd@z Thu Jan 1 00:00:00 1970 From: James TD Smith Subject: [PATCH 2/9] Fix X clipboard handling in emacs21 Date: Sat, 20 Sep 2008 22:08:51 +0100 Message-ID: <20080920210851.19759.1786.stgit@nyarlathotep.internal.mohorovi.cc> References: <20080920210101.19759.15959.stgit@nyarlathotep.internal.mohorovi.cc> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kh9hI-00044r-4v for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:08:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kh9hG-00043C-Dk for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:08:55 -0400 Received: from [199.232.76.173] (port=60157 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kh9hG-000431-8Z for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:08:54 -0400 Received: from 81-86-40-42.dsl.pipex.com ([81.86.40.42]:58531 helo=yog-sothoth.mohorovi.cc) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kh9hF-00021q-9b for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:08:54 -0400 Received: from nyarlathotep.internal.mohorovi.cc (Debian-exim@nyarlathotep.internal.mohorovi.cc [10.0.0.5]) by yog-sothoth.mohorovi.cc (8.14.2/8.14.2) with ESMTP id m8KL8pks017648 for ; Sat, 20 Sep 2008 22:08:51 +0100 (BST) (envelope-from ahktenzero@mohorovi.cc) Received: from [127.0.0.1] (helo=nyarlathotep.internal.mohorovi.cc ident=ahktenzero) by nyarlathotep.internal.mohorovi.cc with esmtp (Exim 4.69) (envelope-from ) id 1Kh9hD-0005o9-GR for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 22:08:51 +0100 In-Reply-To: <20080920210101.19759.15959.stgit@nyarlathotep.internal.mohorovi.cc> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Add a new function to org-compat to fetch clipboard values in emacs21 and xemacs. Use this function to fetch the clipboard when x-selection-value is unavailable. --- lisp/ChangeLog | 9 +++++++++ lisp/org-compat.el | 13 ++++++++++++- lisp/org-remember.el | 12 ++++++------ lisp/org.el | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5eb535f..bcefdab 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,14 @@ 2008-09-20 James TD Smith + * org-compat.el (org-get-x-clipboard-compat): Add a compat + function for fetching the X clipboard on XEmacs and GNU Emacs 21. + + * org-remember.el (org-get-x-clipboard): Use the compat + function to get clipboard values when x-selection-value is + unavailable. Use substring-no-properties instead of + set-text-properties to remove text properties from the clipboard + value. + * lisp/org-clock.el (org-update-mode-line): Support limiting the modeline clock string, and display the full todo value in the tooltip. Set a local keymap so mouse-3 on the clock string goes to diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 1f38b52..24693c8 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -245,7 +245,18 @@ that can be added." (set-extent-property (car ext-inv-spec) 'invisible (cadr ext-inv-spec)))) (move-to-column column force))) - + +(defun org-get-x-clipboard-compat (value) + "Get the clipboard value on XEmacs or Emacs 21" + (cond (org-xemacs-p (org-no-warnings (get-selection-no-error value))) + ((fboundp 'x-get-selection) + (condition-case nil + (or (x-get-selection value 'UTF8_STRING) + (x-get-selection value 'COMPOUND_TEXT) + (x-get-selection value 'STRING) + (x-get-selection value 'TEXT)) + (error nil))))) + (provide 'org-compat) ;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe diff --git a/lisp/org-remember.el b/lisp/org-remember.el index e056123..c1828e6 100644 --- a/lisp/org-remember.el +++ b/lisp/org-remember.el @@ -301,13 +301,13 @@ RET at beg-of-buf -> Append to file as level 2 headline (cddr (assoc char templates))))) (defun org-get-x-clipboard (value) - "Get the value of the x clibboard, in a way that also works with XEmacs." + "Get the value of the x clibboard, in a way that works on XEmacs, and GNU +Emacs 21" (if (eq window-system 'x) - (let ((x (if org-xemacs-p - (org-no-warnings (get-selection-no-error value)) - (and (fboundp 'x-selection-value) - (x-selection-value value))))) - (and (> (length x) 0) (set-text-properties 0 (length x) nil x) x)))) + (let ((x ;;(if (fboundp 'x-selection-value) + ;; (x-selection-value value) + (org-get-x-clipboard-compat value)));) + (if x (substring-no-properties x))))) ;;;###autoload (defun org-remember-apply-template (&optional use-char skip-interactive) diff --git a/lisp/org.el b/lisp/org.el index 297a410..cdbe7bb 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7016,7 +7016,7 @@ If `org-make-link-description-function' is non-nil, this function will be called with the link target, and the result will be the default link description. -If the LINK-LOCATION parameter is non-nil, this value will be +If the `LINK-LOCATION' parameter is non-nil, this value will be used as the link location instead of reading one interactively." (interactive "P") (let* ((wcf (current-window-configuration))