diff options
| author | Chong Yidong | 2010-05-03 11:01:21 -0400 |
|---|---|---|
| committer | Chong Yidong | 2010-05-03 11:01:21 -0400 |
| commit | 53967e09ad89f11531c7fee0240c2eac1f63922c (patch) | |
| tree | c5442ddb118482959ce9e503ae48e71eb6758a52 /src | |
| parent | 1fada56353a7759495a3abb19d93235c040bccad (diff) | |
| download | emacs-53967e09ad89f11531c7fee0240c2eac1f63922c.tar.gz emacs-53967e09ad89f11531c7fee0240c2eac1f63922c.zip | |
Add optional arg to delete-file to force deletion (Bug#6070).
* eval.c (internal_condition_case_n): Rename from
internal_condition_case_2.
(internal_condition_case_2): New function.
* xdisp.c (safe_call): Use internal_condition_case_n.
* fileio.c (Fdelete_file, internal_delete_file): New arg FORCE.
(internal_delete_file, Frename_file): Callers changed.
* buffer.c (Fkill_buffer):
* callproc.c (delete_temp_file): Callers changed (Bug#6070).
* lisp.h: Update prototypes.
* diff.el (diff-sentinel):
* epg.el (epg--make-temp-file, epg-decrypt-string)
(epg-verify-string, epg-sign-string, epg-encrypt-string):
* jka-compr.el (jka-compr-partial-uncompress)
(jka-compr-call-process, jka-compr-write-region, jka-compr-load):
* server.el (server-sentinel): Use delete-file's new FORCE arg
(Bug#6070).
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 16 | ||||
| -rw-r--r-- | src/buffer.c | 2 | ||||
| -rw-r--r-- | src/callproc.c | 2 | ||||
| -rw-r--r-- | src/eval.c | 51 | ||||
| -rw-r--r-- | src/fileio.c | 25 | ||||
| -rw-r--r-- | src/lisp.h | 5 | ||||
| -rw-r--r-- | src/xdisp.c | 2 |
7 files changed, 88 insertions, 15 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index e14f7de13a6..3a9a9ca2264 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | 2010-05-03 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * eval.c (internal_condition_case_n): Rename from | ||
| 4 | internal_condition_case_2. | ||
| 5 | (internal_condition_case_2): New function. | ||
| 6 | |||
| 7 | * xdisp.c (safe_call): Use internal_condition_case_n. | ||
| 8 | |||
| 9 | * fileio.c (Fdelete_file, internal_delete_file): New arg FORCE. | ||
| 10 | (internal_delete_file, Frename_file): Callers changed. | ||
| 11 | |||
| 12 | * buffer.c (Fkill_buffer): | ||
| 13 | * callproc.c (delete_temp_file): Callers changed (Bug#6070). | ||
| 14 | |||
| 15 | * lisp.h: Update prototypes. | ||
| 16 | |||
| 1 | 2010-05-03 Glenn Morris <rgm@gnu.org> | 17 | 2010-05-03 Glenn Morris <rgm@gnu.org> |
| 2 | 18 | ||
| 3 | * Makefile.in (LIBX_EXTRA, LIBX_BASE): New variables. | 19 | * Makefile.in (LIBX_EXTRA, LIBX_BASE): New variables. |
diff --git a/src/buffer.c b/src/buffer.c index b19286c6ea9..339bc99dcb1 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1547,7 +1547,7 @@ with SIGHUP. */) | |||
| 1547 | Lisp_Object tem; | 1547 | Lisp_Object tem; |
| 1548 | tem = Fsymbol_value (intern ("delete-auto-save-files")); | 1548 | tem = Fsymbol_value (intern ("delete-auto-save-files")); |
| 1549 | if (! NILP (tem)) | 1549 | if (! NILP (tem)) |
| 1550 | internal_delete_file (b->auto_save_file_name); | 1550 | internal_delete_file (b->auto_save_file_name, Qt); |
| 1551 | } | 1551 | } |
| 1552 | 1552 | ||
| 1553 | if (b->base_buffer) | 1553 | if (b->base_buffer) |
diff --git a/src/callproc.c b/src/callproc.c index 378c647f385..317636d9cc8 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -856,7 +856,7 @@ delete_temp_file (name) | |||
| 856 | /* Suppress jka-compr handling, etc. */ | 856 | /* Suppress jka-compr handling, etc. */ |
| 857 | int count = SPECPDL_INDEX (); | 857 | int count = SPECPDL_INDEX (); |
| 858 | specbind (intern ("file-name-handler-alist"), Qnil); | 858 | specbind (intern ("file-name-handler-alist"), Qnil); |
| 859 | internal_delete_file (name); | 859 | internal_delete_file (name, Qt); |
| 860 | unbind_to (count, Qnil); | 860 | unbind_to (count, Qnil); |
| 861 | return Qnil; | 861 | return Qnil; |
| 862 | } | 862 | } |
diff --git a/src/eval.c b/src/eval.c index 120365f5f57..e1fb815719e 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -1563,12 +1563,61 @@ internal_condition_case_1 (bfun, arg, handlers, hfun) | |||
| 1563 | return val; | 1563 | return val; |
| 1564 | } | 1564 | } |
| 1565 | 1565 | ||
| 1566 | /* Like internal_condition_case_1 but call BFUN with ARG1 and ARG2 as | ||
| 1567 | its arguments. */ | ||
| 1568 | |||
| 1569 | Lisp_Object | ||
| 1570 | internal_condition_case_2 (bfun, arg1, arg2, handlers, hfun) | ||
| 1571 | Lisp_Object (*bfun) (); | ||
| 1572 | Lisp_Object arg1; | ||
| 1573 | Lisp_Object arg2; | ||
| 1574 | Lisp_Object handlers; | ||
| 1575 | Lisp_Object (*hfun) (); | ||
| 1576 | { | ||
| 1577 | Lisp_Object val; | ||
| 1578 | struct catchtag c; | ||
| 1579 | struct handler h; | ||
| 1580 | |||
| 1581 | /* Since Fsignal will close off all calls to x_catch_errors, | ||
| 1582 | we will get the wrong results if some are not closed now. */ | ||
| 1583 | #if HAVE_X_WINDOWS | ||
| 1584 | if (x_catching_errors ()) | ||
| 1585 | abort (); | ||
| 1586 | #endif | ||
| 1587 | |||
| 1588 | c.tag = Qnil; | ||
| 1589 | c.val = Qnil; | ||
| 1590 | c.backlist = backtrace_list; | ||
| 1591 | c.handlerlist = handlerlist; | ||
| 1592 | c.lisp_eval_depth = lisp_eval_depth; | ||
| 1593 | c.pdlcount = SPECPDL_INDEX (); | ||
| 1594 | c.poll_suppress_count = poll_suppress_count; | ||
| 1595 | c.interrupt_input_blocked = interrupt_input_blocked; | ||
| 1596 | c.gcpro = gcprolist; | ||
| 1597 | c.byte_stack = byte_stack_list; | ||
| 1598 | if (_setjmp (c.jmp)) | ||
| 1599 | { | ||
| 1600 | return (*hfun) (c.val); | ||
| 1601 | } | ||
| 1602 | c.next = catchlist; | ||
| 1603 | catchlist = &c; | ||
| 1604 | h.handler = handlers; | ||
| 1605 | h.var = Qnil; | ||
| 1606 | h.next = handlerlist; | ||
| 1607 | h.tag = &c; | ||
| 1608 | handlerlist = &h; | ||
| 1609 | |||
| 1610 | val = (*bfun) (arg1, arg2); | ||
| 1611 | catchlist = c.next; | ||
| 1612 | handlerlist = h.next; | ||
| 1613 | return val; | ||
| 1614 | } | ||
| 1566 | 1615 | ||
| 1567 | /* Like internal_condition_case but call BFUN with NARGS as first, | 1616 | /* Like internal_condition_case but call BFUN with NARGS as first, |
| 1568 | and ARGS as second argument. */ | 1617 | and ARGS as second argument. */ |
| 1569 | 1618 | ||
| 1570 | Lisp_Object | 1619 | Lisp_Object |
| 1571 | internal_condition_case_2 (bfun, nargs, args, handlers, hfun) | 1620 | internal_condition_case_n (bfun, nargs, args, handlers, hfun) |
| 1572 | Lisp_Object (*bfun) (); | 1621 | Lisp_Object (*bfun) (); |
| 1573 | int nargs; | 1622 | int nargs; |
| 1574 | Lisp_Object *args; | 1623 | Lisp_Object *args; |
diff --git a/src/fileio.c b/src/fileio.c index 13825a54212..6e9ab6f2a1e 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2194,11 +2194,17 @@ DEFUN ("delete-directory-internal", Fdelete_directory_internal, | |||
| 2194 | return Qnil; | 2194 | return Qnil; |
| 2195 | } | 2195 | } |
| 2196 | 2196 | ||
| 2197 | DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 1, "fDelete file: ", | 2197 | DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 2, "fDelete file: \nP", |
| 2198 | doc: /* Delete file named FILENAME. If it is a symlink, remove the symlink. | 2198 | doc: /* Delete file named FILENAME. If it is a symlink, remove the symlink. |
| 2199 | If file has multiple names, it continues to exist with the other names. */) | 2199 | If file has multiple names, it continues to exist with the other names. |
| 2200 | (filename) | 2200 | |
| 2201 | If optional arg FORCE is non-nil, really delete the file regardless of | ||
| 2202 | `delete-by-moving-to-trash'. Otherwise, \"deleting\" actually moves | ||
| 2203 | it to the system's trash can if `delete-by-moving-to-trash' is non-nil. | ||
| 2204 | Interactively, FORCE is non-nil if called with a prefix arg. */) | ||
| 2205 | (filename, force) | ||
| 2201 | Lisp_Object filename; | 2206 | Lisp_Object filename; |
| 2207 | Lisp_Object force; | ||
| 2202 | { | 2208 | { |
| 2203 | Lisp_Object handler; | 2209 | Lisp_Object handler; |
| 2204 | Lisp_Object encoded_file; | 2210 | Lisp_Object encoded_file; |
| @@ -2217,7 +2223,7 @@ If file has multiple names, it continues to exist with the other names. */) | |||
| 2217 | if (!NILP (handler)) | 2223 | if (!NILP (handler)) |
| 2218 | return call2 (handler, Qdelete_file, filename); | 2224 | return call2 (handler, Qdelete_file, filename); |
| 2219 | 2225 | ||
| 2220 | if (delete_by_moving_to_trash) | 2226 | if (delete_by_moving_to_trash && NILP (force)) |
| 2221 | return call1 (Qmove_file_to_trash, filename); | 2227 | return call1 (Qmove_file_to_trash, filename); |
| 2222 | 2228 | ||
| 2223 | encoded_file = ENCODE_FILE (filename); | 2229 | encoded_file = ENCODE_FILE (filename); |
| @@ -2234,14 +2240,15 @@ internal_delete_file_1 (ignore) | |||
| 2234 | return Qt; | 2240 | return Qt; |
| 2235 | } | 2241 | } |
| 2236 | 2242 | ||
| 2237 | /* Delete file FILENAME, returning 1 if successful and 0 if failed. */ | 2243 | /* Delete file FILENAME, returning 1 if successful and 0 if failed. |
| 2244 | FORCE means to ignore `delete-by-moving-to-trash'. */ | ||
| 2238 | 2245 | ||
| 2239 | int | 2246 | int |
| 2240 | internal_delete_file (filename) | 2247 | internal_delete_file (Lisp_Object filename, Lisp_Object force) |
| 2241 | Lisp_Object filename; | ||
| 2242 | { | 2248 | { |
| 2243 | Lisp_Object tem; | 2249 | Lisp_Object tem; |
| 2244 | tem = internal_condition_case_1 (Fdelete_file, filename, | 2250 | |
| 2251 | tem = internal_condition_case_2 (Fdelete_file, filename, force, | ||
| 2245 | Qt, internal_delete_file_1); | 2252 | Qt, internal_delete_file_1); |
| 2246 | return NILP (tem); | 2253 | return NILP (tem); |
| 2247 | } | 2254 | } |
| @@ -2335,7 +2342,7 @@ This is what happens in interactive use with M-x. */) | |||
| 2335 | ) | 2342 | ) |
| 2336 | call2 (Qdelete_directory, file, Qt); | 2343 | call2 (Qdelete_directory, file, Qt); |
| 2337 | else | 2344 | else |
| 2338 | Fdelete_file (file); | 2345 | Fdelete_file (file, Qt); |
| 2339 | unbind_to (count, Qnil); | 2346 | unbind_to (count, Qnil); |
| 2340 | } | 2347 | } |
| 2341 | else | 2348 | else |
diff --git a/src/lisp.h b/src/lisp.h index 16953e20a04..d9d15c9245d 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2901,7 +2901,8 @@ extern Lisp_Object internal_catch P_ ((Lisp_Object, Lisp_Object (*) (Lisp_Object | |||
| 2901 | extern Lisp_Object internal_lisp_condition_case P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); | 2901 | extern Lisp_Object internal_lisp_condition_case P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); |
| 2902 | extern Lisp_Object internal_condition_case P_ ((Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object))); | 2902 | extern Lisp_Object internal_condition_case P_ ((Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object))); |
| 2903 | extern Lisp_Object internal_condition_case_1 P_ ((Lisp_Object (*) (Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object))); | 2903 | extern Lisp_Object internal_condition_case_1 P_ ((Lisp_Object (*) (Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object))); |
| 2904 | extern Lisp_Object internal_condition_case_2 P_ ((Lisp_Object (*) (int, Lisp_Object *), int, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object))); | 2904 | extern Lisp_Object internal_condition_case_2 P_ ((Lisp_Object (*) (Lisp_Object, Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object))); |
| 2905 | extern Lisp_Object internal_condition_case_n P_ ((Lisp_Object (*) (int, Lisp_Object *), int, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object))); | ||
| 2905 | extern void specbind P_ ((Lisp_Object, Lisp_Object)); | 2906 | extern void specbind P_ ((Lisp_Object, Lisp_Object)); |
| 2906 | extern void record_unwind_protect P_ ((Lisp_Object (*) (Lisp_Object), Lisp_Object)); | 2907 | extern void record_unwind_protect P_ ((Lisp_Object (*) (Lisp_Object), Lisp_Object)); |
| 2907 | extern Lisp_Object unbind_to P_ ((int, Lisp_Object)); | 2908 | extern Lisp_Object unbind_to P_ ((int, Lisp_Object)); |
| @@ -3059,7 +3060,7 @@ EXFUN (Ffile_executable_p, 1); | |||
| 3059 | EXFUN (Fread_file_name, 6); | 3060 | EXFUN (Fread_file_name, 6); |
| 3060 | extern Lisp_Object close_file_unwind P_ ((Lisp_Object)); | 3061 | extern Lisp_Object close_file_unwind P_ ((Lisp_Object)); |
| 3061 | extern void report_file_error P_ ((const char *, Lisp_Object)) NO_RETURN; | 3062 | extern void report_file_error P_ ((const char *, Lisp_Object)) NO_RETURN; |
| 3062 | extern int internal_delete_file P_ ((Lisp_Object)); | 3063 | extern int internal_delete_file P_ ((Lisp_Object, Lisp_Object)); |
| 3063 | extern void syms_of_fileio P_ ((void)); | 3064 | extern void syms_of_fileio P_ ((void)); |
| 3064 | extern Lisp_Object make_temp_name P_ ((Lisp_Object, int)); | 3065 | extern Lisp_Object make_temp_name P_ ((Lisp_Object, int)); |
| 3065 | EXFUN (Fmake_symbolic_link, 3); | 3066 | EXFUN (Fmake_symbolic_link, 3); |
diff --git a/src/xdisp.c b/src/xdisp.c index 6d906825d1e..1e16180f7c9 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -2451,7 +2451,7 @@ safe_call (nargs, args) | |||
| 2451 | specbind (Qinhibit_redisplay, Qt); | 2451 | specbind (Qinhibit_redisplay, Qt); |
| 2452 | /* Use Qt to ensure debugger does not run, | 2452 | /* Use Qt to ensure debugger does not run, |
| 2453 | so there is no possibility of wanting to redisplay. */ | 2453 | so there is no possibility of wanting to redisplay. */ |
| 2454 | val = internal_condition_case_2 (Ffuncall, nargs, args, Qt, | 2454 | val = internal_condition_case_n (Ffuncall, nargs, args, Qt, |
| 2455 | safe_eval_handler); | 2455 | safe_eval_handler); |
| 2456 | UNGCPRO; | 2456 | UNGCPRO; |
| 2457 | val = unbind_to (count, val); | 2457 | val = unbind_to (count, val); |