]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/tabulated-list.el
Fix variable-pitch font on MS-Windows
[gnu-emacs] / lisp / emacs-lisp / tabulated-list.el
index 4bf714baa18b28b365218499230acb05cc5dd875..00b029d8f3ee06a41c203185d77b575d19769836 100644 (file)
@@ -1,6 +1,6 @@
 ;;; tabulated-list.el --- generic major mode for tabulated lists -*- lexical-binding: t -*-
 
-;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
 
 ;; Author: Chong Yidong <cyd@stupidchicken.com>
 ;; Keywords: extensions, lisp
@@ -321,11 +321,11 @@ changing `tabulated-list-sort-key'."
         (sorter (tabulated-list--get-sorter))
        entry-id saved-pt saved-col window-line)
     (and remember-pos
+        (setq entry-id (tabulated-list-get-id))
+        (setq saved-col (current-column))
          (when (eq (window-buffer) (current-buffer))
            (setq window-line
-                 (count-screen-lines (window-start) (point))))
-        (setq entry-id (tabulated-list-get-id))
-        (setq saved-col (current-column)))
+                 (count-screen-lines (window-start) (point)))))
     ;; Sort the entries, if necessary.
     (when sorter
       (setq entries (sort entries sorter)))
@@ -356,10 +356,11 @@ changing `tabulated-list-sort-key'."
                           nil)
                          ;; If this entry sorts after id (or it's the
                          ;; end), then just insert id and move on.
-                         ((funcall sorter elt
-                                   ;; FIXME: Might be faster if
-                                   ;; don't construct this list.
-                                   (list local-id (tabulated-list-get-entry)))
+                         ((or (not local-id)
+                              (funcall sorter elt
+                                       ;; FIXME: Might be faster if
+                                       ;; don't construct this list.
+                                       (list local-id (tabulated-list-get-entry))))
                           (apply tabulated-list-printer elt)
                           nil)
                          ;; We find an entry that sorts before id,
@@ -519,7 +520,9 @@ With a numeric prefix argument N, sort the Nth column."
                  (car (aref tabulated-list-format n))
                (get-text-property (point)
                                   'tabulated-list-column-name))))
-    (tabulated-list--sort-by-column-name name)))
+    (if (nth 2 (assoc name (append tabulated-list-format nil)))
+        (tabulated-list--sort-by-column-name name)
+      (user-error "Cannot sort by %s" name))))
 
 (defun tabulated-list--sort-by-column-name (name)
   (when (and name (derived-mode-p 'tabulated-list-mode))
@@ -568,7 +571,6 @@ data in an ewoc may instead specify a printer function (e.g., one
 that calls `ewoc-enter-last'), with `tabulated-list-print-entry'
 as the ewoc pretty-printer."
   (setq-local truncate-lines t)
-  (setq-local buffer-read-only t)
   (setq-local buffer-undo-list t)
   (setq-local revert-buffer-function #'tabulated-list-revert)
   (setq-local glyphless-char-display tabulated-list-glyphless-char-display)
@@ -580,8 +582,4 @@ as the ewoc pretty-printer."
 
 (provide 'tabulated-list)
 
-;; Local Variables:
-;; coding: utf-8
-;; End:
-
 ;;; tabulated-list.el ends here