emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] [PATCH 2/7] Fix X clipboard handling in emacs21


From: James TD Smith
Subject: [Orgmode] [PATCH 2/7] Fix X clipboard handling in emacs21
Date: Fri, 25 Jul 2008 00:46:13 +0100
User-agent: StGIT/0.14.2

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 903aa8c..c81a049 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,14 @@
 2008-07-25  James TD Smith  <address@hidden>
 
+       * 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 0ba1dcc..3447a06 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 2bbb20e..8399f3d 100644
--- a/lisp/org-remember.el
+++ b/lisp/org-remember.el
@@ -300,13 +300,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 7a5be1f..77a859b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6890,7 +6890,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))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]