Bind RET and TAB on images for better UX.
[gnus] / lisp / gnus-xmas.el
index 2f6f1bb..1e5fafb 100644 (file)
@@ -1,7 +1,7 @@
 ;;; gnus-xmas.el --- Gnus functions for XEmacs
 
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-;;   2005, 2006 Free Software Foundation, Inc.
+;;   2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
@@ -39,6 +39,7 @@
 (defvar menu-bar-mode (featurep 'menubar))
 (require 'messagexmas)
 (require 'wid-edit)
+(require 'gnus-util)
 
 (defgroup gnus-xmas nil
   "XEmacsoid support for Gnus"
@@ -173,18 +174,18 @@ displayed, no centering will be performed."
        (i 32))
     ;; Nix out all the control chars...
     (while (>= (setq i (1- i)) 0)
-      (aset table i [??]))
+      (gnus-put-display-table i [??] table))
     ;; ... but not newline and cr, of course.  (cr is necessary for the
     ;; selective display).
-    (aset table ?\n nil)
-    (aset table ?\r nil)
+    (gnus-put-display-table ?\n nil table)
+    (gnus-put-display-table ?\r nil table)
     ;; We keep TAB as well.
-    (aset table ?\t nil)
+    (gnus-put-display-table ?\t nil table)
     ;; We nix out any glyphs over 126 below ctl-arrow.
     (let ((i (if (integerp ctl-arrow) ctl-arrow 160)))
       (while (>= (setq i (1- i)) 127)
-       (unless (aref table i)
-         (aset table i [??]))))
+       (unless (gnus-get-display-table i table)
+         (gnus-put-display-table i [??] table))))
     ;; Can't use `set-specifier' because of a bug in 19.14 and earlier
     (add-spec-to-specifier current-display-table table (current-buffer) nil)))
 
@@ -223,6 +224,10 @@ call it with the value of the `gnus-data' text property."
                 (delete-extent extent)
                 nil)))
 
+(defun gnus-xmas-overlays-in (beg end)
+  "Return a list of the extents that overlap the region BEG ... END."
+  (mapcar-extents #'identity nil nil beg end))
+
 (defun gnus-xmas-window-top-edge (&optional window)
   (nth 1 (window-pixel-edges window)))
 
@@ -336,7 +341,7 @@ call it with the value of the `gnus-data' text property."
 (defun gnus-xmas-read-event-char (&optional prompt)
   "Get the next event."
   (when prompt
-    (message "%s" prompt))
+    (display-message 'no-log (format "%s" prompt)))
   (let ((event (next-command-event)))
     (sit-for 0)
     ;; We junk all non-key events.  Is this naughty?
@@ -357,10 +362,17 @@ then we display only bindings that start with that prefix."
   (let ((keymap (copy-keymap gnus-article-mode-map))
        (map (copy-keymap gnus-article-send-map))
        (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
-       agent draft)
+       parent agent draft)
     (define-key keymap "S" map)
     (set-keymap-default-binding map nil)
     (with-current-buffer gnus-article-current-summary
+      (set-keymap-parent
+       keymap
+       (if (setq parent (keymap-parent gnus-article-mode-map))
+          (prog1
+              (setq parent (copy-keymap parent))
+            (set-keymap-parent parent (current-local-map)))
+        (current-local-map)))
       (let ((def (key-binding "S"))
            gnus-pick-mode)
        (set-keymap-parent map (if (symbolp def)
@@ -409,11 +421,13 @@ FRONT-ADVANCE and REAR-ADVANCE are ignored."
       (make-extent beg end buffer)))
 
   (defalias 'gnus-delete-overlay 'delete-extent)
+  (defalias 'gnus-overlay-get 'extent-property)
   (defalias 'gnus-overlay-put 'set-extent-property)
   (defalias 'gnus-move-overlay 'gnus-xmas-move-overlay)
   (defalias 'gnus-overlay-buffer 'extent-object)
   (defalias 'gnus-overlay-start 'extent-start-position)
   (defalias 'gnus-overlay-end 'extent-end-position)
+  (defalias 'gnus-overlays-in 'gnus-xmas-overlays-in)
   (defalias 'gnus-kill-all-overlays 'gnus-xmas-kill-all-overlays)
   (defalias 'gnus-extent-detached-p 'extent-detached-p)
   (defalias 'gnus-add-text-properties 'gnus-xmas-add-text-properties)
@@ -902,8 +916,6 @@ XEmacs compatibility workaround."
                  (list
                   (cons 'x
                         (expand-file-name pixmap gnus-xmas-glyph-directory))
-                  (cons 'mswindows
-                        (expand-file-name pixmap gnus-xmas-glyph-directory))
                   (cons 'tty substring)))))
      (setq gnus-group-icon-cache
           (cons (cons pixmap glyph) gnus-group-icon-cache))
@@ -921,9 +933,12 @@ XEmacs compatibility workaround."
        (featurep (if (eq type 'pbm) 'xbm type))))
 
 (defun gnus-xmas-create-image (file &optional type data-p &rest props)
-  (let ((type (if type
-                 (symbol-name type)
-               (car (last (split-string file "[.]")))))
+  (let ((type (cond
+              (type
+               (symbol-name type))
+              ((and (not data-p)
+                    (string-match "[.]" file))
+               (car (last (split-string file "[.]"))))))
        (face (plist-get props :face))
        glyph)
     (when (equal type "pbm")
@@ -945,8 +960,9 @@ XEmacs compatibility workaround."
                (insert-file-contents-literally file))
              (make-glyph
               (vector
-               (or (intern type)
-                   (mm-image-type-from-buffer))
+               (if type
+                   (intern type)
+                 (mm-image-type-from-buffer))
                :data (buffer-string))))))
     (when face
       (set-glyph-face glyph face))
@@ -988,5 +1004,4 @@ Warning: Don't insert text immediately after the image."
 
 (provide 'gnus-xmas)
 
-;;; arch-tag: 4e84de3f-ea0a-4ee3-bfeb-e03d46fcacef
 ;;; gnus-xmas.el ends here