[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 208/255: support for viewing lists in a buffer
From: |
Eric Schulte |
Subject: |
[elpa] 208/255: support for viewing lists in a buffer |
Date: |
Sun, 16 Mar 2014 01:02:49 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 389a9b0b80ee3fbbc081692b95bf76718d2da689
Author: Eric Schulte <address@hidden>
Date: Tue Aug 6 00:33:56 2013 -0600
support for viewing lists in a buffer
---
list-buffer.el | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 74 insertions(+), 0 deletions(-)
diff --git a/list-buffer.el b/list-buffer.el
new file mode 100644
index 0000000..416fda5
--- /dev/null
+++ b/list-buffer.el
@@ -0,0 +1,74 @@
+;;; list-buffer.el --- view a list as a table in a buffer
+
+;; Copyright (C) 2013 Eric Schulte <address@hidden>
+
+;; Author: Eric Schulte <address@hidden>
+;; Created: 2013-08-02
+;; Version: 0.1
+;; Keywords: list buffer cl
+
+;; This file is not (yet) part of GNU Emacs.
+;; However, it is distributed under the same license.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Code:
+(eval-when-compile (require 'cl))
+
+(defvar *buffer-list* nil
+ "List associated with the current list buffer.")
+
+(defvar *buffer-headers* nil
+ "Headers associated with the current list buffer.")
+
+(defun list-buffer-create (buffer list &optional headers)
+ (pop-to-buffer buffer)
+ (set (make-local-variable '*buffer-list*) list)
+ (set (make-local-variable '*buffer-headers*) headers)
+ ;; set commands at the bottom
+ (list-buffer-refresh))
+
+(defun list-format-row (widths row)
+ (apply #'concat
+ (cl-mapcar
+ (lambda (width cell)
+ (if (< (length cell) width)
+ (concat cell (make-list (- width (length cell)) ?\ ))
+ (concat (subseq cell 0 (- width 4)) "... ")))
+ widths row)))
+
+(defun list-buffer-refresh ()
+ (let* ((strings (mapcar (lambda (row)
+ (mapcar (lambda (cell) (format "%s" cell)) row))
+ *buffer-list*))
+ (lengths (mapcar (lambda (row) (mapcar #'length row)) strings))
+ (widths (apply #'cl-mapcar #'max lengths)))
+ ;; write headers
+ (when *buffer-headers*
+ (set (make-local-variable 'header-line-format)
+ (list-format-row widths *buffer-headers*)))
+ ;; write rows
+ (delete (point-min) (point-max))
+ (insert (mapconcat (lambda (row) (list-format-row widths row))
+ strings "\n"))))
+
+(defun list-buffer-sort (key predicate)
+ (set *buffer-list* (cl-sort *buffer-list* predicate :key key)))
+
+(defun list-buffer-filter (key filter)
+ (set *buffer-list* (cl-remove-if-not *buffer-list* filter :key key)))
+
+(provide 'list-buffer)
- [elpa] 197/255: use new mark machinery to apply labels, (continued)
- [elpa] 197/255: use new mark machinery to apply labels, Eric Schulte, 2014/03/15
- [elpa] 195/255: query backend for territory, Eric Schulte, 2014/03/15
- [elpa] 201/255: print score after marking territory, Eric Schulte, 2014/03/15
- [elpa] 189/255: replace flet with cl-flet, Eric Schulte, 2014/03/15
- [elpa] 190/255: set level (mainly for playing GNUGO), Eric Schulte, 2014/03/15
- [elpa] 204/255: prefix external names with package name, Eric Schulte, 2014/03/15
- [elpa] 165/255: working on placing backgrounds behind pieces, Eric Schulte, 2014/03/15
- [elpa] 202/255: added interface function to view an SGF file, Eric Schulte, 2014/03/15
- [elpa] 205/255: update the README, Eric Schulte, 2014/03/15
- [elpa] 206/255: ensure prisoners are 0 at the start of a new game, Eric Schulte, 2014/03/15
- [elpa] 208/255: support for viewing lists in a buffer,
Eric Schulte <=
- [elpa] 207/255: robustly handle prematurely quitting process, Eric Schulte, 2014/03/15
- [elpa] 209/255: adding curry, rcurry and compose helpers, Eric Schulte, 2014/03/15
- [elpa] 213/255: include headers in width calculation, Eric Schulte, 2014/03/15
- [elpa] 215/255: smaller ldots, Eric Schulte, 2014/03/15
- [elpa] 200/255: refresh the go board, Eric Schulte, 2014/03/15
- [elpa] 214/255: refresh list every time the buffer changes size, Eric Schulte, 2014/03/15
- [elpa] 212/255: bug fix, wrong function name, Eric Schulte, 2014/03/15
- [elpa] 225/255: quit observing IGS game w/o closing connection, Eric Schulte, 2014/03/15
- [elpa] 171/255: bigger stones, Eric Schulte, 2014/03/15
- [elpa] 219/255: updated igs backend, Eric Schulte, 2014/03/15