* [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] @ 2007-07-19 12:23 Richard Stallman 2007-07-19 14:10 ` Thien-Thi Nguyen 0 siblings, 1 reply; 10+ messages in thread From: Richard Stallman @ 2007-07-19 12:23 UTC (permalink / raw) To: emacs-devel Would someone please DTRT, then ack? Please put the fix in Emacs 22 as well as the trunk. ------- Start of forwarded message ------- X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=failed version=3.1.0 From: Dieter Wilhelm <dieter@duenenhof-wilhelm.de> To: bug-gnu-emacs@gnu.org Date: Wed, 18 Jul 2007 17:39:34 +0200 Subject: image-dired (tumme) database file not existing Hi please do: 1.) emacs -D -Q 2.) M-x image-dired (loading some directory) 3.) Then I'd like to comment some file (pressing c) in the *image-dired* buffer but I receive the following error message: image-dired-write-comments: Opening input file: no such file or directory, /home/dieter/.emacs.d/image-dired/.image-dired_db Dieter In GNU Emacs 22.1.5 (x86_64-unknown-linux-gnu, GTK+ Version 2.8.20) of 2007-07-01 on debby Windowing system distributor `The X.Org Foundation', version 11.0.70101000 configured using `configure '--with-gtk'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US.UTF-8 locale-coding-system: utf-8 default-enable-multibyte-characters: t Major mode: Article Minor modes in effect: shell-dirtrack-mode: t iswitchb-mode: t display-time-mode: t show-paren-mode: t tooltip-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t unify-8859-on-encoding-mode: t utf-translate-cjk-mode: t auto-compression-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t abbrev-mode: t Recent input: M-b M-b M-b C-b ' v e C-e SPC 8 - ) . C-j C-j <tab> D i e t e r C-p C-p C-e C-b C-b C-b C-b <backspace> , SPC t o SPC b e SPC s h u r e SPC <backspace> <backspace> <backspace> <backspace> <backspace> u r e SPC I ' <backspace> SPC <backspace> ' v e SPC m a d e SPC n o SPC i <backspace> m i s t a k e s SPC C-a d u m b SPC M-q <M-backspace> s t u p i d SPC M-q C-e C-j C-j T h a n k s SPC f o r SPC t u m m e SPC M-( <backspace> <backspace> C-d SPC ( a SPC <backspace> SPC c o n v e r t ) <left> <left> <left> <left> <left> <left> <left> <left> s l o w SPC M-b M-b f r o m SPC C-e . <left> <left> <left> <left> <left> <left> <left> <left> <left> <left> <up> <left> <left> <left> <left> <left> <left> <left> <left> <left> <left> <left> <right> <right> <right> <right> <right> <right> <right> <backspace> ; C-c C-c <up> <return> <f4> <f5> M-x b b <return> r i c h <return> <help-echo> <down-mouse-1> <mouse-movement> <mouse-movement> <drag-mouse-1> <down-mouse-1> <mouse-movement> <mouse-movement> <drag-mouse-1> <f1> <f2> C-x o <tab> <tab> <tab> <tab> <tab> C-n C-n C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p <return> t t M-x e m a c s - r e <tab> <backspace> <backspace> b u <tab> <backspace> <backspace> <backspace> <backspace> <backspace> <backspace> <backspace> <backspace> r e p o <tab> o <backspace> r t - e m <tab> <retur n> Recent messages: Saving file /home/dieter/Mail/archive/sent... Wrote /home/dieter/Mail/archive/sent Sending...done Auto-saving...done Formatting...done. Type C-x 4 b RET to restore old contents of the bbdb-list window. Follow the link. [5 times] widget-button-press: Buffer is read-only: #<buffer *Article*> Making completion list... Loading emacsbug...done _______________________________________________ bug-gnu-emacs mailing list bug-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs ------- End of forwarded message ------- ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] 2007-07-19 12:23 [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] Richard Stallman @ 2007-07-19 14:10 ` Thien-Thi Nguyen 2007-07-19 15:03 ` Mathias Dahl 2007-07-21 23:36 ` Mathias Dahl 0 siblings, 2 replies; 10+ messages in thread From: Thien-Thi Nguyen @ 2007-07-19 14:10 UTC (permalink / raw) To: Mathias Dahl; +Cc: dieter, emacs-devel [-- Attachment #1: Type: text/plain, Size: 646 bytes --] () Dieter Wilhelm <dieter@duenenhof-wilhelm.de> () Wed, 18 Jul 2007 17:39:34 +0200 image-dired-write-comments: Opening input file: no such file or directory, /home/dieter/.emacs.d/image-dired/.image-dired_db below is a quick patch (against the trunk). here is a ChangeLog entry: * image-dired.el (image-dired-sane-db-file): New func. (image-dired-write-tags, image-dired-remove-tag) (image-dired-list-tags, image-dired-write-comments) (image-dired-get-comment, image-dired-mark-tagged-files) (image-dired-create-gallery-lists): Call new func. does this give good results? thi ___________________________________________________ [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: .ttn.image-dired.diff --] [-- Type: text/x-diff, Size: 3382 bytes --] Index: image-dired.el =================================================================== RCS file: /sources/emacs/emacs/lisp/image-dired.el,v retrieving revision 1.4 diff -c -r1.4 image-dired.el *** image-dired.el 13 Jun 2007 00:05:24 -0000 1.4 --- image-dired.el 19 Jul 2007 14:00:33 -0000 *************** *** 869,879 **** --- 869,896 ---- ;;;###autoload (defalias 'tumme 'image-dired-show-all-from-dir) + (defun image-dired-sane-db-file () + "Check if `image-dired-db-file' exists. + If not, try to create it (including any parent directories). + Signal error if there are problems creating it." + (or (file-exists-p image-dired-db-file) + (let (dir buf) + (unless (file-directory-p (setq dir (file-name-directory + image-dired-db-file))) + (make-directory dir t)) + (with-current-buffer (setq buf (create-file-buffer + image-dired-db-file)) + (write-file image-dired-db-file)) + (kill-buffer buf) + (file-exists-p image-dired-db-file)) + (error "Could not create %s" image-dired-db-file))) + (defun image-dired-write-tags (file-tags) "Write file tags to database. Write each file and tag in FILE-TAGS to the database. FILE-TAGS is an alist in the following form: ((FILE . TAG) ... )" + (image-dired-sane-db-file) (let (end file tag) (with-temp-file image-dired-db-file (insert-file-contents image-dired-db-file) *************** *** 893,898 **** --- 910,916 ---- (defun image-dired-remove-tag (files tag) "For all FILES, remove TAG from the image database." + (image-dired-sane-db-file) (save-excursion (let (end buf start) (setq buf (find-file image-dired-db-file)) *************** *** 927,932 **** --- 945,951 ---- (defun image-dired-list-tags (file) "Read all tags for image FILE from the image database." + (image-dired-sane-db-file) (save-excursion (let (end buf (tags "")) (setq buf (find-file image-dired-db-file)) *************** *** 2038,2043 **** --- 2057,2063 ---- Write file comments to one or more files. FILE-COMMENTS is an alist on the following form: ((FILE . COMMENT) ... )" + (image-dired-sane-db-file) (let (end comment-beg-pos comment-end-pos file comment) (with-temp-file image-dired-db-file (insert-file-contents image-dired-db-file) *************** *** 2108,2113 **** --- 2128,2134 ---- (defun image-dired-get-comment (file) "Get comment for file FILE." + (image-dired-sane-db-file) (save-excursion (let (end buf comment-beg-pos comment-end-pos comment) (setq buf (find-file image-dired-db-file)) *************** *** 2136,2141 **** --- 2157,2163 ---- on all image files in the database file. The files that have a matching tags will be marked in the dired buffer." (interactive) + (image-dired-sane-db-file) (let ((tag (read-string "Mark tagged files (regexp): ")) (hits 0) files buf) *************** *** 2300,2305 **** --- 2322,2328 ---- (defun image-dired-create-gallery-lists () "Create temporary lists used by `image-dired-gallery-generate'." + (image-dired-sane-db-file) (let ((buf (find-file image-dired-db-file)) end beg file row-tags) (setq image-dired-tag-file-list nil) [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] 2007-07-19 14:10 ` Thien-Thi Nguyen @ 2007-07-19 15:03 ` Mathias Dahl 2007-07-19 15:37 ` Thien-Thi Nguyen 2007-07-21 23:36 ` Mathias Dahl 1 sibling, 1 reply; 10+ messages in thread From: Mathias Dahl @ 2007-07-19 15:03 UTC (permalink / raw) To: Thien-Thi Nguyen; +Cc: dieter, emacs-devel > below is a quick patch (against the trunk). > here is a ChangeLog entry: > does this give good results? I haven't tested the patch yet but it looks okay. I had a different idea in mind, however: Instead of making each function make sure a db file exist, why not change code like this: (find-file image-dired-db-file) into this: (find-file (image-dired-db-file)) And inside that new defun basically do what you did in your new function. I did not follow very closely the recent discussions about Emacs' data directory so I don't remember if anything useful came out of it that could be used here. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] 2007-07-19 15:03 ` Mathias Dahl @ 2007-07-19 15:37 ` Thien-Thi Nguyen 2007-07-20 5:25 ` tomas 0 siblings, 1 reply; 10+ messages in thread From: Thien-Thi Nguyen @ 2007-07-19 15:37 UTC (permalink / raw) To: Mathias Dahl; +Cc: dieter, emacs-devel () "Mathias Dahl" <mathias.dahl@gmail.com> () Thu, 19 Jul 2007 17:03:09 +0200 Instead of making each function make sure a db file exist, why not change code like this: (find-file image-dired-db-file) into this: (find-file (image-dired-db-file)) And inside that new defun basically do what you did in your new function. well, i considered that, too, but decided against it due to the following reasoning (somewhat muddied by the summer heat): there are two phases to the code's relationship w/ the file: 0/ ascertaining that it exists; 1/ accessing it. i think it's best to keep these separate because the cost of phase 0 should be minimized. when they are performed separately, a knowledgable programmer (such as the author of image-dired.el ;-) can further decrease the costs by avoiding phase 0 altogether in some places, by reasoning about the call graph, where the unknowledgable programmer (me) mechanistically added "safe" calls. in other words, there is some upside to the separate approach; it invites refined hacking. when the phases are performed together, no such potential exists (except in reworking the code to separate them; ie., inviting more hacking than necessary :-). of course, one could argue lots of file-exists-p calls are no big deal, but i would not be that one. (half-informed philosophical mumbling follows) what we see here is the basic tension between functional programming and the real world (external) state... change happens but is it the root or the leaves that must react? thi ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] 2007-07-19 15:37 ` Thien-Thi Nguyen @ 2007-07-20 5:25 ` tomas 2007-07-20 6:44 ` Thien-Thi Nguyen 0 siblings, 1 reply; 10+ messages in thread From: tomas @ 2007-07-20 5:25 UTC (permalink / raw) To: Thien-Thi Nguyen; +Cc: dieter, emacs-devel, Mathias Dahl -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thu, Jul 19, 2007 at 05:37:10PM +0200, Thien-Thi Nguyen wrote: > () "Mathias Dahl" <mathias.dahl@gmail.com> > () Thu, 19 Jul 2007 17:03:09 +0200 > > Instead of making each function make sure a db file exist, why not > change code like this: > > (find-file image-dired-db-file) > > into this: > > (find-file (image-dired-db-file)) > > And inside that new defun basically do what you did in your new function. > > well, i considered that, too, but decided against it due to the > following reasoning (somewhat muddied by the summer heat): [...] > of course, one could argue lots of file-exists-p calls are no big > deal, but i would not be that one. (half-informed philosophical > mumbling follows) what we see here is the basic tension between > functional programming and the real world (external) state... > change happens but is it the root or the leaves that must react? Ah, philosophy, let's jump in ;-) One aspect that IMHO deserves mention is that Mathias' approach is more change-friendly. If a third, not-so-knowledgeable hacker (e.g. me) tries to fix something, (s)he is less probable to screw things up. Regards - -- tomás -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFGoEdYBcgs9XrR2kYRAqi2AJ4jv2yy/gkyGAN2KZxdSPedeDDoJACeLYwD hpCgxQeciSR5/rCECJSN6DQ= =nNo9 -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] 2007-07-20 5:25 ` tomas @ 2007-07-20 6:44 ` Thien-Thi Nguyen 2007-07-20 8:10 ` tomas 0 siblings, 1 reply; 10+ messages in thread From: Thien-Thi Nguyen @ 2007-07-20 6:44 UTC (permalink / raw) To: tomas; +Cc: dieter, emacs-devel, Mathias Dahl () tomas@tuxteam.de () Fri, 20 Jul 2007 05:25:44 +0000 One aspect that IMHO deserves mention is that Mathias' approach is more change-friendly. If a third, not-so-knowledgeable hacker (e.g. me) tries to fix something, (s)he is less probable to screw things up. sometimes screwing things up is the best change (at least, temporarily ;-). in this way the maintainer gets to practice "stimulated annulling", yuk yuk. thi ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] 2007-07-20 6:44 ` Thien-Thi Nguyen @ 2007-07-20 8:10 ` tomas 0 siblings, 0 replies; 10+ messages in thread From: tomas @ 2007-07-20 8:10 UTC (permalink / raw) To: Thien-Thi Nguyen; +Cc: emacs-devel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Fri, Jul 20, 2007 at 08:44:37AM +0200, Thien-Thi Nguyen wrote: > () tomas@tuxteam.de > () Fri, 20 Jul 2007 05:25:44 +0000 > > One aspect that IMHO deserves mention is that > Mathias' approach is more change-friendly [...] > sometimes screwing things up is the best change (at > least, temporarily ;-). in this way the maintainer > gets to practice "stimulated annulling", yuk yuk. :-)) - -- tomás -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFGoG3aBcgs9XrR2kYRAnS0AJsHDrtJQdMtvYAMYNw14X5YBIdx+wCfaW0X CCkLLYVpJYbGV8BJxtAm0q8= =wB+p -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] 2007-07-19 14:10 ` Thien-Thi Nguyen 2007-07-19 15:03 ` Mathias Dahl @ 2007-07-21 23:36 ` Mathias Dahl 2007-07-21 23:49 ` Thien-Thi Nguyen 1 sibling, 1 reply; 10+ messages in thread From: Mathias Dahl @ 2007-07-21 23:36 UTC (permalink / raw) To: Thien-Thi Nguyen; +Cc: dieter, emacs-devel > below is a quick patch (against the trunk). > here is a ChangeLog entry: > > * image-dired.el (image-dired-sane-db-file): New func. > (image-dired-write-tags, image-dired-remove-tag) > (image-dired-list-tags, image-dired-write-comments) > (image-dired-get-comment, image-dired-mark-tagged-files) > (image-dired-create-gallery-lists): Call new func. Since there has been no strong objection (mine is more a philosophical one and not a very strong one) I think we should install your fix. We can always debate the differences later; the fix does solve the problem and does not cause any problems as far as I can see. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] 2007-07-21 23:36 ` Mathias Dahl @ 2007-07-21 23:49 ` Thien-Thi Nguyen 2007-07-22 18:36 ` Richard Stallman 0 siblings, 1 reply; 10+ messages in thread From: Thien-Thi Nguyen @ 2007-07-21 23:49 UTC (permalink / raw) To: Mathias Dahl; +Cc: dieter, emacs-devel () "Mathias Dahl" <mathias.dahl@gmail.com> () Sun, 22 Jul 2007 01:36:02 +0200 I think we should install your fix thanks for reviewing the patch. it's now installed on both trunk and EMACS_22_BASE. thi ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] 2007-07-21 23:49 ` Thien-Thi Nguyen @ 2007-07-22 18:36 ` Richard Stallman 0 siblings, 0 replies; 10+ messages in thread From: Richard Stallman @ 2007-07-22 18:36 UTC (permalink / raw) To: Thien-Thi Nguyen; +Cc: dieter, emacs-devel, mathias.dahl Thanks for fixing it. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-07-22 18:36 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-07-19 12:23 [dieter@duenenhof-wilhelm.de: image-dired (tumme) database file not existing] Richard Stallman 2007-07-19 14:10 ` Thien-Thi Nguyen 2007-07-19 15:03 ` Mathias Dahl 2007-07-19 15:37 ` Thien-Thi Nguyen 2007-07-20 5:25 ` tomas 2007-07-20 6:44 ` Thien-Thi Nguyen 2007-07-20 8:10 ` tomas 2007-07-21 23:36 ` Mathias Dahl 2007-07-21 23:49 ` Thien-Thi Nguyen 2007-07-22 18:36 ` Richard Stallman
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).