From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Mathias Dahl" Newsgroups: gmane.emacs.devel Subject: Additon to tumme.el Date: Sun, 16 Jul 2006 11:21:44 +0200 Message-ID: <7dbe73ed0607160221o38238f6dl10dd953a12112e0c@mail.gmail.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1153041727 13649 80.91.229.2 (16 Jul 2006 09:22:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 16 Jul 2006 09:22:07 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 16 11:22:03 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G22p8-00029Z-3e for ged-emacs-devel@m.gmane.org; Sun, 16 Jul 2006 11:22:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G22p6-00074C-JR for ged-emacs-devel@m.gmane.org; Sun, 16 Jul 2006 05:22:00 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G22ot-00070U-8i for emacs-devel@gnu.org; Sun, 16 Jul 2006 05:21:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G22os-000704-Rk for emacs-devel@gnu.org; Sun, 16 Jul 2006 05:21:46 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G22os-0006zg-IE for emacs-devel@gnu.org; Sun, 16 Jul 2006 05:21:46 -0400 Original-Received: from [64.233.182.188] (helo=nf-out-0910.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G22rH-0000C7-Me for emacs-devel@gnu.org; Sun, 16 Jul 2006 05:24:15 -0400 Original-Received: by nf-out-0910.google.com with SMTP id l24so530223nfc for ; Sun, 16 Jul 2006 02:21:44 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=YCgxsr7iTaURBF2hqQkFaNyxA0EWomKq4Xe01GdYz5tJHj+6M3q/TVkF/hlDXs6IpRrXtpluor8/dd33jJWnF59apnqP4WXE5pV5528VonIfgCvIIBJskgkMgMxUU4gmLnCAaISGsfGEATF3xu6/K96zw2GB4MF/9p2Ghea888I= Original-Received: by 10.48.242.9 with SMTP id p9mr1000071nfh; Sun, 16 Jul 2006 02:21:44 -0700 (PDT) Original-Received: by 10.48.248.13 with HTTP; Sun, 16 Jul 2006 02:21:44 -0700 (PDT) Original-To: emacs-devel@gnu.org Content-Disposition: inline X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:57085 Archived-At: I would like to add the following code to tumme.el. It provides a facility to very easily edit file tags and comments of image files in a buffer using widgets. It is actually quite simple but in my opinion a very nice piece of functionality for end users. The code does not affect any old functionality in tumme (only new functions and variables are added). I also propose yet another key binding (C-t e) in Dired that will call `tumme-dired-edit-comment-and-tags'. Is it a bad time now for things like this? ;;;; Code begins here (require 'widget) (eval-when-compile (require 'wid-edit)) (defvar tumme-widget-list nil "List to keep track of meta data in edit buffer") (defun tumme-dired-edit-comment-and-tags () "Edit comment and tags of current or marked image files. Edit comment and tags for all marked image files in an easy-to-use form." (interactive) (setq tumme-widget-list nil) ;; Setup buffer. (let ((files (dired-get-marked-files))) (switch-to-buffer "*Tumme Edit Meta Data*") (kill-all-local-variables) (make-local-variable 'widget-example-repeat) (let ((inhibit-read-only t)) (erase-buffer)) (remove-overlays) ;; Some help for the user. (widget-insert "\nEdit comments and tags for each image. Separate multiple tags with a comma. Move forward between fields using TAB or RET. Move to the previous field using backtab (S-TAB). Save by activating the Save button at the bottom of the form or cancel the operation by activating the Cancel button.\n\n") ;; Here comes all images and a comment and tag field for each ;; image. (mapc (lambda (file) (let* ((thumb-file (tumme-thumb-name file)) (img (create-image thumb-file)) comment-widget tag-widget) (insert-image img) (widget-insert "\n\nComment: ") (setq comment-widget (widget-create 'editable-field :size 60 :format "%v " :value (or (tumme-get-comment file) ""))) (widget-insert "\nTags: ") (setq tag-widget (widget-create 'editable-field :size 60 :format "%v " :value (or (mapconcat (lambda (tag) tag) (tumme-list-tags file) ",") ""))) ;; Save information in all widgets so that we can use it when ;; the user saves the form. (setq tumme-widget-list (append tumme-widget-list (list (list file comment-widget tag-widget)))) (widget-insert "\n\n"))) files)) ;; Footer with Save and Cancel button. (widget-insert "\n") (widget-create 'push-button :notify (lambda (&rest ignore) (tumme-save-information-from-widgets) (bury-buffer) (message "Done.")) "Save") (widget-insert " ") (widget-create 'push-button :notify (lambda (&rest ignore) (bury-buffer) (message "Operation canceled.")) "Cancel") (widget-insert "\n") (use-local-map widget-keymap) (widget-setup) ;; Jump to the first widget. (widget-forward 1)) (defun tumme-save-information-from-widgets () "Save information found in `tumme-widget-list'. Use the information in `tumme-widget-list' to save comments and tags to their respective image file. Internal function used by `tumme-dired-edit-comment-and-tags'." (mapc (lambda (x) (let ((file (car x)) (comment (widget-value (cadr x))) (tags (widget-value (caddr x)))) (tumme-write-comment file comment) (mapc (lambda (tag) (tumme-write-tag file tag)) (split-string tags ",")))) tumme-widget-list)) ;;;; Code ends here /Mathias