From ad22b7f7c16aa6c26df6ec1e1c192dde2e1b0cce Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Sat, 12 Mar 2011 20:44:42 +0100 Subject: [PATCH 1/7] lisp/avoid.el: Fix typos in docstrings. --- lisp/ChangeLog | 6 ++++++ lisp/avoid.el | 15 +++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b232ea61ee8..29b47595eb6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2011-03-12 Juanma Barranquero + + * avoid.el (mouse-avoidance-mode, mouse-avoidance-nudge-dist) + (mouse-avoidance-threshold, mouse-avoidance-banish-destination) + (mouse-avoidance-mode): Fix typos in docstrings. + 2011-03-12 Michael Albinus * net/tramp.el (tramp-progress-reporter-update): Use diff --git a/lisp/avoid.el b/lisp/avoid.el index 31833994323..c9c989b2ab9 100644 --- a/lisp/avoid.el +++ b/lisp/avoid.el @@ -77,7 +77,7 @@ ;;;###autoload (defcustom mouse-avoidance-mode nil - "Activate mouse avoidance mode. + "Activate Mouse Avoidance mode. See function `mouse-avoidance-mode' for possible values. Setting this variable directly does not take effect; use either \\[customize] or the function `mouse-avoidance-mode'." @@ -86,8 +86,7 @@ use either \\[customize] or the function `mouse-avoidance-mode'." (mouse-avoidance-mode (or value 'none))) :initialize 'custom-initialize-default :type '(choice (const :tag "none" nil) (const banish) (const jump) - (const animate) (const exile) (const proteus) - ) + (const animate) (const exile) (const proteus)) :group 'avoid :require 'avoid :version "20.3") @@ -95,7 +94,7 @@ use either \\[customize] or the function `mouse-avoidance-mode'." (defcustom mouse-avoidance-nudge-dist 15 "Average distance that mouse will be moved when approached by cursor. -Only applies in Mouse-Avoidance mode `jump' and its derivatives. +Only applies in Mouse Avoidance mode `jump' and its derivatives. For best results make this larger than `mouse-avoidance-threshold'." :type 'integer :group 'avoid) @@ -113,7 +112,7 @@ For best results make this larger than `mouse-avoidance-threshold'." (defcustom mouse-avoidance-threshold 5 "Mouse-pointer's flight distance. If the cursor gets closer than this, the mouse pointer will move away. -Only applies in mouse-avoidance-modes `animate' and `jump'." +Only applies in Mouse Avoidance modes `animate' and `jump'." :type 'integer :group 'avoid) @@ -184,7 +183,7 @@ Acceptable distance is defined by `mouse-avoidance-threshold'." mouse-avoidance-threshold)))))) (defun mouse-avoidance-banish-destination () - "The position to which Mouse-Avoidance mode `banish' moves the mouse. + "The position to which Mouse Avoidance mode `banish' moves the mouse. You can redefine this if you want the mouse banished to a different corner." (let* ((pos (window-edges))) (cons (- (nth 2 pos) 2) @@ -332,7 +331,7 @@ redefine this function to suit your own tastes." ;;;###autoload (defun mouse-avoidance-mode (&optional mode) - "Set cursor avoidance mode to MODE. + "Set Mouse Avoidance mode to MODE. MODE should be one of the symbols `banish', `exile', `jump', `animate', `cat-and-mouse', `proteus', or `none'. @@ -352,7 +351,7 @@ Effects of the different modes: Whenever the mouse is moved, the frame is also raised. -\(see `mouse-avoidance-threshold' for definition of \"too close\", +\(See `mouse-avoidance-threshold' for definition of \"too close\", and `mouse-avoidance-nudge-dist' and `mouse-avoidance-nudge-var' for definition of \"random distance\".)" (interactive From 46dcfee46cb241a0f8e34da679ca8b42e8ee8d46 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sun, 13 Mar 2011 18:36:47 -0400 Subject: [PATCH 2/7] Backport 2011-03-06T01:42:13Z!rgm@gnu.org from trunk. * configure.in (FREETYPE_LIBS): Actually set it to something. * configure.in: Don't zero-out FONTCONFIG_CFLAGS and FONTCONFIG_LIBS when building with XFT (doing so is incorrect, as Emacs directly uses fontconfig, and breaks building when using a strict linker). --- ChangeLog | 11 +++++++++++ configure.in | 26 +++++++++++++------------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b3dcc3af64..b45615d4317 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-03-13 Glenn Morris + + * configure.in (FREETYPE_LIBS): Actually set it to something. + +2011-03-13 Miles Bader + + * configure.in: Don't zero-out FONTCONFIG_CFLAGS and + FONTCONFIG_LIBS when building with XFT (doing so is incorrect, as + Emacs directly uses fontconfig, and breaks building when using a + strict linker). + 2011-03-07 Chong Yidong * Version 23.3 released. diff --git a/configure.in b/configure.in index cfb2a2eb7dc..bc83bc6d703 100644 --- a/configure.in +++ b/configure.in @@ -2034,21 +2034,21 @@ if test "${HAVE_X11}" = "yes"; then fi # "$HAVE_XFT" != no fi # "x${with_xft}" != "xno" - dnl For the "Does Emacs use" message at the end. - if test "$HAVE_XFT" != "yes"; then - HAVE_XFT=no - fi - - - HAVE_FREETYPE=no ## We used to allow building with FreeType and without Xft. ## However, the ftx font backend driver is not in good shape. - if test "${HAVE_XFT}" = "yes"; then - dnl As we use Xft, we anyway use freetype. - dnl There's no need for additional CFLAGS and LIBS. - HAVE_FREETYPE=yes - FONTCONFIG_CFLAGS= - FONTCONFIG_LIBS= + if test "$HAVE_XFT" != "yes"; then + dnl For the "Does Emacs use" message at the end. + HAVE_XFT=no + HAVE_FREETYPE=no + else + dnl Strict linkers fail with + dnl ftfont.o: undefined reference to symbol 'FT_New_Face' + dnl if -lfreetype is not specified. + dnl The following is needed to set FREETYPE_LIBS. + PKG_CHECK_MODULES(FREETYPE, freetype2, HAVE_FREETYPE=yes, + HAVE_FREETYPE=no) + + test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires libfreetype) fi HAVE_LIBOTF=no From e6ce307c50e6413f1ba87a315e0f8beb1a8ddac8 Mon Sep 17 00:00:00 2001 From: Ralph Schleicher Date: Wed, 16 Mar 2011 01:00:58 +0100 Subject: [PATCH 3/7] lisp/info.el: Fix bug#8258. * info (info-initialize): Replace all uses of `:' with path-separator for compatibility with non-Unix systems. Cache quoting of path-separator. --- lisp/ChangeLog | 6 ++++++ lisp/info.el | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 29b47595eb6..5bd208ba3c8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2011-03-15 Ralph Schleicher + + * info.el (info-initialize): Replace all uses of `:' with + path-separator for compatibility with non-Unix systems. + Cache quoting of path-separator. (Bug#8258) + 2011-03-12 Juanma Barranquero * avoid.el (mouse-avoidance-mode, mouse-avoidance-nudge-dist) diff --git a/lisp/info.el b/lisp/info.el index c6e20f827c1..8fd0fc70096 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -588,15 +588,15 @@ in `Info-file-supports-index-cookies-list'." (defun info-initialize () "Initialize `Info-directory-list', if that hasn't been done yet." (unless Info-directory-list - (let ((path (getenv "INFOPATH"))) + (let ((path (getenv "INFOPATH")) + (sep (regexp-quote path-separator))) (setq Info-directory-list (prune-directory-list (if path - (if (string-match ":\\'" path) - (append (split-string (substring path 0 -1) - (regexp-quote path-separator)) + (if (string-match-p (concat sep "\\'") path) + (append (split-string (substring path 0 -1) sep) (Info-default-dirs)) - (split-string path (regexp-quote path-separator))) + (split-string path sep)) (Info-default-dirs))))))) ;;;###autoload From e4021ec1d72e0493b9f80230a9324c06d0579581 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 16 Mar 2011 10:54:21 -0400 Subject: [PATCH 4/7] * strings.texi (String Conversion): Don't mention string-make-(uni|multi)byte. * nonascii.texi (Converting Representations): Fix up range. * keymaps.texi (Key Binding Commands): Update code point, avoid "unibyte character" and remove mention of unibyte bindings. Fixes: debbugs:8262 --- doc/lispref/ChangeLog | 8 ++++++++ doc/lispref/keymaps.texi | 14 +++++--------- doc/lispref/nonascii.texi | 2 +- doc/lispref/strings.texi | 4 ++-- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index a52a8e73dd1..90a1d24ce04 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,11 @@ +2011-03-16 Stefan Monnier + + * strings.texi (String Conversion): Don't mention + string-make-(uni|multi)byte (bug#8262). + * nonascii.texi (Converting Representations): Fix up range. + * keymaps.texi (Key Binding Commands): Update code point, avoid + "unibyte character" and remove mention of unibyte bindings. + 2011-03-07 Chong Yidong * Version 23.3 released. diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi index bc1937442f8..1d485ab67ba 100644 --- a/doc/lispref/keymaps.texi +++ b/doc/lispref/keymaps.texi @@ -1707,15 +1707,11 @@ or @noindent and your language environment is multibyte Latin-1, these commands -actually bind the multibyte character with code 2294, not the unibyte -Latin-1 character with code 246 (@kbd{M-v}). In order to use this -binding, you need to enter the multibyte Latin-1 character as keyboard -input. One way to do this is by using an appropriate input method -(@pxref{Input Methods, , Input Methods, emacs, The GNU Emacs Manual}). - - If you want to use a unibyte character in the key binding, you can -construct the key sequence string using @code{multibyte-char-to-unibyte} -or @code{string-make-unibyte} (@pxref{Converting Representations}). +actually bind the multibyte character with code 246, not the byte +code 246 (@kbd{M-v}) sent by a Latin-1 terminal. In order to use this +binding, you need to teach Emacs how to decode the keyboard by using an +appropriate input method (@pxref{Input Methods, , Input Methods, emacs, The GNU +Emacs Manual}). @deffn Command global-set-key key binding This function sets the binding of @var{key} in the current global map diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi index cb075e10a94..3093613ccaa 100644 --- a/doc/lispref/nonascii.texi +++ b/doc/lispref/nonascii.texi @@ -171,7 +171,7 @@ acceptable because the buffer's representation is a choice made by the user that cannot be overridden automatically. Converting unibyte text to multibyte text leaves @acronym{ASCII} -characters unchanged, and converts bytes with codes 128 through 159 to +characters unchanged, and converts bytes with codes 128 through 255 to the multibyte representation of raw eight-bit bytes. Converting multibyte text to unibyte converts all @acronym{ASCII} diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi index bb550346e9d..925c92050e4 100644 --- a/doc/lispref/strings.texi +++ b/doc/lispref/strings.texi @@ -555,8 +555,8 @@ strings and integers. @code{format} (@pxref{Formatting Strings}) and @code{prin1-to-string} (@pxref{Output Functions}) can also convert Lisp objects into strings. @code{read-from-string} (@pxref{Input Functions}) can ``convert'' a string representation of a Lisp object -into an object. The functions @code{string-make-multibyte} and -@code{string-make-unibyte} convert the text representation of a string +into an object. The functions @code{string-to-multibyte} and +@code{string-to-unibyte} convert the text representation of a string (@pxref{Converting Representations}). @xref{Documentation}, for functions that produce textual descriptions From 45763476fcc967a750bb2abe3bd7a43b7a19e537 Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Thu, 17 Mar 2011 16:44:02 +0100 Subject: [PATCH 5/7] src/xfaces.c (Fx_load_color_file): Read color file from absolute filename. Fixes: debbugs:8250 --- src/ChangeLog | 5 +++++ src/xfaces.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 75958169951..49b37a843b6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2011-03-17 Juanma Barranquero + + * xfaces.c (Fx_load_color_file): + Read color file from absolute filename (bug#8250). + 2011-03-11 Juanma Barranquero Backport revno:103582 from trunk. diff --git a/src/xfaces.c b/src/xfaces.c index e9e677d1b19..9956ef55842 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -6625,7 +6625,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */) CHECK_STRING (filename); abspath = Fexpand_file_name (filename, Qnil); - fp = fopen (SDATA (filename), "rt"); + fp = fopen (SDATA (abspath), "rt"); if (fp) { char buf[512]; From 576bce32675146e772183647c4750c1f5f9b7de7 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 19 Mar 2011 11:30:56 +0200 Subject: [PATCH 6/7] Fix emerge.el on MS-Windows and MS-DOS. lisp/emerge.el (emerge-metachars): Separate value for ms-dos and windows-nt systems. (emerge-protect-metachars): Quote correctly for ms-dos and windows-nt systems. --- lisp/ChangeLog | 7 +++++++ lisp/emerge.el | 23 ++++++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5bd208ba3c8..602b60c6aac 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2011-03-19 Eli Zaretskii + + * emerge.el (emerge-metachars): Separate value for ms-dos and + windows-nt systems. + (emerge-protect-metachars): Quote correctly for ms-dos and + windows-nt systems. + 2011-03-15 Ralph Schleicher * info.el (info-initialize): Replace all uses of `:' with diff --git a/lisp/emerge.el b/lisp/emerge.el index 997077aa08f..ffae5529e1c 100644 --- a/lisp/emerge.el +++ b/lisp/emerge.el @@ -3187,21 +3187,26 @@ See also `auto-save-file-name-p'." ;; Metacharacters that have to be protected from the shell when executing ;; a diff/diff3 command. -(defcustom emerge-metachars "[ \t\n!\"#$&'()*;<=>?[\\^`{|~]" - "Characters that must be quoted with \\ when used in a shell command line. +(defcustom emerge-metachars + (if (memq system-type '(ms-dos windows-nt)) + "[ \t\"<>|?*^&=]" + "[ \t\n!\"#$&'()*;<=>?[\\^`{|~]") + "Characters that must be quoted when used in a shell command line. More precisely, a [...] regexp to match any one such character." :type 'regexp :group 'emerge) ;; Quote metacharacters (using \) when executing a diff/diff3 command. (defun emerge-protect-metachars (s) - (let ((limit 0)) - (while (string-match emerge-metachars s limit) - (setq s (concat (substring s 0 (match-beginning 0)) - "\\" - (substring s (match-beginning 0)))) - (setq limit (1+ (match-end 0))))) - s) + (if (memq system-type '(ms-dos windows-nt)) + (shell-quote-argument s) + (let ((limit 0)) + (while (string-match emerge-metachars s limit) + (setq s (concat (substring s 0 (match-beginning 0)) + "\\" + (substring s (match-beginning 0)))) + (setq limit (1+ (match-end 0))))) + s)) (provide 'emerge) From 20f5695598d3137257e24802479d003ea82eb5f9 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sat, 19 Mar 2011 12:42:53 -0400 Subject: [PATCH 7/7] Backport fix for Bug#8219 from trunk. * buffer.h (BUF_BEGV, BUF_BEGV_BYTE, BUF_ZV, BUF_ZV_BYTE, BUF_PT) (BUF_PT_BYTE): Rewrite to handle indirect buffers (Bug#8219). These macros can no longer be used for assignment. * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): Assign struct members directly, instead of using BUF_BEGV etc. (record_buffer_markers, fetch_buffer_markers): New functions for recording and fetching special buffer markers. (set_buffer_internal_1, set_buffer_temp): Use them. * lread.c (unreadchar): Use SET_BUF_PT_BOTH. * insdel.c (adjust_point): Use SET_BUF_PT_BOTH. * intervals.c (temp_set_point_both): Use SET_BUF_PT_BOTH. (get_local_map): Use SET_BUF_BEGV_BOTH and SET_BUF_ZV_BOTH. * xdisp.c (hscroll_window_tree): (reconsider_clip_changes): Use PT instead of BUF_PT. --- src/ChangeLog | 22 ++++++ src/buffer.c | 187 +++++++++++++++++++++--------------------------- src/buffer.h | 42 ++++++++--- src/insdel.c | 4 +- src/intervals.c | 16 ++--- src/lread.c | 6 +- src/xdisp.c | 4 +- 7 files changed, 148 insertions(+), 133 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 49b37a843b6..be81dd27584 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,25 @@ +2011-03-19 Chong Yidong + + * buffer.h (BUF_BEGV, BUF_BEGV_BYTE, BUF_ZV, BUF_ZV_BYTE, BUF_PT) + (BUF_PT_BYTE): Rewrite to handle indirect buffers (Bug#8219). + These macros can no longer be used for assignment. + + * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): Assign + struct members directly, instead of using BUF_BEGV etc. + (record_buffer_markers, fetch_buffer_markers): New functions for + recording and fetching special buffer markers. + (set_buffer_internal_1, set_buffer_temp): Use them. + + * lread.c (unreadchar): Use SET_BUF_PT_BOTH. + + * insdel.c (adjust_point): Use SET_BUF_PT_BOTH. + + * intervals.c (temp_set_point_both): Use SET_BUF_PT_BOTH. + (get_local_map): Use SET_BUF_BEGV_BOTH and SET_BUF_ZV_BOTH. + + * xdisp.c (hscroll_window_tree): + (reconsider_clip_changes): Use PT instead of BUF_PT. + 2011-03-17 Juanma Barranquero * xfaces.c (Fx_load_color_file): diff --git a/src/buffer.c b/src/buffer.c index 9220527313d..e7759cb5255 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -371,15 +371,17 @@ even if it is dead. The return value is never nil. */) if (! BUF_BEG_ADDR (b)) buffer_memory_full (); - BUF_PT (b) = BEG; + b->pt = BEG; + b->begv = BEG; + b->zv = BEG; + b->pt_byte = BEG_BYTE; + b->begv_byte = BEG_BYTE; + b->zv_byte = BEG_BYTE; + BUF_GPT (b) = BEG; - BUF_BEGV (b) = BEG; - BUF_ZV (b) = BEG; - BUF_Z (b) = BEG; - BUF_PT_BYTE (b) = BEG_BYTE; BUF_GPT_BYTE (b) = BEG_BYTE; - BUF_BEGV_BYTE (b) = BEG_BYTE; - BUF_ZV_BYTE (b) = BEG_BYTE; + + BUF_Z (b) = BEG; BUF_Z_BYTE (b) = BEG_BYTE; BUF_MODIFF (b) = 1; BUF_CHARS_MODIFF (b) = 1; @@ -533,6 +535,53 @@ clone_per_buffer_values (from, to) to->local_var_alist = buffer_lisp_local_variables (from); } + +/* If buffer B has markers to record PT, BEGV and ZV when it is not + current, update these markers. */ + +static void +record_buffer_markers (struct buffer *b) +{ + if (! NILP (b->pt_marker)) + { + Lisp_Object buffer; + + eassert (!NILP (b->begv_marker)); + eassert (!NILP (b->zv_marker)); + + XSETBUFFER (buffer, b); + set_marker_both (b->pt_marker, buffer, b->pt, b->pt_byte); + set_marker_both (b->begv_marker, buffer, b->begv, b->begv_byte); + set_marker_both (b->zv_marker, buffer, b->zv, b->zv_byte); + } +} + + +/* If buffer B has markers to record PT, BEGV and ZV when it is not + current, fetch these values into B->begv etc. */ + +static void +fetch_buffer_markers (struct buffer *b) +{ + if (! NILP (b->pt_marker)) + { + Lisp_Object m; + + eassert (!NILP (b->begv_marker)); + eassert (!NILP (b->zv_marker)); + + m = b->pt_marker; + SET_BUF_PT_BOTH (b, marker_position (m), marker_byte_position (m)); + + m = b->begv_marker; + SET_BUF_BEGV_BOTH (b, marker_position (m), marker_byte_position (m)); + + m = b->zv_marker; + SET_BUF_ZV_BOTH (b, marker_position (m), marker_byte_position (m)); + } +} + + DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, Smake_indirect_buffer, 2, 3, "bMake indirect buffer (to buffer): \nBName of indirect buffer: ", @@ -572,12 +621,12 @@ CLONE nil means the indirect buffer's state is reset to default values. */) /* Use the base buffer's text object. */ b->text = b->base_buffer->text; - BUF_BEGV (b) = BUF_BEGV (b->base_buffer); - BUF_ZV (b) = BUF_ZV (b->base_buffer); - BUF_PT (b) = BUF_PT (b->base_buffer); - BUF_BEGV_BYTE (b) = BUF_BEGV_BYTE (b->base_buffer); - BUF_ZV_BYTE (b) = BUF_ZV_BYTE (b->base_buffer); - BUF_PT_BYTE (b) = BUF_PT_BYTE (b->base_buffer); + b->pt = b->base_buffer->pt; + b->begv = b->base_buffer->begv; + b->zv = b->base_buffer->zv; + b->pt_byte = b->base_buffer->pt_byte; + b->begv_byte = b->base_buffer->begv_byte; + b->zv_byte = b->base_buffer->zv_byte; b->newline_cache = 0; b->width_run_cache = 0; @@ -607,24 +656,23 @@ CLONE nil means the indirect buffer's state is reset to default values. */) /* Make sure the base buffer has markers for its narrowing. */ if (NILP (b->base_buffer->pt_marker)) { + eassert (NILP (b->base_buffer->begv_marker)); + eassert (NILP (b->base_buffer->zv_marker)); + b->base_buffer->pt_marker = Fmake_marker (); set_marker_both (b->base_buffer->pt_marker, base_buffer, - BUF_PT (b->base_buffer), - BUF_PT_BYTE (b->base_buffer)); - } - if (NILP (b->base_buffer->begv_marker)) - { + b->base_buffer->pt, + b->base_buffer->pt_byte); + b->base_buffer->begv_marker = Fmake_marker (); set_marker_both (b->base_buffer->begv_marker, base_buffer, - BUF_BEGV (b->base_buffer), - BUF_BEGV_BYTE (b->base_buffer)); - } - if (NILP (b->base_buffer->zv_marker)) - { + b->base_buffer->begv, + b->base_buffer->begv_byte); + b->base_buffer->zv_marker = Fmake_marker (); set_marker_both (b->base_buffer->zv_marker, base_buffer, - BUF_ZV (b->base_buffer), - BUF_ZV_BYTE (b->base_buffer)); + b->base_buffer->zv, + b->base_buffer->zv_byte); XMARKER (b->base_buffer->zv_marker)->insertion_type = 1; } @@ -632,11 +680,11 @@ CLONE nil means the indirect buffer's state is reset to default values. */) { /* Give the indirect buffer markers for its narrowing. */ b->pt_marker = Fmake_marker (); - set_marker_both (b->pt_marker, buf, BUF_PT (b), BUF_PT_BYTE (b)); + set_marker_both (b->pt_marker, buf, b->pt, b->pt_byte); b->begv_marker = Fmake_marker (); - set_marker_both (b->begv_marker, buf, BUF_BEGV (b), BUF_BEGV_BYTE (b)); + set_marker_both (b->begv_marker, buf, b->begv, b->begv_byte); b->zv_marker = Fmake_marker (); - set_marker_both (b->zv_marker, buf, BUF_ZV (b), BUF_ZV_BYTE (b)); + set_marker_both (b->zv_marker, buf, b->zv, b->zv_byte); XMARKER (b->zv_marker)->insertion_type = 1; } else @@ -1890,27 +1938,7 @@ set_buffer_internal_1 (b) /* If the old current buffer has markers to record PT, BEGV and ZV when it is not current, update them now. */ - if (! NILP (old_buf->pt_marker)) - { - Lisp_Object obuf; - XSETBUFFER (obuf, old_buf); - set_marker_both (old_buf->pt_marker, obuf, - BUF_PT (old_buf), BUF_PT_BYTE (old_buf)); - } - if (! NILP (old_buf->begv_marker)) - { - Lisp_Object obuf; - XSETBUFFER (obuf, old_buf); - set_marker_both (old_buf->begv_marker, obuf, - BUF_BEGV (old_buf), BUF_BEGV_BYTE (old_buf)); - } - if (! NILP (old_buf->zv_marker)) - { - Lisp_Object obuf; - XSETBUFFER (obuf, old_buf); - set_marker_both (old_buf->zv_marker, obuf, - BUF_ZV (old_buf), BUF_ZV_BYTE (old_buf)); - } + record_buffer_markers (old_buf); } /* Get the undo list from the base buffer, so that it appears @@ -1920,21 +1948,7 @@ set_buffer_internal_1 (b) /* If the new current buffer has markers to record PT, BEGV and ZV when it is not current, fetch them now. */ - if (! NILP (b->pt_marker)) - { - BUF_PT (b) = marker_position (b->pt_marker); - BUF_PT_BYTE (b) = marker_byte_position (b->pt_marker); - } - if (! NILP (b->begv_marker)) - { - BUF_BEGV (b) = marker_position (b->begv_marker); - BUF_BEGV_BYTE (b) = marker_byte_position (b->begv_marker); - } - if (! NILP (b->zv_marker)) - { - BUF_ZV (b) = marker_position (b->zv_marker); - BUF_ZV_BYTE (b) = marker_byte_position (b->zv_marker); - } + fetch_buffer_markers (b); /* Look down buffer's list of local Lisp variables to find and update any that forward into C variables. */ @@ -1984,50 +1998,13 @@ set_buffer_temp (b) old_buf = current_buffer; current_buffer = b; - if (old_buf) - { - /* If the old current buffer has markers to record PT, BEGV and ZV - when it is not current, update them now. */ - if (! NILP (old_buf->pt_marker)) - { - Lisp_Object obuf; - XSETBUFFER (obuf, old_buf); - set_marker_both (old_buf->pt_marker, obuf, - BUF_PT (old_buf), BUF_PT_BYTE (old_buf)); - } - if (! NILP (old_buf->begv_marker)) - { - Lisp_Object obuf; - XSETBUFFER (obuf, old_buf); - set_marker_both (old_buf->begv_marker, obuf, - BUF_BEGV (old_buf), BUF_BEGV_BYTE (old_buf)); - } - if (! NILP (old_buf->zv_marker)) - { - Lisp_Object obuf; - XSETBUFFER (obuf, old_buf); - set_marker_both (old_buf->zv_marker, obuf, - BUF_ZV (old_buf), BUF_ZV_BYTE (old_buf)); - } - } + /* If the old current buffer has markers to record PT, BEGV and ZV + when it is not current, update them now. */ + record_buffer_markers (old_buf); /* If the new current buffer has markers to record PT, BEGV and ZV when it is not current, fetch them now. */ - if (! NILP (b->pt_marker)) - { - BUF_PT (b) = marker_position (b->pt_marker); - BUF_PT_BYTE (b) = marker_byte_position (b->pt_marker); - } - if (! NILP (b->begv_marker)) - { - BUF_BEGV (b) = marker_position (b->begv_marker); - BUF_BEGV_BYTE (b) = marker_byte_position (b->begv_marker); - } - if (! NILP (b->zv_marker)) - { - BUF_ZV (b) = marker_position (b->zv_marker); - BUF_ZV_BYTE (b) = marker_byte_position (b->zv_marker); - } + fetch_buffer_markers (b); } DEFUN ("set-buffer", Fset_buffer, Sset_buffer, 1, 1, 0, diff --git a/src/buffer.h b/src/buffer.h index 21854571670..56d0422b7e3 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -107,22 +107,46 @@ along with GNU Emacs. If not, see . */ #define BUF_BEG(buf) (BEG) #define BUF_BEG_BYTE(buf) (BEG_BYTE) +/* The BUF_BEGV[_BYTE], BUF_ZV[_BYTE], and BUF_PT[_BYTE] macros cannot + be used for assignment; use SET_BUF_* macros below for that. */ + /* Position of beginning of accessible range of buffer. */ -#define BUF_BEGV(buf) ((buf)->begv) -#define BUF_BEGV_BYTE(buf) ((buf)->begv_byte) +#define BUF_BEGV(buf) \ + (buf == current_buffer ? BEGV \ + : NILP (buf->begv_marker) ? buf->begv \ + : marker_position (buf->begv_marker)) + +#define BUF_BEGV_BYTE(buf) \ + (buf == current_buffer ? BEGV_BYTE \ + : NILP (buf->begv_marker) ? buf->begv_byte \ + : marker_byte_position (buf->begv_marker)) /* Position of point in buffer. */ -#define BUF_PT(buf) ((buf)->pt) -#define BUF_PT_BYTE(buf) ((buf)->pt_byte) +#define BUF_PT(buf) \ + (buf == current_buffer ? PT \ + : NILP (buf->pt_marker) ? buf->pt \ + : marker_position (buf->pt_marker)) + +#define BUF_PT_BYTE(buf) \ + (buf == current_buffer ? PT_BYTE \ + : NILP (buf->pt_marker) ? buf->pt_byte \ + : marker_byte_position (buf->pt_marker)) + +/* Position of end of accessible range of buffer. */ +#define BUF_ZV(buf) \ + (buf == current_buffer ? ZV \ + : NILP (buf->zv_marker) ? buf->zv \ + : marker_position (buf->zv_marker)) + +#define BUF_ZV_BYTE(buf) \ + (buf == current_buffer ? ZV_BYTE \ + : NILP (buf->zv_marker) ? buf->zv_byte \ + : marker_byte_position (buf->zv_marker)) /* Position of gap in buffer. */ #define BUF_GPT(buf) ((buf)->text->gpt) #define BUF_GPT_BYTE(buf) ((buf)->text->gpt_byte) -/* Position of end of accessible range of buffer. */ -#define BUF_ZV(buf) ((buf)->zv) -#define BUF_ZV_BYTE(buf) ((buf)->zv_byte) - /* Position of end of buffer. */ #define BUF_Z(buf) ((buf)->text->z) #define BUF_Z_BYTE(buf) ((buf)->text->z_byte) @@ -230,8 +254,6 @@ extern void enlarge_buffer_text P_ ((struct buffer *, EMACS_INT)); /* Macros for setting the BEGV, ZV or PT of a given buffer. - SET_BUF_PT* seet to be redundant. Get rid of them? - The ..._BOTH macros take both a charpos and a bytepos, which must correspond to each other. diff --git a/src/insdel.c b/src/insdel.c index 7e0ba797fa8..b76a2d2271a 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -459,9 +459,7 @@ adjust_markers_for_insert (EMACS_INT from, EMACS_INT from_byte, static void adjust_point (EMACS_INT nchars, EMACS_INT nbytes) { - BUF_PT (current_buffer) += nchars; - BUF_PT_BYTE (current_buffer) += nbytes; - + SET_BUF_PT_BOTH (current_buffer, PT + nchars, PT_BYTE + nbytes); /* In a single-byte buffer, the two positions must be equal. */ eassert (PT_BYTE >= PT && PT_BYTE - PT <= ZV_BYTE - ZV); } diff --git a/src/intervals.c b/src/intervals.c index d47888b237c..fd8f3f55479 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -1949,8 +1949,7 @@ temp_set_point_both (struct buffer *buffer, if (charpos > BUF_ZV (buffer) || charpos < BUF_BEGV (buffer)) abort (); - BUF_PT_BYTE (buffer) = bytepos; - BUF_PT (buffer) = charpos; + SET_BUF_PT_BOTH (buffer, charpos, bytepos); } /* Set point in BUFFER to CHARPOS. If the target position is @@ -2366,10 +2365,9 @@ get_local_map (position, buffer, type) old_zv = BUF_ZV (buffer); old_begv_byte = BUF_BEGV_BYTE (buffer); old_zv_byte = BUF_ZV_BYTE (buffer); - BUF_BEGV (buffer) = BUF_BEG (buffer); - BUF_ZV (buffer) = BUF_Z (buffer); - BUF_BEGV_BYTE (buffer) = BUF_BEG_BYTE (buffer); - BUF_ZV_BYTE (buffer) = BUF_Z_BYTE (buffer); + + SET_BUF_BEGV_BOTH (buffer, BUF_BEG (buffer), BUF_BEG_BYTE (buffer)); + SET_BUF_ZV_BOTH (buffer, BUF_Z (buffer), BUF_Z_BYTE (buffer)); XSETFASTINT (lispy_position, position); XSETBUFFER (lispy_buffer, buffer); @@ -2383,10 +2381,8 @@ get_local_map (position, buffer, type) if (NILP (prop)) prop = get_pos_property (lispy_position, type, lispy_buffer); - BUF_BEGV (buffer) = old_begv; - BUF_ZV (buffer) = old_zv; - BUF_BEGV_BYTE (buffer) = old_begv_byte; - BUF_ZV_BYTE (buffer) = old_zv_byte; + SET_BUF_BEGV_BOTH (buffer, old_begv, old_begv_byte); + SET_BUF_ZV_BOTH (buffer, old_zv, old_zv_byte); /* Use the local map only if it is valid. */ prop = get_keymap (prop, 0, 0); diff --git a/src/lread.c b/src/lread.c index 8f1d4af8f36..2da64632417 100644 --- a/src/lread.c +++ b/src/lread.c @@ -458,15 +458,15 @@ unreadchar (readcharfun, c) else if (BUFFERP (readcharfun)) { struct buffer *b = XBUFFER (readcharfun); - int bytepos = BUF_PT_BYTE (b); + EMACS_INT charpos = BUF_PT (b); + EMACS_INT bytepos = BUF_PT_BYTE (b); - BUF_PT (b)--; if (! NILP (b->enable_multibyte_characters)) BUF_DEC_POS (b, bytepos); else bytepos--; - BUF_PT_BYTE (b) = bytepos; + SET_BUF_PT_BOTH (b, charpos - 1, bytepos); } else if (MARKERP (readcharfun)) { diff --git a/src/xdisp.c b/src/xdisp.c index c2af4d68b6e..ade95cf3d62 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10760,7 +10760,7 @@ hscroll_window_tree (window) current_buffer = XBUFFER (w->buffer); if (w == XWINDOW (selected_window)) - pt = BUF_PT (current_buffer); + pt = PT; else { pt = marker_position (w->pointm); @@ -11194,7 +11194,7 @@ reconsider_clip_changes (w, b) int pt; if (w == XWINDOW (selected_window)) - pt = BUF_PT (current_buffer); + pt = PT; else pt = marker_position (w->pointm);