Mercurial > hg > xemacs-beta
comparison src/editfns.c @ 844:047d37eb70d7
[xemacs-hg @ 2002-05-16 13:30:23 by ben]
ui fixes for things that were bothering me
bytecode.c, editfns.c, lisp.h, lread.c: Fix save-restriction to use markers rather than pseudo-markers
(integers representing the amount of text on either side of the
region). That way, all inserts are handled correctly, not just
those inside old restriction.
Add buffer argument to save_restriction_save().
process.c: Clean up very dirty and kludgy code that outputs into a buffer --
use proper unwind protects, etc.
font-lock.c: Do save-restriction/widen around the function -- otherwise, incorrect
results will ensue when a buffer has been narrowed before a call to
e.g. `buffer-syntactic-context' -- something that happens quite often.
fileio.c: Look for a handler for make-temp-name.
window.c, winslots.h: Try to solve this annoying problem: have two frames displaying the
buffer, in different places; in one, temporarily switch away to
another buffer and then back -- and you've lost your position;
it's reset to the other one in the other frame. My current
solution involves window-level caches of buffers and points (also
a cache for window-start); when set-window-buffer is called, it
looks to see if the buffer was previously visited in the window,
and if so, uses the most recent point at that time. (It's a
marker, so it handles changes.)
#### Note: It could be argued that doing it on the frame level
would be better -- e.g. if you visit a buffer temporarily through
a grep, and then go back to that buffer, you presumably want the
grep's position rather than some previous position provided
everything was in the same frame, even though the grep was in
another window in the frame. However, doing it on the frame level
fails when you have two windows on the same frame. Perhaps we
keep both a window and a frame cache, and use the frame cache if
there are no other windows on the frame showing the buffer, else
the window's cache? This is probably something to be configurable
using a specifier. Suggestions please please please?
window.c: Clean up a bit code that deals with the annoyance of window-point
vs. point.
dialog.el: Function to ask a
multiple-choice question, automatically choosing a dialog box or
minibuffer representation as necessary. Generalized version of
yes-or-no-p, y-or-n-p.
files.el: Use get-user-response to ask "yes/no/diff" question when recovering.
"diff" means that a diff is displayed between the current file and the
autosave. (Converts/deconverts escape-quoted as necessary. No more
complaints from you, Mr. Turnbull!) One known problem: when a dialog
is used, it's modal, so you can't scroll the diff. Will fix soon.
lisp-mode.el: If we're filling a string, don't treat semicolon as a comment,
which would give very unfriendly results.
Uses `buffer-syntactic-context'.
simple.el: all changes back to the beginning. (Useful if you've saved the file
in the middle of the changes.)
simple.el: Add option kill-word-into-kill-ring, which controls whether words
deleted with kill-word, backward-kill-word, etc. are "cut" into the
kill ring, or "cleared" into nothingness. (My preference is the
latter, by far. I'd almost go so far as suggesting we make it the
default, as you can always select a word and then cut it if you want
it cut.)
menubar-items.el: Add option corresponding to kill-word-into-kill-ring.
author | ben |
---|---|
date | Thu, 16 May 2002 13:30:58 +0000 |
parents | 6728e641994e |
children | e7ee5f8bde58 |
comparison
equal
deleted
inserted
replaced
843:f46864126a0d | 844:047d37eb70d7 |
---|---|
2040 narrow_line_number_cache (buf); | 2040 narrow_line_number_cache (buf); |
2041 return Qnil; | 2041 return Qnil; |
2042 } | 2042 } |
2043 | 2043 |
2044 Lisp_Object | 2044 Lisp_Object |
2045 save_restriction_save (void) | 2045 save_restriction_save (struct buffer *buf) |
2046 { | 2046 { |
2047 Lisp_Object bottom, top; | 2047 Lisp_Object bottom = noseeum_make_marker (); |
2048 /* Note: I tried using markers here, but it does not win | 2048 Lisp_Object top = noseeum_make_marker (); |
2049 | |
2050 /* Formerly, this function remembered the amount of text on either side | |
2051 of the restricted area, in a halfway attempt to account for insertion -- | |
2052 it handles insertion inside the old restricted area, but not outside. | |
2053 The comment read: | |
2054 | |
2055 [[ Note: I tried using markers here, but it does not win | |
2049 because insertion at the end of the saved region | 2056 because insertion at the end of the saved region |
2050 does not advance mh and is considered "outside" the saved region. */ | 2057 does not advance mh and is considered "outside" the saved region. ]] |
2051 bottom = make_int (BUF_BEGV (current_buffer) - BUF_BEG (current_buffer)); | 2058 |
2052 top = make_int (BUF_Z (current_buffer) - BUF_ZV (current_buffer)); | 2059 But that was clearly before the advent of marker-insertion-type. --ben */ |
2053 | 2060 |
2054 return noseeum_cons (Fcurrent_buffer (), noseeum_cons (bottom, top)); | 2061 Fset_marker (bottom, make_int (BUF_BEGV (buf)), wrap_buffer (buf)); |
2062 Fset_marker (top, make_int (BUF_ZV (buf)), wrap_buffer (buf)); | |
2063 Fset_marker_insertion_type (top, Qt); | |
2064 | |
2065 return noseeum_cons (wrap_buffer (buf), noseeum_cons (bottom, top)); | |
2055 } | 2066 } |
2056 | 2067 |
2057 Lisp_Object | 2068 Lisp_Object |
2058 save_restriction_restore (Lisp_Object data) | 2069 save_restriction_restore (Lisp_Object data) |
2059 { | 2070 { |
2060 struct buffer *buf; | 2071 struct buffer *buf; |
2061 Charcount newhead, newtail; | 2072 Lisp_Object markers = XCDR (data); |
2062 Lisp_Object tem; | |
2063 int local_clip_changed = 0; | 2073 int local_clip_changed = 0; |
2064 | 2074 |
2065 buf = XBUFFER (XCAR (data)); | 2075 buf = XBUFFER (XCAR (data)); |
2066 if (!BUFFER_LIVE_P (buf)) | 2076 /* someone could have killed the buffer in the meantime ... */ |
2067 { | 2077 if (BUFFER_LIVE_P (buf)) |
2068 /* someone could have killed the buffer in the meantime ... */ | 2078 { |
2069 free_cons (XCONS (XCDR (data))); | 2079 Charbpos start = marker_position (XCAR (markers)); |
2070 free_cons (XCONS (data)); | 2080 Charbpos end = marker_position (XCDR (markers)); |
2071 return Qnil; | 2081 Bytebpos byte_start = charbpos_to_bytebpos (buf, start); |
2072 } | 2082 Bytebpos byte_end = charbpos_to_bytebpos (buf, end); |
2073 tem = XCDR (data); | 2083 |
2074 newhead = XINT (XCAR (tem)); | 2084 if (BUF_BEGV (buf) != start) |
2075 newtail = XINT (XCDR (tem)); | 2085 { |
2076 | 2086 local_clip_changed = 1; |
2077 free_cons (XCONS (XCDR (data))); | 2087 SET_BOTH_BUF_BEGV (buf, start, byte_start); |
2088 narrow_line_number_cache (buf); | |
2089 } | |
2090 if (BUF_ZV (buf) != end) | |
2091 { | |
2092 local_clip_changed = 1; | |
2093 SET_BOTH_BUF_ZV (buf, end, byte_end); | |
2094 } | |
2095 | |
2096 if (local_clip_changed) | |
2097 MARK_CLIP_CHANGED; | |
2098 | |
2099 /* If point is outside the new visible range, move it inside. */ | |
2100 BUF_SET_PT (buf, charbpos_clip_to_bounds (BUF_BEGV (buf), BUF_PT (buf), | |
2101 BUF_ZV (buf))); | |
2102 } | |
2103 | |
2104 /* Free all the junk we allocated, so that a `save-restriction' comes | |
2105 for free in terms of GC junk. */ | |
2106 free_marker (XMARKER (XCAR (markers))); | |
2107 free_marker (XMARKER (XCDR (markers))); | |
2108 free_cons (XCONS (markers)); | |
2078 free_cons (XCONS (data)); | 2109 free_cons (XCONS (data)); |
2079 | |
2080 if (newhead + newtail > BUF_Z (buf) - BUF_BEG (buf)) | |
2081 { | |
2082 newhead = 0; | |
2083 newtail = 0; | |
2084 } | |
2085 | |
2086 { | |
2087 Charbpos start, end; | |
2088 Bytebpos byte_start, byte_end; | |
2089 | |
2090 start = BUF_BEG (buf) + newhead; | |
2091 end = BUF_Z (buf) - newtail; | |
2092 | |
2093 byte_start = charbpos_to_bytebpos (buf, start); | |
2094 byte_end = charbpos_to_bytebpos (buf, end); | |
2095 | |
2096 if (BUF_BEGV (buf) != start) | |
2097 { | |
2098 local_clip_changed = 1; | |
2099 SET_BOTH_BUF_BEGV (buf, start, byte_start); | |
2100 narrow_line_number_cache (buf); | |
2101 } | |
2102 if (BUF_ZV (buf) != end) | |
2103 { | |
2104 local_clip_changed = 1; | |
2105 SET_BOTH_BUF_ZV (buf, end, byte_end); | |
2106 } | |
2107 } | |
2108 if (local_clip_changed) | |
2109 MARK_CLIP_CHANGED; | |
2110 | |
2111 /* If point is outside the new visible range, move it inside. */ | |
2112 BUF_SET_PT (buf, | |
2113 charbpos_clip_to_bounds (BUF_BEGV (buf), | |
2114 BUF_PT (buf), | |
2115 BUF_ZV (buf))); | |
2116 | 2110 |
2117 return Qnil; | 2111 return Qnil; |
2118 } | 2112 } |
2119 | 2113 |
2120 DEFUN ("save-restriction", Fsave_restriction, 0, UNEVALLED, 0, /* | 2114 DEFUN ("save-restriction", Fsave_restriction, 0, UNEVALLED, 0, /* |
2127 The old restrictions settings are restored | 2121 The old restrictions settings are restored |
2128 even in case of abnormal exit (throw or error). | 2122 even in case of abnormal exit (throw or error). |
2129 | 2123 |
2130 The value returned is the value of the last form in BODY. | 2124 The value returned is the value of the last form in BODY. |
2131 | 2125 |
2132 `save-restriction' can get confused if, within the BODY, you widen | 2126 As of XEmacs 22.0, `save-restriction' correctly handles all modifications |
2133 and then make changes outside the area within the saved restrictions. | 2127 made within BODY. (Formerly, it got confused if, within the BODY, you |
2128 widened and then made changes outside the old restricted area.) | |
2134 | 2129 |
2135 Note: if you are using both `save-excursion' and `save-restriction', | 2130 Note: if you are using both `save-excursion' and `save-restriction', |
2136 use `save-excursion' outermost: | 2131 use `save-excursion' outermost: |
2137 (save-excursion (save-restriction ...)) | 2132 (save-excursion (save-restriction ...)) |
2138 */ | 2133 */ |
2139 (body)) | 2134 (body)) |
2140 { | 2135 { |
2141 /* This function can GC */ | 2136 /* This function can GC */ |
2142 int speccount = specpdl_depth (); | 2137 int speccount = |
2143 | 2138 record_unwind_protect (save_restriction_restore, |
2144 record_unwind_protect (save_restriction_restore, save_restriction_save ()); | 2139 save_restriction_save (current_buffer)); |
2145 | 2140 |
2146 return unbind_to_1 (speccount, Fprogn (body)); | 2141 return unbind_to_1 (speccount, Fprogn (body)); |
2147 } | 2142 } |
2148 | 2143 |
2149 | 2144 |