Mercurial > emacs
comparison lisp/tumme.el @ 68783:86813076a765
(tumme-dir): Changed default value to "~/.emacs-d/tumme"
(tumme-dir): New function. Copied from thumbs.el.
author | Mathias Dahl <mathias.dahl@gmail.com> |
---|---|
date | Fri, 10 Feb 2006 23:43:02 +0000 |
parents | 3c76b1d6eff0 |
children | 3e96b0954fa1 4b3d39451150 |
comparison
equal
deleted
inserted
replaced
68782:5bcc23f3e602 | 68783:86813076a765 |
---|---|
55 ;; pronounce it, go to the page on EmacsWiki and download the .ogg | 55 ;; pronounce it, go to the page on EmacsWiki and download the .ogg |
56 ;; file from there. | 56 ;; file from there. |
57 ;; | 57 ;; |
58 ;; `tumme' stores the thumbnail files in `tumme-dir' using the file | 58 ;; `tumme' stores the thumbnail files in `tumme-dir' using the file |
59 ;; name format ORIGNAME.thumb.ORIGEXT. For example | 59 ;; name format ORIGNAME.thumb.ORIGEXT. For example |
60 ;; ~/.tumme/myimage01.thumb.jpg. The "database" is for now just a | 60 ;; ~/.emacs.d/tumme/myimage01.thumb.jpg. The "database" is for now |
61 ;; plain text file with the following format: | 61 ;; just a plain text file with the following format: |
62 ;; | 62 ;; |
63 ;; file-name-non-directory;comment:comment-text;tag1;tag2;tag3;...;tagN | 63 ;; file-name-non-directory;comment:comment-text;tag1;tag2;tag3;...;tagN |
64 ;; | 64 ;; |
65 ;; | 65 ;; |
66 ;; PREREQUISITES | 66 ;; PREREQUISITES |
506 ;; returns a thumbnail image descriptor. Then third-party libraries | 506 ;; returns a thumbnail image descriptor. Then third-party libraries |
507 ;; won't have to muck around with tumme.el's internal functions like | 507 ;; won't have to muck around with tumme.el's internal functions like |
508 ;; `thumme-thumb-name', `tumme-create-thumb', etc. His code to get | 508 ;; `thumme-thumb-name', `tumme-create-thumb', etc. His code to get |
509 ;; speedbar display tumme thumbnails, might be integrated soon. | 509 ;; speedbar display tumme thumbnails, might be integrated soon. |
510 ;; | 510 ;; |
511 ;; * Changed the default value of `tumme-dir' to "~/.emacs.d/tumme" | |
512 ;; and added a new function, `tumme-dir' to handle the creating of | |
513 ;; it. Code copied from thumbs.el. | |
514 ;; | |
515 ;; | |
511 ;; TODO | 516 ;; TODO |
512 ;; ==== | 517 ;; ==== |
513 ;; | 518 ;; |
514 ;; * Support gallery creation when using per-directory thumbnail | 519 ;; * Support gallery creation when using per-directory thumbnail |
515 ;; storage. | 520 ;; storage. |
570 (defgroup tumme nil | 575 (defgroup tumme nil |
571 "Use dired to browse your images as thumbnails, and more." | 576 "Use dired to browse your images as thumbnails, and more." |
572 :prefix "tumme-" | 577 :prefix "tumme-" |
573 :group 'files) | 578 :group 'files) |
574 | 579 |
575 (defcustom tumme-dir "~/.tumme/" | 580 (defcustom tumme-dir "~/.emacs.d/tumme/" |
576 "*Directory where thumbnail images for are stored." | 581 "*Directory where thumbnail images are stored." |
577 :type 'string | 582 :type 'string |
578 :group 'tumme) | 583 :group 'tumme) |
579 | 584 |
580 (defcustom tumme-thumbnail-storage 'use-tumme-dir | 585 (defcustom tumme-thumbnail-storage 'use-tumme-dir |
581 "*How to store tumme's thumbnail files. | 586 "*How to store tumme's thumbnail files. |
587 :type '(choice :tag "How to store thumbnail files" | 592 :type '(choice :tag "How to store thumbnail files" |
588 (const :tag "Use tumme-dir" use-tumme-dir) | 593 (const :tag "Use tumme-dir" use-tumme-dir) |
589 (const :tag "Per-directory" per-directory)) | 594 (const :tag "Per-directory" per-directory)) |
590 :group 'tumme) | 595 :group 'tumme) |
591 | 596 |
592 (defcustom tumme-db-file "~/.tumme/.tumme_db" | 597 (defcustom tumme-db-file "~/.emacs.d/tumme/.tumme_db" |
593 "*Database file where file names and their associated tags are stored." | 598 "*Database file where file names and their associated tags are stored." |
594 :type 'string | 599 :type 'string |
595 :group 'tumme) | 600 :group 'tumme) |
596 | 601 |
597 (defcustom tumme-temp-image-file "~/.tumme/.tumme_temp" | 602 (defcustom tumme-temp-image-file "~/.emacs.d/tumme/.tumme_temp" |
598 "*Name of temporary image file used by various commands." | 603 "*Name of temporary image file used by various commands." |
599 :type 'string | 604 :type 'string |
600 :group 'tumme) | 605 :group 'tumme) |
601 | 606 |
602 (defcustom tumme-gallery-dir "~/.tumme/.tumme_gallery" | 607 (defcustom tumme-gallery-dir "~/.emacs.d/tumme/.tumme_gallery" |
603 "*Directory to store generated gallery html pages. | 608 "*Directory to store generated gallery html pages. |
604 This path needs to be \"shared\" to the public so that it can access | 609 This path needs to be \"shared\" to the public so that it can access |
605 the index.html page that tumme creates." | 610 the index.html page that tumme creates." |
606 :type 'string | 611 :type 'string |
607 :group 'tumme) | 612 :group 'tumme) |
694 `tumme-temp-image-file'." | 699 `tumme-temp-image-file'." |
695 :type 'string | 700 :type 'string |
696 :group 'tumme) | 701 :group 'tumme) |
697 | 702 |
698 (defcustom tumme-temp-rotate-image-file | 703 (defcustom tumme-temp-rotate-image-file |
699 "~/.tumme/.tumme_rotate_temp" | 704 "~/.emacs.d/tumme/.tumme_rotate_temp" |
700 "*Temporary file for rotate operations." | 705 "*Temporary file for rotate operations." |
701 :type 'string | 706 :type 'string |
702 :group 'tumme) | 707 :group 'tumme) |
703 | 708 |
704 (defcustom tumme-rotate-original-ask-before-overwrite t | 709 (defcustom tumme-rotate-original-ask-before-overwrite t |
848 (defcustom tumme-show-all-from-dir-max-files 50 | 853 (defcustom tumme-show-all-from-dir-max-files 50 |
849 "*Maximum number of files to show using`tumme-show-all-from-dir'. | 854 "*Maximum number of files to show using`tumme-show-all-from-dir'. |
850 before warning the user." | 855 before warning the user." |
851 :type 'integer | 856 :type 'integer |
852 :group 'tumme) | 857 :group 'tumme) |
858 | |
859 (defun tumme-dir () | |
860 "Return the current thumbnails directory (from `tumme-dir'). | |
861 Create the thumbnails directory if it does not exist." | |
862 (let ((tumme-dir (file-name-as-directory | |
863 (expand-file-name tumme-dir)))) | |
864 (unless (file-directory-p tumme-dir) | |
865 (make-directory tumme-dir t) | |
866 (message "Creating thumbnails directory")) | |
867 tumme-dir)) | |
853 | 868 |
854 (defun tumme-insert-image (file type relief margin) | 869 (defun tumme-insert-image (file type relief margin) |
855 "Insert image FILE of image TYPE, using RELIEF and MARGIN, at point." | 870 "Insert image FILE of image TYPE, using RELIEF and MARGIN, at point." |
856 | 871 |
857 (let ((i `(image :type ,type | 872 (let ((i `(image :type ,type |
907 ;; thumbnail file name need not be that | 922 ;; thumbnail file name need not be that |
908 ;; "cryptographically" good so a faster one could | 923 ;; "cryptographically" good so a faster one could |
909 ;; be used here. | 924 ;; be used here. |
910 (setq md5-hash (md5 (file-name-as-directory | 925 (setq md5-hash (md5 (file-name-as-directory |
911 (file-name-directory file)))) | 926 (file-name-directory file)))) |
912 (file-name-as-directory (expand-file-name tumme-dir))) | 927 (file-name-as-directory (expand-file-name (tumme-dir)))) |
913 ((eq 'per-directory tumme-thumbnail-storage) | 928 ((eq 'per-directory tumme-thumbnail-storage) |
914 (format "%s.tumme/" | 929 (format "%s.tumme/" |
915 (file-name-directory f)))) | 930 (file-name-directory f)))) |
916 (file-name-sans-extension | 931 (file-name-sans-extension |
917 (file-name-nondirectory f)) | 932 (file-name-nondirectory f)) |
2708 ;; (mapcar | 2723 ;; (mapcar |
2709 ;; (lambda (f) | 2724 ;; (lambda (f) |
2710 ;; (let ((fattribs (file-attributes f))) | 2725 ;; (let ((fattribs (file-attributes f))) |
2711 ;; ;; Get last access time and file size | 2726 ;; ;; Get last access time and file size |
2712 ;; `(,(nth 4 fattribs) ,(nth 7 fattribs) ,f))) | 2727 ;; `(,(nth 4 fattribs) ,(nth 7 fattribs) ,f))) |
2713 ;; (directory-files tumme-dir t ".+\.thumb\..+$")) | 2728 ;; (directory-files (tumme-dir) t ".+\.thumb\..+$")) |
2714 ;; ;; Sort function. Compare time between two files. | 2729 ;; ;; Sort function. Compare time between two files. |
2715 ;; '(lambda (l1 l2) | 2730 ;; '(lambda (l1 l2) |
2716 ;; (time-less-p (car l1) (car l2))))) | 2731 ;; (time-less-p (car l1) (car l2))))) |
2717 ;; (dirsize (apply '+ (mapcar (lambda (x) (cadr x)) files)))) | 2732 ;; (dirsize (apply '+ (mapcar (lambda (x) (cadr x)) files)))) |
2718 ;; (while (> dirsize tumme-dir-max-size) | 2733 ;; (while (> dirsize tumme-dir-max-size) |