all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Tag based dired?
@ 2006-06-23  0:33 Xiao-Yong Jin
  2006-06-23 21:38 ` Leon
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Xiao-Yong Jin @ 2006-06-23  0:33 UTC (permalink / raw)


Hi all, I'm wondering if there is some kind of tag or label support in
dired.

Nowadays tagging or labeling is used widely on the Internet.  Blogs
and wikis has various tag support.  And gmail has its flexible
labeling support.  So does the f-spot.  I did some search on the web
and there is no file manager that really supports tags well.  

So far I use org-mode to organize my staff as well as my files.
Because you can add various tags to a subject in org-mode, it's easy
to manager all the files.  However, it's not easy to handle files
using file links in org-mode.

I think it would be much better if one could give various labels to
files, and organize and search files using labels, especially in dired
or even wdired.

I want to ask if there are some easy way to implement this feature in
emacs?  This file tagging idea is very rough now and I would like to
do some research to make it more concrete.  And if it's possible, I
want to implement it as a plugin to dired?

-- 
Xiao-Yong

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tag based dired?
  2006-06-23  0:33 Tag based dired? Xiao-Yong Jin
@ 2006-06-23 21:38 ` Leon
  2006-06-23 23:48   ` Bill Wohler
                     ` (2 more replies)
  2006-06-26  8:58 ` Mathias Dahl
  2006-06-27 14:58 ` Mathias Dahl
  2 siblings, 3 replies; 10+ messages in thread
From: Leon @ 2006-06-23 21:38 UTC (permalink / raw)


Xiao-Yong Jin <xj2106NO@SPAMcolumbia.edu> writes:

> Hi all, I'm wondering if there is some kind of tag or label support in
> dired.
>
> Nowadays tagging or labeling is used widely on the Internet.  Blogs
> and wikis has various tag support.  And gmail has its flexible
> labeling support.  So does the f-spot.  I did some search on the web
> and there is no file manager that really supports tags well.  
>
> So far I use org-mode to organize my staff as well as my files.
> Because you can add various tags to a subject in org-mode, it's easy
> to manager all the files.  However, it's not easy to handle files
> using file links in org-mode.
>
> I think it would be much better if one could give various labels to
> files, and organize and search files using labels, especially in dired
> or even wdired.
>
> I want to ask if there are some easy way to implement this feature in
> emacs?  This file tagging idea is very rough now and I would like to
> do some research to make it more concrete.  And if it's possible, I
> want to implement it as a plugin to dired?

Could you give an example of using tag?

-- 
Leon

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tag based dired?
  2006-06-23 21:38 ` Leon
@ 2006-06-23 23:48   ` Bill Wohler
       [not found]   ` <mailman.3279.1151106523.9609.help-gnu-emacs@gnu.org>
  2006-06-24 19:09   ` Leon
  2 siblings, 0 replies; 10+ messages in thread
From: Bill Wohler @ 2006-06-23 23:48 UTC (permalink / raw)


Leon <sdl.web@gmail.com> writes:

> Could you give an example of using tag?

I'll guess.

Take mh-e.el for example. Right now, for me, it is in one specific
place on my hard drive, namely, /usr/local/src/emacs/lisp/mh-e/mh-e.el.

I could tag this file with "mail", "emacs", "lisp", "source", "MH-E".
In addition, the lisp files already have a Keywords pseudo-header
field which could be used to automatically tag the files as well.

I could then find this file by specifying any of those tags. I could
limit the number of files I see by specifying more tags.

If you were to use a normal file system, you'd create a directory for
each tag in the system, and create hard links between the directories
for files that share tags.

The major advantage of this system is that it would be easier to
classify and find stuff since you wouldn't have to create--and
remember--a possible arcane path to a file. The disadvantage with this
implementation is that the directories would be huge and unwieldy.

An Emacs interface to this would make it easy to enter tags and to
limit the output to files tagged with those tags.

In the meantime, you might look at locate and locate-with-filter. Why
these functions don't put their output in a dired buffer is beyond me.

-- 
Bill Wohler <wohler@newt.com>  http://www.newt.com/wohler/  GnuPG ID:610BD9AD

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tag based dired?
       [not found]   ` <mailman.3279.1151106523.9609.help-gnu-emacs@gnu.org>
@ 2006-06-24  3:20     ` Xiao-Yong Jin
  0 siblings, 0 replies; 10+ messages in thread
From: Xiao-Yong Jin @ 2006-06-24  3:20 UTC (permalink / raw)


Bill Wohler <wohler@newt.com> writes:

> Leon <sdl.web@gmail.com> writes:
>
>> Could you give an example of using tag?
>
> I'll guess.
>
> Take mh-e.el for example. Right now, for me, it is in one specific
> place on my hard drive, namely, /usr/local/src/emacs/lisp/mh-e/mh-e.el.
>
> I could tag this file with "mail", "emacs", "lisp", "source", "MH-E".
> In addition, the lisp files already have a Keywords pseudo-header
> field which could be used to automatically tag the files as well.
>
> I could then find this file by specifying any of those tags. I could
> limit the number of files I see by specifying more tags.
>
Yes, that's exactly what I meant.

> If you were to use a normal file system, you'd create a directory for
> each tag in the system, and create hard links between the directories
> for files that share tags.
>
I see this as a disadvantage of the conventional way to store files.

> The major advantage of this system is that it would be easier to
> classify and find stuff since you wouldn't have to create--and
> remember--a possible arcane path to a file. The disadvantage with this
> implementation is that the directories would be huge and unwieldy.
>
It's like that you have two ways of labeling or classifying an
ordinary file.  One is the physical path of a file in the file system
it resides.  The other is a logical way, that is, you can specify a
certain file or a group of files by giving some tags.  It's a much
easier way to grouping files, I guess.  But, I don't see why the
directories would be huge and unwieldy?  I think a good hierarchy of
arcane paths of files should be still well maintained.

> An Emacs interface to this would make it easy to enter tags and to
> limit the output to files tagged with those tags.
>
It's pretty much like a keyword database for files such that you can
search files by their keywords.  But an Emacs interface should provide
the end user a friendly interface like dired with a comprehensive and
powerful but yet easy way to manage the tags.  I think implement this
feature on top of dired would be ideal.  Actually it's like emblems in
nautilus -- personally I believe emblems in nautilus are just an extra
useless thing, not easy to use at all -- but with a powerful editing
and searching ability.

> In the meantime, you might look at locate and locate-with-filter. Why
> these functions don't put their output in a dired buffer is beyond me.
>
An easy and quick implementation like locate is fine.  At least the
output buffer of locate has similar interface with dired.  Many basic
editing can be done with it, like rename, copy, and even byte
compile.  I'll definitely look at that to see if I can get some
where.

One thing that still bothering me is how and where to store the tag
informations.  It should be easily accessed and edited, and searching
within it should be quick.  However, for a small group of file, plain
text should be sufficient.  And due to my personal interest, I tend to
use the org-mode.  Because I've been using org-mode to maintain links
to files and to web pages as well.  But this also pulls in the
incorporation with org-mode, which makes it harder to implement, at
least for me, now.  Nevertheless since searching through tags has
already been mature in org-mode, it could be the basis of tag
searching for files.

> -- 
> Bill Wohler <wohler@newt.com>  http://www.newt.com/wohler/  GnuPG ID:610BD9AD
>
>
>

More inputs from you are appreciated.

-- 
Xiao-Yong

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tag based dired?
  2006-06-23 21:38 ` Leon
  2006-06-23 23:48   ` Bill Wohler
       [not found]   ` <mailman.3279.1151106523.9609.help-gnu-emacs@gnu.org>
@ 2006-06-24 19:09   ` Leon
  2 siblings, 0 replies; 10+ messages in thread
From: Leon @ 2006-06-24 19:09 UTC (permalink / raw)


Thank you, Bill and Xiao-Yong.

It's a very nice feature to have:)

-- 
Leon

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tag based dired?
  2006-06-23  0:33 Tag based dired? Xiao-Yong Jin
  2006-06-23 21:38 ` Leon
@ 2006-06-26  8:58 ` Mathias Dahl
  2006-06-26 12:16   ` Xiao-Yong Jin
  2006-06-27  0:59   ` Bill Wohler
  2006-06-27 14:58 ` Mathias Dahl
  2 siblings, 2 replies; 10+ messages in thread
From: Mathias Dahl @ 2006-06-26  8:58 UTC (permalink / raw)


Xiao-Yong Jin <xj2106NO@SPAMcolumbia.edu> writes:

> Hi all, I'm wondering if there is some kind of tag or label support in
> dired.
>
> Nowadays tagging or labeling is used widely on the Internet.  Blogs
> and wikis has various tag support.  And gmail has its flexible
> labeling support.  So does the f-spot.  I did some search on the web
> and there is no file manager that really supports tags well.  

It certainly is possible. Tumme, which is part of CVS Emacs (Emacs 22)
has tagging capabilities. Tumme is used for browing image collections
and supports commenting and tagging images. Actually, you should be
able to use Tumme's tagging functionality to tag other types of files,
as long as you do not try to use it to display these files. :)

Tumme stores the comments and tags in a central "database" file. You
can use the tags to find files and have them marked in dired.

If you don't use CVS Emacs, download tumme.el from here:

http://www.emacswiki.org/cgi-bin/wiki/Tumme

Install it and put this in your .emacs:

(require 'tumme)

In dired, do M-x tumme-tag-files. You will be prompted for a list of
tags to add to the marked files. The tags will then be saved to the
tumme database file. After having added files, tell Emacs to mark them
using M-x tumme-mark-tagged-files.

Again, Tumme is for image browsing, but you could always try and
experiment with this to see how it works with other types of
files. Tagging files in this way is a generic thing.

Happy experimenting!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tag based dired?
  2006-06-26  8:58 ` Mathias Dahl
@ 2006-06-26 12:16   ` Xiao-Yong Jin
  2006-06-27  8:36     ` Mathias Dahl
  2006-06-27  0:59   ` Bill Wohler
  1 sibling, 1 reply; 10+ messages in thread
From: Xiao-Yong Jin @ 2006-06-26 12:16 UTC (permalink / raw)


Mathias Dahl <brakjoller@gmail.com> writes:

> Xiao-Yong Jin <xj2106NO@SPAMcolumbia.edu> writes:
>
>> Hi all, I'm wondering if there is some kind of tag or label support in
>> dired.
>>
>> Nowadays tagging or labeling is used widely on the Internet.  Blogs
>> and wikis has various tag support.  And gmail has its flexible
>> labeling support.  So does the f-spot.  I did some search on the web
>> and there is no file manager that really supports tags well.  
>
> It certainly is possible. Tumme, which is part of CVS Emacs (Emacs 22)
> has tagging capabilities. Tumme is used for browing image collections
> and supports commenting and tagging images. Actually, you should be
> able to use Tumme's tagging functionality to tag other types of files,
> as long as you do not try to use it to display these files. :)
>
> Tumme stores the comments and tags in a central "database" file. You
> can use the tags to find files and have them marked in dired.
>
> If you don't use CVS Emacs, download tumme.el from here:
>
> http://www.emacswiki.org/cgi-bin/wiki/Tumme
>
> Install it and put this in your .emacs:
>
> (require 'tumme)
>
> In dired, do M-x tumme-tag-files. You will be prompted for a list of
> tags to add to the marked files. The tags will then be saved to the
> tumme database file. After having added files, tell Emacs to mark them
> using M-x tumme-mark-tagged-files.
>
> Again, Tumme is for image browsing, but you could always try and
> experiment with this to see how it works with other types of
> files. Tagging files in this way is a generic thing.
>
> Happy experimenting!

Amazing.  I've been using emacs-unicode-2 branch for a year and wasn't
aware of Tumme's existence until now.  Certainly it's a great step
beyond the thumbs.el.  :-)

Two more things,

1) I got this when I first use tumme-tag-files
   basic-save-buffer-2: /home/jin/.emacs.d/tumme/.tumme_db: no such directory
   It would be fine to add a simple test and create the directory
   automatically.

2) Is there a more visible way to see all the tags associated to the
   files in dired buffer?
-- 
Xiao-Yong

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tag based dired?
  2006-06-26  8:58 ` Mathias Dahl
  2006-06-26 12:16   ` Xiao-Yong Jin
@ 2006-06-27  0:59   ` Bill Wohler
  1 sibling, 0 replies; 10+ messages in thread
From: Bill Wohler @ 2006-06-27  0:59 UTC (permalink / raw)


Mathias Dahl <brakjoller@gmail.com> writes:

> Tumme stores the comments and tags in a central "database" file. You
> can use the tags to find files and have them marked in dired.

Ah, that's a better implementation than the one I proposed.

Thanks for the heads-up.

-- 
Bill Wohler <wohler@newt.com>  http://www.newt.com/wohler/  GnuPG ID:610BD9AD

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tag based dired?
  2006-06-26 12:16   ` Xiao-Yong Jin
@ 2006-06-27  8:36     ` Mathias Dahl
  0 siblings, 0 replies; 10+ messages in thread
From: Mathias Dahl @ 2006-06-27  8:36 UTC (permalink / raw)


Xiao-Yong Jin <xj2106NO@SPAMcolumbia.edu> writes:

> Amazing.  I've been using emacs-unicode-2 branch for a year and wasn't
> aware of Tumme's existence until now.  Certainly it's a great step
> beyond the thumbs.el.  :-)

Well, it came into CVS Emacs some months ago, and it is quite easy to
miss.

> 1) I got this when I first use tumme-tag-files
>    basic-save-buffer-2: /home/jin/.emacs.d/tumme/.tumme_db: no such directory
>    It would be fine to add a simple test and create the directory
>    automatically.

I'll look into that. In your case, was it .emacs.d or its sub
directory "tumme" that was missing?

> 2) Is there a more visible way to see all the tags associated to the
>    files in dired buffer?

Not really. When you use Tumme for its original purpose, to browse
image thumbnails, you will see in the echo area all tags associated to
each image when you move around the thumbnails in the thumbnail
buffer. It would be easy to implement that for other files
too. Something like this, maybe:

(require 'tumme)

(defun tumme-dired-display-tags (file)
  "Display file FILE's tags in the echo area."
  (let ((tags (tumme-list-tags file)))
    (if tags
        (message "Tags: %s"
                 (mapconcat
                  (lambda (x)
                    x)
                  tags ", ")))))

(defun tumme-dired-next-line-display-tags (&optional arg)
  "In dired, go to next line and display tags, if any"
  (interactive "p")
  (dired-next-line arg)
  (tumme-dired-display-tags (dired-get-filename)))

(defun tumme-dired-previous-line-display-tags (&optional arg)
  "In dired, go to previous line and display tags, if any"
  (interactive "p")
  (dired-previous-line arg)
  (tumme-dired-display-tags (dired-get-filename)))

;; Bind keys in Dired

(define-key dired-mode-map "n" 'tumme-dired-next-line-display-tags)
(define-key dired-mode-map "p" 'tumme-dired-previous-line-display-tags)

Try it!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tag based dired?
  2006-06-23  0:33 Tag based dired? Xiao-Yong Jin
  2006-06-23 21:38 ` Leon
  2006-06-26  8:58 ` Mathias Dahl
@ 2006-06-27 14:58 ` Mathias Dahl
  2 siblings, 0 replies; 10+ messages in thread
From: Mathias Dahl @ 2006-06-27 14:58 UTC (permalink / raw)


Xiao-Yong Jin <xj2106NO@SPAMcolumbia.edu> writes:

> Hi all, I'm wondering if there is some kind of tag or label support in
> dired.
>
> Nowadays tagging or labeling is used widely on the Internet.  Blogs
> and wikis has various tag support.  And gmail has its flexible
> labeling support.  So does the f-spot.  I did some search on the web
> and there is no file manager that really supports tags well.  
>
> So far I use org-mode to organize my staff as well as my files.
> Because you can add various tags to a subject in org-mode, it's easy
> to manager all the files.  However, it's not easy to handle files
> using file links in org-mode.
>
> I think it would be much better if one could give various labels to
> files, and organize and search files using labels, especially in dired
> or even wdired.
>
> I want to ask if there are some easy way to implement this feature in
> emacs?  This file tagging idea is very rough now and I would like to
> do some research to make it more concrete.  And if it's possible, I
> want to implement it as a plugin to dired?

I just couldn't hold myself and created a small hack that might be
useful (hopefully I will find a use for it myself too so that I can
convince myself that the time was well spent.) :)

Here we go:

;;; file-props.el --- Add file properties to your files
;;
;; Copyright (C) 2006 Mathias Dahl
;;
;; Version: 0.1
;; Keywords: search, convenience, files
;; Author: Mathias Dahl <mathias.rem0veth1s.dahl@gmail.com>

;; This file is not part of GNU Emacs.

;; 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 2, 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.

;;; Commentary:
;;
;; file-props.el provides a way to "tag" or "label" your files.
;; Actually, the functionality is generic and supports adding any type
;; of property to your files.  Right now "tags" and a "comment" can be
;; added.
;;
;; After having added this meta data you can use it to find files in
;; different ways.  Provided is a command to list all files having a
;; certain tag in a dired buffer.
;;
;; NOTE: This is not stable yet, it is a proof-of-concept, to see if
;; it could be useful.  Use at own your risk.
;;
;;; Installation:
;;
;; Place this file in your `load-path'.
;;
;; Put this in your .emacs file:
;;
;; (require 'file-props)
;; (file-props-load-properties)
;;
;; NOTE: If you don't load the properties file it will be overwritten
;; with only the properties you define in this session.  I'm not sure
;; if this is the best approach though.  One could make file-props.el
;; automactially load all file properties when it is loaded.
;;
;;; Usage:
;;
;; - Adding tags:
;;
;; In dired, mark a couple of files and type M-x
;; file-props-dired-add-tags RET.
;;
;; On the prompt, enter one or more tags, separated with a comma and
;; type RET.
;;
;; - Finding files:
;;
;; Type M-x file-props-find-tags-dired RET.
;;
;; Enter a tag and type RET.
;;
;; You will be presented with a dired buffer containing the files
;; having the tag you searched for.
;;
;; - Other uses:
;;
;; Currently, the only other command is `file-props-dired-add-comment'
;; which will add a comment property to the file.  The idea is that
;; while tags are used to categorize or label your files, a comment is
;; more specific and can act as the description of the file.
;;
;; As explained above, tags and comments are just examples of meta
;; data you might want to add to your files, other types of data
;; should be easy to add if you want.  Look at
;; `file-props-dired-add-tags' and `file-props-dired-add-comment' for
;; examples.
;;
;;
;;; History:
;; 
;;
;; Version 0.1, 2006-06-27
;;
;; * First release.
;;

;;; Code:

(defgroup file-props nil
  "File properties lets you add different kinds of properties or
meta-data to files and have these properties saved to a central
data file.  This information can be used to mark file having a
certain meta-data in Dired."
  :group 'Convenience)


(defcustom file-props-data-file "~/.emacs.d/file-props"
  "File in which the file properties are saved."
  :type 'file
  :group 'file-props)


(defvar file-props-list nil
  "List containing the file properties.")


(defun file-props-add-property (file property value)
  "For FILE, set PROPERTY to VALUE.
If the property does not exist, it will be created.  If it
exists, the value will be overwritten."
  (unless (assoc file file-props-list)
    (setq file-props-list (append file-props-list (list (list file nil)))))
  (setcdr (assoc file file-props-list)
          (plist-put (cdr (assoc file file-props-list)) property value)))


(defun file-props-save-properties ()
  "Save file properties.
Save file properties to file `file-props-data-file'."
  (with-temp-file (expand-file-name file-props-data-file)
    (prin1 file-props-list (current-buffer))))


(defun file-props-load-properties ()
  "Load all file properties.
Load all file properties from file `file-props-data-file'.  If
the files does not exist, no harm is done; it will be created
when file properties are added to files."
  (let ((file (expand-file-name file-props-data-file))
        buf)
    (if (not (file-exists-p file))
        (message "File properties data file does not exist")
      (setq buf (find-file-noselect
                 file))
      (setq file-props-list (read buf))
      (kill-buffer buf))))


(defun file-props-dired-add-tags ()
  "Add file tags to current or marked files."
  (interactive)
  (let ((tags-string (read-string "Enter tags, separated by a comma: ")))
    (mapc
     (lambda (x)
       (file-props-add-property x 'tags (split-string tags-string ",")))
     (dired-get-marked-files)))
  ;; Don't save to file if there are no properties.  This works as a
  ;; kind of security measure, making sure that the data file is not
  ;; overwritten with no data if the user by mistake did not load the
  ;; old properties before adding new ones.  If anyone can come up
  ;; with a better approach than this, please don't hesitate to
  ;; contact me.
  (if file-props-list
      (file-props-save-properties)))


(defun file-props-dired-add-comment ()
  "Add file comment to current or marked files."
  (interactive)
  (let ((comment (read-string "Enter comment: ")))
    (mapc
     (lambda (x)
       (file-props-add-property x 'comment comment))
     (dired-get-marked-files)))
  (file-props-save-properties))


(defun file-props-list-all-tags ()
  "Return all unique tags for all files."
  (unless file-props-list
    (file-props-load-properties))
  (let (all-tags)
    (mapc
     (lambda (x)
       (let ((tags (plist-get (cdr x) 'tags)))
         (mapc
          (lambda (y)
            (unless (member y all-tags)
              (setq all-tags (append all-tags (list y)))))
          tags)))
     file-props-list)
    all-tags))


(defun file-props-find-files-from-tag (tag)
  "Return a list of all files having file tag TAG."
  (let (files)
    (mapc
     (lambda (x)
       (when (member tag (plist-get (cdr x) 'tags))
         (setq files (append files (list (car x))))))
     file-props-list)
    files))


(defun file-props-find-tags-dired ()
  "Search for file tag TAG to find files and list them in dired.
It generates a result like `find-dired' does."
  (interactive)
  (let ((dir (read-directory-name "Set current directory: "))
        (tag (read-string "Tag to search for: ")))
       (dired (cons dir (file-props-find-files-from-tag tag)))))


(provide 'file-props)

;;; file-props.el ends here

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-06-27 14:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-23  0:33 Tag based dired? Xiao-Yong Jin
2006-06-23 21:38 ` Leon
2006-06-23 23:48   ` Bill Wohler
     [not found]   ` <mailman.3279.1151106523.9609.help-gnu-emacs@gnu.org>
2006-06-24  3:20     ` Xiao-Yong Jin
2006-06-24 19:09   ` Leon
2006-06-26  8:58 ` Mathias Dahl
2006-06-26 12:16   ` Xiao-Yong Jin
2006-06-27  8:36     ` Mathias Dahl
2006-06-27  0:59   ` Bill Wohler
2006-06-27 14:58 ` Mathias Dahl

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.