unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* format.el
@ 2002-04-06 17:32 Richard Stallman
  2002-04-06 17:55 ` format.el Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2002-04-06 17:32 UTC (permalink / raw)
  Cc: emacs-devel, gerd

format.el defines conversions for some international text representations
that are implented by running recode.  Also two that use iso-german
and iso-spanish.

Are these features still useful, or have they been obsoleted
by Mule facilities?  Can we delete some of this as obsolete?

^ permalink raw reply	[flat|nested] 7+ messages in thread
* format.el
@ 2004-03-18  2:11 Luc Teirlinck
  2004-03-20  4:48 ` format.el Richard Stallman
  0 siblings, 1 reply; 7+ messages in thread
From: Luc Teirlinck @ 2004-03-18  2:11 UTC (permalink / raw)


What about the following patch to format.el, which would make
`format-write-file' ask interactively for confirmation before
overwriting an existing file, in exactly the same way `write-file'
does?  I believe most users would expect `format-write-file' to behave
exactly like the more familiar and analogous `write-file' and asking
for confirmation does seem a lot safer.

The patch would also make `format-insert-file' always return a list of
two elements, just like `insert-file-contents' does, instead of
returning such a list if the FORMAT argument is nil and a non-list
cons cell otherwise.  There seems to be no reason whatsoever for the
subtle difference and I checked that the `insert-file-contents' change
does not produce any incompatibilities in the Emacs source code,
because the format argument is `nil' in all involved uses.  That is
exactly the case that would not change.

Those subtle differences can confuse the user and they would have to
be carefully documented at all appropriate places, including the Elisp
manual (currently that is not the case).  It seems a lot easier to
make the behavior uniform.

I could install if desired.

===File ~/format.el-diff====================================
*** format.el.~1.43.~	Mon Feb  9 13:59:35 2004
--- format.el	Mon Mar  8 20:07:30 2004
***************
*** 366,376 ****
  		 (funcall to-fn beg end (current-buffer)))))
  	  (setq format (cdr format)))))))
  
! (defun format-write-file (filename format)
    "Write current buffer into file FILENAME using some FORMAT.
! Makes buffer visit that file and sets the format as the default for future
  saves.  If the buffer is already visiting a file, you can specify a directory
! name as FILENAME, to write a file of the same old name in that directory."
    (interactive
     ;; Same interactive spec as write-file, plus format question.
     (let* ((file (if buffer-file-name
--- 366,380 ----
  		 (funcall to-fn beg end (current-buffer)))))
  	  (setq format (cdr format)))))))
  
! (defun format-write-file (filename format &optional confirm)
    "Write current buffer into file FILENAME using some FORMAT.
! Make buffer visit that file and set the format as the default for future
  saves.  If the buffer is already visiting a file, you can specify a directory
! name as FILENAME, to write a file of the same old name in that directory.
! 
! If optional third arg CONFIRM is non-nil, this function asks for
! confirmation before overwriting an existing file.  Interactively,
! confirmation is required unless you supply a prefix argument."
    (interactive
     ;; Same interactive spec as write-file, plus format question.
     (let* ((file (if buffer-file-name
***************
*** 382,388 ****
  				  nil nil (buffer-name))))
  	  (fmt (format-read (format "Write file `%s' in format: "
  				    (file-name-nondirectory file)))))
!      (list file fmt)))
    (let ((old-formats buffer-file-format)
  	preserve-formats)
      (dolist (fmt old-formats)
--- 386,392 ----
  				  nil nil (buffer-name))))
  	  (fmt (format-read (format "Write file `%s' in format: "
  				    (file-name-nondirectory file)))))
!      (list file fmt (not current-prefix-arg))))
    (let ((old-formats buffer-file-format)
  	preserve-formats)
      (dolist (fmt old-formats)
***************
*** 393,399 ****
      (dolist (fmt preserve-formats)
        (unless (memq fmt buffer-file-format)
  	(setq buffer-file-format (append buffer-file-format (list fmt))))))
!   (write-file filename))
  
  (defun format-find-file (filename format)
    "Find the file FILENAME using data format FORMAT.
--- 397,403 ----
      (dolist (fmt preserve-formats)
        (unless (memq fmt buffer-file-format)
  	(setq buffer-file-format (append buffer-file-format (list fmt))))))
!   (write-file filename confirm))
  
  (defun format-find-file (filename format)
    "Find the file FILENAME using data format FORMAT.
***************
*** 416,422 ****
  the part of the file to read.
  
  The return value is like the value of `insert-file-contents':
! a list (ABSOLUTE-FILE-NAME . SIZE)."
    (interactive
     ;; Same interactive spec as write-file, plus format question.
     (let* ((file (read-file-name "Find file: "))
--- 420,426 ----
  the part of the file to read.
  
  The return value is like the value of `insert-file-contents':
! a list (ABSOLUTE-FILE-NAME SIZE)."
    (interactive
     ;; Same interactive spec as write-file, plus format question.
     (let* ((file (read-file-name "Find file: "))
***************
*** 429,435 ****
        (setq size (nth 1 value)))
      (if format
  	(setq size (format-decode format size)
! 	      value (cons (car value) size)))
      value))
  
  (defun format-read (&optional prompt)
--- 433,439 ----
        (setq size (nth 1 value)))
      (if format
  	(setq size (format-decode format size)
! 	      value (list (car value) size)))
      value))
  
  (defun format-read (&optional prompt)
============================================================

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

end of thread, other threads:[~2004-03-20  4:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-06 17:32 format.el Richard Stallman
2002-04-06 17:55 ` format.el Eli Zaretskii
2002-04-07 10:46   ` format.el Kai Großjohann
2002-04-07 18:50   ` format.el Richard Stallman
2002-04-08  5:44     ` format.el Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2004-03-18  2:11 format.el Luc Teirlinck
2004-03-20  4:48 ` format.el 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).