summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autogen/Makefile.in1
-rw-r--r--autogen/config.in6
-rwxr-xr-xautogen/configure131
-rw-r--r--lisp/ChangeLog19
-rw-r--r--lisp/emacs-lisp/cl-loaddefs.el2
-rw-r--r--lisp/emacs-lisp/cl-macs.el38
-rw-r--r--lisp/help-fns.el11
-rw-r--r--lisp/progmodes/js.el10
-rw-r--r--lisp/window.el20
-rw-r--r--src/ChangeLog28
-rw-r--r--src/bidi.c75
-rw-r--r--src/dispextern.h2
-rw-r--r--src/dispnew.c2
-rw-r--r--src/indent.c2
-rw-r--r--src/window.c18
-rw-r--r--src/xdisp.c74
16 files changed, 272 insertions, 167 deletions
diff --git a/autogen/Makefile.in b/autogen/Makefile.in
index 3348d3a4c0..5b28ad0808 100644
--- a/autogen/Makefile.in
+++ b/autogen/Makefile.in
@@ -495,6 +495,7 @@ LIBXT_OTHER = @LIBXT_OTHER@
LIBX_OTHER = @LIBX_OTHER@
LIB_GCC = @LIB_GCC@
LIB_MATH = @LIB_MATH@
+LIB_PTHREAD = @LIB_PTHREAD@
LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@
LIB_STANDARD = @LIB_STANDARD@
LTLIBINTL = @LTLIBINTL@
diff --git a/autogen/config.in b/autogen/config.in
index d4ec03b834..ca44b80c91 100644
--- a/autogen/config.in
+++ b/autogen/config.in
@@ -321,9 +321,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the `gtk_adjustment_get_page_size' function. */
#undef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE
-/* Define to 1 if you have GTK and pthread (-lpthread). */
-#undef HAVE_GTK_AND_PTHREAD
-
/* Define to 1 if you have the `gtk_dialog_get_action_area' function. */
#undef HAVE_GTK_DIALOG_GET_ACTION_AREA
@@ -582,6 +579,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the `pstat_getdynamic' function. */
#undef HAVE_PSTAT_GETDYNAMIC
+/* Define to 1 if you have pthread (-lpthread). */
+#undef HAVE_PTHREAD
+
/* Define to 1 if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H
diff --git a/autogen/configure b/autogen/configure
index 074850731b..351937c35a 100755
--- a/autogen/configure
+++ b/autogen/configure
@@ -1139,6 +1139,7 @@ IMAGEMAGICK_LIBS
IMAGEMAGICK_CFLAGS
RSVG_LIBS
RSVG_CFLAGS
+LIB_PTHREAD
VMLIMIT_OBJ
GMALLOC_OBJ
HAVE_XSERVER
@@ -9949,6 +9950,72 @@ if test "x$ac_cv_lib_Xbsd_main" = x""yes; then :
fi
+LIB_PTHREAD=
+for ac_header in pthread.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
+if test "x$ac_cv_header_pthread_h" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PTHREAD_H 1
+_ACEOF
+
+fi
+
+done
+
+if test "$ac_cv_header_pthread_h"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5
+$as_echo_n "checking for pthread_self in -lpthread... " >&6; }
+if test "${ac_cv_lib_pthread_pthread_self+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_self ();
+int
+main ()
+{
+return pthread_self ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_pthread_pthread_self=yes
+else
+ ac_cv_lib_pthread_pthread_self=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_self" >&5
+$as_echo "$ac_cv_lib_pthread_pthread_self" >&6; }
+if test "x$ac_cv_lib_pthread_pthread_self" = x""yes; then :
+ HAVE_PTHREAD=yes
+fi
+
+fi
+if test "$HAVE_PTHREAD" = yes; then
+ case "${canonical}" in
+ *-hpux*) ;;
+ *) LIB_PTHREAD="-lpthread" ;;
+ esac
+
+$as_echo "#define HAVE_PTHREAD 1" >>confdefs.h
+
+fi
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cma_open in -lpthreads" >&5
$as_echo_n "checking for cma_open in -lpthreads... " >&6; }
if test "${ac_cv_lib_pthreads_cma_open+set}" = set; then :
@@ -10774,70 +10841,6 @@ done
fi
- HAVE_GTK_AND_PTHREAD=no
- for ac_header in pthread.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
-if test "x$ac_cv_header_pthread_h" = x""yes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_PTHREAD_H 1
-_ACEOF
-
-fi
-
-done
-
- if test "$ac_cv_header_pthread_h"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5
-$as_echo_n "checking for pthread_self in -lpthread... " >&6; }
-if test "${ac_cv_lib_pthread_pthread_self+set}" = set; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpthread $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char pthread_self ();
-int
-main ()
-{
-return pthread_self ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_pthread_pthread_self=yes
-else
- ac_cv_lib_pthread_pthread_self=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_self" >&5
-$as_echo "$ac_cv_lib_pthread_pthread_self" >&6; }
-if test "x$ac_cv_lib_pthread_pthread_self" = x""yes; then :
- HAVE_GTK_AND_PTHREAD=yes
-fi
-
- fi
- if test "$HAVE_GTK_AND_PTHREAD" = yes; then
- case "${canonical}" in
- *-hpux*) ;;
- *) GTK_LIBS="$GTK_LIBS -lpthread" ;;
- esac
-
-$as_echo "#define HAVE_GTK_AND_PTHREAD 1" >>confdefs.h
-
- fi
for ac_func in gtk_widget_get_window gtk_widget_set_has_window \
gtk_dialog_get_action_area gtk_widget_get_sensitive \
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6a6abdf7e4..7c1fa3a656 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,22 @@
+2011-08-05 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * progmodes/js.el (js--regexp-literal): Accept regexps at the beginning
+ of statements and in a few more cases (bug#9183).
+
+ * emacs-lisp/cl-macs.el (cl--make-usage-var, cl--make-usage-args):
+ New functions.
+ (cl-transform-lambda): Use them (bug#9239).
+
+2011-08-05 Martin Rudalics <rudalics@gmx.at>
+
+ * window.el (display-buffer-same-window)
+ (display-buffer-same-frame, display-buffer-other-window)
+ (pop-to-buffer-same-window, pop-to-buffer-same-frame)
+ (pop-to-buffer-other-window)
+ (pop-to-buffer-same-frame-other-window)
+ (pop-to-buffer-other-frame): Make them defuns.
+ (switch-to-buffer): Don't set LABEL argument of pop-to-buffer.
+
2011-08-03 Stefan Monnier <monnier@iro.umontreal.ca>
* subr.el (make-composed-keymap): Move from C. Change calling
diff --git a/lisp/emacs-lisp/cl-loaddefs.el b/lisp/emacs-lisp/cl-loaddefs.el
index 4b9985380c..7beb4d4b4c 100644
--- a/lisp/emacs-lisp/cl-loaddefs.el
+++ b/lisp/emacs-lisp/cl-loaddefs.el
@@ -282,7 +282,7 @@ Not documented
;;;;;; flet progv psetq do-all-symbols do-symbols dotimes dolist
;;;;;; do* do loop return-from return block etypecase typecase ecase
;;;;;; case load-time-value eval-when destructuring-bind function*
-;;;;;; defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "21df83d6106cb0c3d037e75ad79359dc")
+;;;;;; defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "0907093f7720996444ededb4edfe8072")
;;; Generated autoloads from cl-macs.el
(autoload 'gensym "cl-macs" "\
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 6d242eda3a..fb19115287 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -238,6 +238,37 @@ It is a list of elements of the form either:
(declare-function help-add-fundoc-usage "help-fns" (docstring arglist))
+(defun cl--make-usage-var (x)
+ "X can be a var or a (destructuring) lambda-list."
+ (cond
+ ((symbolp x) (make-symbol (upcase (symbol-name x))))
+ ((consp x) (cl--make-usage-args x))
+ (t x)))
+
+(defun cl--make-usage-args (arglist)
+ ;; `orig-args' can contain &cl-defs (an internal
+ ;; CL thingy I don't understand), so remove it.
+ (let ((x (memq '&cl-defs arglist)))
+ (when x (setq arglist (delq (car x) (remq (cadr x) arglist)))))
+ (let ((state nil))
+ (mapcar (lambda (x)
+ (cond
+ ((symbolp x)
+ (if (eq ?\& (aref (symbol-name x) 0))
+ (setq state x)
+ (make-symbol (upcase (symbol-name x)))))
+ ((not (consp x)) x)
+ ((memq state '(nil &rest)) (cl--make-usage-args x))
+ (t ;(VAR INITFORM SVAR) or ((KEYWORD VAR) INITFORM SVAR).
+ (list*
+ (if (and (consp (car x)) (eq state '&key))
+ (list (caar x) (cl--make-usage-var (nth 1 (car x))))
+ (cl--make-usage-var (car x)))
+ (nth 1 x) ;INITFORM.
+ (cl--make-usage-args (nthcdr 2 x)) ;SVAR.
+ ))))
+ arglist)))
+
(defun cl-transform-lambda (form bind-block)
(let* ((args (car form)) (body (cdr form)) (orig-args args)
(bind-defs nil) (bind-enquote nil)
@@ -282,11 +313,8 @@ It is a list of elements of the form either:
(require 'help-fns)
(cons (help-add-fundoc-usage
(if (stringp (car hdr)) (pop hdr))
- ;; orig-args can contain &cl-defs (an internal
- ;; CL thingy I don't understand), so remove it.
- (let ((x (memq '&cl-defs orig-args)))
- (if (null x) orig-args
- (delq (car x) (remq (cadr x) orig-args)))))
+ (format "(fn %S)"
+ (cl--make-usage-args orig-args)))
hdr)))
(list (nconc (list 'let* bind-lets)
(nreverse bind-forms) body)))))))
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index b13e6a77d5..5e034b14fd 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -65,7 +65,9 @@
(defun help-split-fundoc (docstring def)
"Split a function DOCSTRING into the actual doc and the usage info.
-Return (USAGE . DOC) or nil if there's no usage info.
+Return (USAGE . DOC) or nil if there's no usage info, where USAGE info
+is a string describing the argument list of DEF, such as
+\"(apply FUNCTION &rest ARGUMENTS)\".
DEF is the function whose usage we're looking for in DOCSTRING."
;; Functions can get the calling sequence at the end of the doc string.
;; In cases where `function' has been fset to a subr we can't search for
@@ -156,12 +158,7 @@ the same names as used in the original source code, when possible."
(defun help-make-usage (function arglist)
(cons (if (symbolp function) function 'anonymous)
(mapcar (lambda (arg)
- (if (not (symbolp arg))
- (if (and (consp arg) (symbolp (car arg)))
- ;; CL style default values for optional args.
- (cons (intern (upcase (symbol-name (car arg))))
- (cdr arg))
- arg)
+ (if (not (symbolp arg)) arg
(let ((name (symbol-name arg)))
(cond
((string-match "\\`&" name) arg)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 1bdcb4cfa8..4abbe3b895 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1658,15 +1658,19 @@ This performs fontification according to `js--class-styles'."
;; below.
(eval-and-compile
(defconst js--regexp-literal
- "[=(,:]\\(?:\\s-\\|\n\\)*\\(/\\)\\(?:\\\\.\\|[^/*\\]\\)\\(?:\\\\.\\|[^/\\]\\)*\\(/\\)"
+ (concat
+ ;; We want to match regular expressions only at the beginning of
+ ;; expressions.
+ ;; FIXME: Should we also allow /regexp/ after infix operators such as +,
+ ;; /, -, *, >, ...?
+ "\\(?:\\`\\|[=([{,:;]\\)\\(?:\\s-\\|\n\\)*"
+ "\\(/\\)\\(?:\\\\.\\|[^/*\\]\\)\\(?:\\\\.\\|[^/\\]\\)*\\(/\\)")
"Regexp matching a JavaScript regular expression literal.
Match groups 1 and 2 are the characters forming the beginning and
end of the literal."))
(defconst js-syntax-propertize-function
(syntax-propertize-rules
- ;; We want to match regular expressions only at the beginning of
- ;; expressions.
(js--regexp-literal (1 "\"") (2 "\""))))
;;; Indentation
diff --git a/lisp/window.el b/lisp/window.el
index 215dbab784..7e666af6ab 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -5796,7 +5796,7 @@ this list as arguments."
;; regardless of graphic-only restrictions.
(display-buffer-pop-up-frame buffer)))))
-(defsubst display-buffer-same-window (&optional buffer-or-name label)
+(defun display-buffer-same-window (&optional buffer-or-name label)
"Display buffer specified by BUFFER-OR-NAME in the selected window.
Another window will be used only if the buffer can't be shown in
the selected window, usually because it is dedicated to another
@@ -5805,7 +5805,7 @@ buffer. Optional argument BUFFER-OR-NAME and LABEL are as for
(interactive "BDisplay buffer in same window:\nP")
(display-buffer buffer-or-name 'same-window label))
-(defsubst display-buffer-same-frame (&optional buffer-or-name label)
+(defun display-buffer-same-frame (&optional buffer-or-name label)
"Display buffer specified by BUFFER-OR-NAME in a window on the same frame.
Another frame will be used only if there is no other choice.
Optional argument BUFFER-OR-NAME and LABEL are as for
@@ -5813,7 +5813,7 @@ Optional argument BUFFER-OR-NAME and LABEL are as for
(interactive "BDisplay buffer on same frame:\nP")
(display-buffer buffer-or-name 'same-frame label))
-(defsubst display-buffer-other-window (&optional buffer-or-name label)
+(defun display-buffer-other-window (&optional buffer-or-name label)
"Display buffer specified by BUFFER-OR-NAME in another window.
The selected window will be used only if there is no other
choice. Windows on the selected frame are preferred to windows
@@ -5887,7 +5887,7 @@ additional information."
(select-frame-set-input-focus new-frame norecord))
buffer))
-(defsubst pop-to-buffer-same-window (&optional buffer-or-name norecord label)
+(defun pop-to-buffer-same-window (&optional buffer-or-name norecord label)
"Pop to buffer specified by BUFFER-OR-NAME in the selected window.
Another window will be used only if the buffer can't be shown in
the selected window, usually because it is dedicated to another
@@ -5896,7 +5896,7 @@ as for `pop-to-buffer'."
(interactive "BPop to buffer in selected window:\nP")
(pop-to-buffer buffer-or-name 'same-window norecord label))
-(defsubst pop-to-buffer-same-frame (&optional buffer-or-name norecord label)
+(defun pop-to-buffer-same-frame (&optional buffer-or-name norecord label)
"Pop to buffer specified by BUFFER-OR-NAME in a window on the selected frame.
Another frame will be used only if there is no other choice.
Optional arguments BUFFER-OR-NAME, NORECORD and LABEL are as for
@@ -5904,7 +5904,7 @@ Optional arguments BUFFER-OR-NAME, NORECORD and LABEL are as for
(interactive "BPop to buffer on same frame:\nP")
(pop-to-buffer buffer-or-name 'same-frame norecord label))
-(defsubst pop-to-buffer-other-window (&optional buffer-or-name norecord label)
+(defun pop-to-buffer-other-window (&optional buffer-or-name norecord label)
"Pop to buffer specified by BUFFER-OR-NAME in another window.
The selected window will be used only if there is no other
choice. Windows on the selected frame are preferred to windows
@@ -5913,7 +5913,7 @@ LABEL are as for `pop-to-buffer'."
(interactive "BPop to buffer in another window:\nP")
(pop-to-buffer buffer-or-name 'other-window norecord))
-(defsubst pop-to-buffer-same-frame-other-window (&optional buffer-or-name norecord label)
+(defun pop-to-buffer-same-frame-other-window (&optional buffer-or-name norecord label)
"Pop to buffer specified by BUFFER-OR-NAME in another window on the selected frame.
The selected window or another frame will be used only if there
is no other choice. Optional arguments BUFFER-OR-NAME, NORECORD
@@ -5921,7 +5921,7 @@ and LABEL are as for `pop-to-buffer'."
(interactive "BPop to buffer in another window on same frame:\nP")
(pop-to-buffer buffer-or-name 'same-frame-other-window norecord label))
-(defsubst pop-to-buffer-other-frame (&optional buffer-or-name norecord label)
+(defun pop-to-buffer-other-frame (&optional buffer-or-name norecord label)
"Pop to buffer specified by BUFFER-OR-NAME on another frame.
The selected frame will be used only if there's no other choice.
Optional arguments BUFFER-OR-NAME, NORECORD and LABEL are as for
@@ -5994,8 +5994,7 @@ Return the buffer switched to."
(let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name)))
(if (null force-same-window)
(pop-to-buffer
- buffer '(same-window (reuse-window-dedicated . weak))
- norecord 'switch-to-buffer)
+ buffer '(same-window (reuse-window-dedicated . weak)) norecord)
(cond
;; Don't call set-window-buffer if it's not needed since it
;; might signal an error (e.g. if the window is dedicated).
@@ -6005,6 +6004,7 @@ Return the buffer switched to."
((eq (window-dedicated-p) t)
(error "Cannot switch buffers in a dedicated window"))
(t (set-window-buffer nil buffer)))
+
(unless norecord
(select-window (selected-window)))
(set-buffer buffer))))
diff --git a/src/ChangeLog b/src/ChangeLog
index 94e7d98f81..53925dae40 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -408,6 +408,34 @@
(gs_load): Use printmax_t to print the widest integers possible.
Check for integer overflow when computing image height and width.
+2011-08-05 Eli Zaretskii <eliz@gnu.org>
+
+ * bidi.c <bidi_cache_total_alloc>: Now static.
+ (bidi_initialize): Initialize bidi_cache_total_alloc.
+
+ *xdisp.c (display_line): Release buffer allocated for shelved bidi
+ cache. (Bug#9221)
+
+ * bidi.c (bidi_shelve_cache, bidi_unshelve_cache): Track total
+ amount allocated this far in `bidi_cache_total_alloc'.
+ (bidi_unshelve_cache): Accept an additional argument JUST_FREE; if
+ non-zero, only free the data buffer without restoring the cache
+ contents. All callers changed.
+
+ * dispextern.h (bidi_unshelve_cache): Update prototype.
+
+ * xdisp.c (SAVE_IT, pos_visible_p, move_it_in_display_line_to)
+ (move_it_in_display_line, move_it_to)
+ (move_it_vertically_backward, move_it_by_lines): Replace the call
+ to xfree to an equivalent call to bidi_unshelve_cache.
+ (move_it_in_display_line_to): Fix logic of returning
+ MOVE_POS_MATCH_OR_ZV in the bidi case. (Bug#9224)
+
+2011-08-05 Eli Zaretskii <eliz@gnu.org>
+
+ * xdisp.c (set_cursor_from_row): Prefer the candidate glyph that
+ came from a string character with a `cursor' property. (Bug#9229)
+
2011-08-04 Jan Djärv <jan.h.d@swipnet.se>
* Makefile.in (LIB_PTHREAD): New variable.
diff --git a/src/bidi.c b/src/bidi.c
index f499ec37b9..f6ad22f8ea 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -628,17 +628,24 @@ bidi_pop_it (struct bidi_it *bidi_it)
bidi_cache_last_idx = -1;
}
+static ptrdiff_t bidi_cache_total_alloc;
+
/* Stash away a copy of the cache and its control variables. */
void *
bidi_shelve_cache (void)
{
unsigned char *databuf;
+ ptrdiff_t alloc;
+ /* Empty cache. */
if (bidi_cache_idx == 0)
return NULL;
- databuf = xmalloc (bidi_shelve_header_size
- + bidi_cache_idx * sizeof (struct bidi_it));
+ alloc = (bidi_shelve_header_size
+ + bidi_cache_idx * sizeof (struct bidi_it));
+ databuf = xmalloc (alloc);
+ bidi_cache_total_alloc += alloc;
+
memcpy (databuf, &bidi_cache_idx, sizeof (bidi_cache_idx));
memcpy (databuf + sizeof (bidi_cache_idx),
bidi_cache, bidi_cache_idx * sizeof (struct bidi_it));
@@ -664,7 +671,7 @@ bidi_shelve_cache (void)
/* Restore the cache state from a copy stashed away by bidi_shelve_cache. */
void
-bidi_unshelve_cache (void *databuf)
+bidi_unshelve_cache (void *databuf, int just_free)
{
unsigned char *p = databuf;
@@ -677,30 +684,43 @@ bidi_unshelve_cache (void *databuf)
}
else
{
- memcpy (&bidi_cache_idx, p, sizeof (bidi_cache_idx));
- bidi_cache_ensure_space (bidi_cache_idx);
- memcpy (bidi_cache, p + sizeof (bidi_cache_idx),
- bidi_cache_idx * sizeof (struct bidi_it));
- memcpy (bidi_cache_start_stack,
- p + sizeof (bidi_cache_idx)
- + bidi_cache_idx * sizeof (struct bidi_it),
- sizeof (bidi_cache_start_stack));
- memcpy (&bidi_cache_sp,
- p + sizeof (bidi_cache_idx)
- + bidi_cache_idx * sizeof (struct bidi_it)
- + sizeof (bidi_cache_start_stack),
- sizeof (bidi_cache_sp));
- memcpy (&bidi_cache_start,
- p + sizeof (bidi_cache_idx)
- + bidi_cache_idx * sizeof (struct bidi_it)
- + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp),
- sizeof (bidi_cache_start));
- memcpy (&bidi_cache_last_idx,
- p + sizeof (bidi_cache_idx)
- + bidi_cache_idx * sizeof (struct bidi_it)
- + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp)
- + sizeof (bidi_cache_start),
- sizeof (bidi_cache_last_idx));
+ if (just_free)
+ {
+ ptrdiff_t idx;
+
+ memcpy (&idx, p, sizeof (bidi_cache_idx));
+ bidi_cache_total_alloc -=
+ bidi_shelve_header_size + idx * sizeof (struct bidi_it);
+ }
+ else
+ {
+ memcpy (&bidi_cache_idx, p, sizeof (bidi_cache_idx));
+ bidi_cache_ensure_space (bidi_cache_idx);
+ memcpy (bidi_cache, p + sizeof (bidi_cache_idx),
+ bidi_cache_idx * sizeof (struct bidi_it));
+ memcpy (bidi_cache_start_stack,
+ p + sizeof (bidi_cache_idx)
+ + bidi_cache_idx * sizeof (struct bidi_it),
+ sizeof (bidi_cache_start_stack));
+ memcpy (&bidi_cache_sp,
+ p + sizeof (bidi_cache_idx)
+ + bidi_cache_idx * sizeof (struct bidi_it)
+ + sizeof (bidi_cache_start_stack),
+ sizeof (bidi_cache_sp));
+ memcpy (&bidi_cache_start,
+ p + sizeof (bidi_cache_idx)
+ + bidi_cache_idx * sizeof (struct bidi_it)
+ + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp),
+ sizeof (bidi_cache_start));
+ memcpy (&bidi_cache_last_idx,
+ p + sizeof (bidi_cache_idx)
+ + bidi_cache_idx * sizeof (struct bidi_it)
+ + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp)
+ + sizeof (bidi_cache_start),
+ sizeof (bidi_cache_last_idx));
+ bidi_cache_total_alloc -=
+ bidi_shelve_header_size + bidi_cache_idx * sizeof (struct bidi_it);
+ }
xfree (p);
}
@@ -747,6 +767,7 @@ bidi_initialize (void)
staticpro (&paragraph_separate_re);
bidi_cache_sp = 0;
+ bidi_cache_total_alloc = 0;
bidi_initialized = 1;
}
diff --git a/src/dispextern.h b/src/dispextern.h
index 4976131018..02d1089e3e 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2979,7 +2979,7 @@ extern int bidi_mirror_char (int);
extern void bidi_push_it (struct bidi_it *);
extern void bidi_pop_it (struct bidi_it *);
extern void *bidi_shelve_cache (void);
-extern void bidi_unshelve_cache (void *);
+extern void bidi_unshelve_cache (void *, int);
/* Defined in xdisp.c */
diff --git a/src/dispnew.c b/src/dispnew.c
index fde9be6bf5..5fedbb75a3 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5289,7 +5289,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
argument is ZV to prevent move_it_in_display_line from matching
based on buffer positions. */
move_it_in_display_line (&it, ZV, to_x, MOVE_TO_X);
- bidi_unshelve_cache (itdata);
+ bidi_unshelve_cache (itdata, 0);
Fset_buffer (old_current_buffer);
diff --git a/src/indent.c b/src/indent.c
index 37873351aa..313315e908 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2126,7 +2126,7 @@ whether or not it is currently displayed in some window. */)
}
SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
- bidi_unshelve_cache (itdata);
+ bidi_unshelve_cache (itdata, 0);
}
if (BUFFERP (old_buffer))
diff --git a/src/window.c b/src/window.c
index 04fea6b9bf..96b1144acf 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1379,7 +1379,7 @@ if it isn't already recorded. */)
if (it.current_y < it.last_visible_y)
move_it_past_eol (&it);
value = make_number (IT_CHARPOS (it));
- bidi_unshelve_cache (itdata);
+ bidi_unshelve_cache (itdata, 0);
if (old_buffer)
set_buffer_internal (old_buffer);
@@ -4273,7 +4273,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
}
start = it.current.pos;
- bidi_unshelve_cache (itdata);
+ bidi_unshelve_cache (itdata, 0);
}
else if (auto_window_vscroll_p)
{
@@ -4417,7 +4417,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
}
else
{
- bidi_unshelve_cache (itdata);
+ bidi_unshelve_cache (itdata, 0);
if (noerror)
return;
else if (n < 0) /* could happen with empty buffers */
@@ -4434,7 +4434,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
w->vscroll = 0;
else
{
- bidi_unshelve_cache (itdata);
+ bidi_unshelve_cache (itdata, 0);
if (noerror)
return;
else
@@ -4583,7 +4583,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
SET_PT_BOTH (charpos, bytepos);
}
}
- bidi_unshelve_cache (itdata);
+ bidi_unshelve_cache (itdata, 0);
}
@@ -5010,7 +5010,7 @@ displayed_window_lines (struct window *w)
start_display (&it, w, start);
move_it_vertically (&it, height);
bottom_y = line_bottom_y (&it);
- bidi_unshelve_cache (itdata);
+ bidi_unshelve_cache (itdata, 0);
/* rms: On a non-window display,
the value of it.vpos at the bottom of the screen
@@ -5116,7 +5116,7 @@ and redisplay normally--don't erase and redraw the frame. */)
move_it_vertically_backward (&it, window_box_height (w) / 2);
charpos = IT_CHARPOS (it);
bytepos = IT_BYTEPOS (it);
- bidi_unshelve_cache (itdata);
+ bidi_unshelve_cache (itdata, 0);
}
else if (iarg < 0)
{
@@ -5164,7 +5164,7 @@ and redisplay normally--don't erase and redraw the frame. */)
}
if (h <= 0)
{
- bidi_unshelve_cache (itdata);
+ bidi_unshelve_cache (itdata, 0);
return Qnil;
}
@@ -5187,7 +5187,7 @@ and redisplay normally--don't erase and redraw the frame. */)
charpos = IT_CHARPOS (it);
bytepos = IT_BYTEPOS (it);
- bidi_unshelve_cache (itdata);
+ bidi_unshelve_cache (itdata, 0);
}
else
{
diff --git a/src/xdisp.c b/src/xdisp.c
index bffb7bcdd7..481dd35c5d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -604,7 +604,7 @@ int current_mode_line_height, current_header_line_height;
#define SAVE_IT(ITCOPY,ITORIG,CACHE) \
do { \
if (CACHE) \
- xfree (CACHE); \
+ bidi_unshelve_cache (CACHE, 1); \
ITCOPY = ITORIG; \
CACHE = bidi_shelve_cache(); \
} while (0)
@@ -613,7 +613,7 @@ int current_mode_line_height, current_header_line_height;
do { \
if (pITORIG != pITCOPY) \
*(pITORIG) = *(pITCOPY); \
- bidi_unshelve_cache (CACHE); \
+ bidi_unshelve_cache (CACHE, 0); \
CACHE = NULL; \
} while (0)
@@ -1341,9 +1341,9 @@ pos_visible_p (struct window *w, EMACS_INT charpos, int *x, int *y,
*vpos = it2.vpos;
}
else
- xfree (it2data);
+ bidi_unshelve_cache (it2data, 1);
}
- bidi_unshelve_cache (itdata);
+ bidi_unshelve_cache (itdata, 0);
if (old_buffer)
set_buffer_internal_1 (old_buffer);
@@ -2624,7 +2624,7 @@ init_iterator (struct it *it, struct window *w,
it->paragraph_embedding = R2L;
else
it->paragraph_embedding = NEUTRAL_DIR;
- bidi_unshelve_cache (NULL);
+ bidi_unshelve_cache (NULL, 0);
bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f),
&it->bidi_it);
}
@@ -5615,7 +5615,7 @@ back_to_previous_visible_line_start (struct it *it)
pos = --IT_CHARPOS (it2);
--IT_BYTEPOS (it2);
it2.sp = 0;
- bidi_unshelve_cache (NULL);
+ bidi_unshelve_cache (NULL, 0);
it2.string_from_display_prop_p = 0;
it2.from_disp_prop_p = 0;
if (handle_display_prop (&it2) == HANDLED_RETURN
@@ -5825,7 +5825,7 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p)
{
bidi_init_it (IT_CHARPOS (*it), IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f),
&it->bidi_it);
- bidi_unshelve_cache (NULL);
+ bidi_unshelve_cache (NULL, 0);
it->bidi_it.paragraph_dir = NEUTRAL_DIR;
it->bidi_it.string.s = NULL;
it->bidi_it.string.lstring = Qnil;
@@ -8006,13 +8006,13 @@ move_it_in_display_line_to (struct it *it,
positions smaller than TO_CHARPOS, return
MOVE_POS_MATCH_OR_ZV, like the unidirectional display
did. */
- if ((op & MOVE_TO_POS) != 0
+ if (it->bidi_p && (op & MOVE_TO_POS) != 0
&& !saw_smaller_pos
&& IT_CHARPOS (*it) > to_charpos)
{
- result = MOVE_POS_MATCH_OR_ZV;
- if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV)
+ if (IT_CHARPOS (ppos_it) < ZV)
RESTORE_IT (it, &ppos_it, ppos_data);
+ goto buffer_pos_reached;
}
else
result = MOVE_NEWLINE_OR_CR;
@@ -8051,14 +8051,13 @@ move_it_in_display_line_to (struct it *it,
character positions smaller than TO_CHARPOS,
return MOVE_POS_MATCH_OR_ZV, like the
unidirectional display did. */
- || ((op & MOVE_TO_POS) != 0
+ || (it->bidi_p && (op & MOVE_TO_POS) != 0
&& !saw_smaller_pos
&& IT_CHARPOS (*it) > to_charpos))
{
- result = MOVE_POS_MATCH_OR_ZV;
- if (it->bidi_p && !at_eob_p && IT_CHARPOS (ppos_it) < ZV)
+ if (!at_eob_p && IT_CHARPOS (ppos_it) < ZV)
RESTORE_IT (it, &ppos_it, ppos_data);
- break;
+ goto buffer_pos_reached;
}
if (ITERATOR_AT_END_OF_LINE_P (it))
{
@@ -8066,14 +8065,13 @@ move_it_in_display_line_to (struct it *it,
break;
}
}
- else if ((op & MOVE_TO_POS) != 0
+ else if (it->bidi_p && (op & MOVE_TO_POS) != 0
&& !saw_smaller_pos
&& IT_CHARPOS (*it) > to_charpos)
{
- result = MOVE_POS_MATCH_OR_ZV;
- if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV)
+ if (IT_CHARPOS (ppos_it) < ZV)
RESTORE_IT (it, &ppos_it, ppos_data);
- break;
+ goto buffer_pos_reached;
}
result = MOVE_LINE_TRUNCATED;
break;
@@ -8093,13 +8091,13 @@ move_it_in_display_line_to (struct it *it,
done:
if (atpos_data)
- xfree (atpos_data);
+ bidi_unshelve_cache (atpos_data, 1);
if (atx_data)
- xfree (atx_data);
+ bidi_unshelve_cache (atx_data, 1);
if (wrap_data)
- xfree (wrap_data);
+ bidi_unshelve_cache (wrap_data, 1);
if (ppos_data)
- xfree (ppos_data);
+ bidi_unshelve_cache (ppos_data, 1);
/* Restore the iterator settings altered at the beginning of this
function. */
@@ -8134,7 +8132,7 @@ move_it_in_display_line (struct it *it,
(it, -1, prev_x, MOVE_TO_X);
}
else
- xfree (save_data);
+ bidi_unshelve_cache (save_data, 1);
}
else
move_it_in_display_line_to (it, to_charpos, to_x, op);
@@ -8393,7 +8391,7 @@ move_it_to (struct it *it, EMACS_INT to_charpos, int to_x, int to_y, int to_vpos
}
if (backup_data)
- xfree (backup_data);
+ bidi_unshelve_cache (backup_data, 1);
TRACE_MOVE ((stderr, "move_it_to: reached %d\n", reached));
}
@@ -8472,7 +8470,7 @@ move_it_vertically_backward (struct it *it, int dy)
RESTORE_IT (it, it, it2data);
if (nlines > 0)
move_it_by_lines (it, nlines);
- xfree (it3data);
+ bidi_unshelve_cache (it3data, 1);
}
else
{
@@ -8668,7 +8666,7 @@ move_it_by_lines (struct it *it, int dvpos)
if (IT_CHARPOS (*it) >= start_charpos)
RESTORE_IT (it, &it2, it2data);
else
- xfree (it2data);
+ bidi_unshelve_cache (it2data, 1);
}
else
RESTORE_IT (it, it, it2data);
@@ -13704,14 +13702,12 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
w->cursor.vpos >= 0
/* that candidate is not the row we are processing */
&& MATRIX_ROW (matrix, w->cursor.vpos) != row
- /* the row we are processing is part of a continued line */
- && (row->continued_p || MATRIX_ROW_CONTINUATION_LINE_P (row))
/* Make sure cursor.vpos specifies a row whose start and end
charpos occlude point. This is because some callers of this
function leave cursor.vpos at the row where the cursor was
displayed during the last redisplay cycle. */
&& MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) <= pt_old
- && pt_old < MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)))
+ && pt_old <= MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)))
{
struct glyph *g1 =
MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos;
@@ -13720,15 +13716,20 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
if (!(row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end))
return 0;
/* Keep the candidate whose buffer position is the closest to
- point. */
+ point or has the `cursor' property. */
if (/* previous candidate is a glyph in TEXT_AREA of that row */
w->cursor.hpos >= 0
&& w->cursor.hpos < MATRIX_ROW_USED (matrix, w->cursor.vpos)
- && BUFFERP (g1->object)
- && (g1->charpos == pt_old /* an exact match always wins */
- || (BUFFERP (glyph->object)
- && eabs (g1->charpos - pt_old)
- < eabs (glyph->charpos - pt_old))))
+ && ((BUFFERP (g1->object)
+ && (g1->charpos == pt_old /* an exact match always wins */
+ || (BUFFERP (glyph->object)
+ && eabs (g1->charpos - pt_old)
+ < eabs (glyph->charpos - pt_old))))
+ /* previous candidate is a glyph from a string that has
+ a non-nil `cursor' property */
+ || (STRINGP (g1->object)
+ && !NILP (Fget_char_property (make_number (g1->charpos),
+ Qcursor, g1->object)))))
return 0;
/* If this candidate gives an exact match, use that. */
if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old)
@@ -18774,6 +18775,9 @@ display_line (struct it *it)
}
}
+ if (wrap_data)
+ bidi_unshelve_cache (wrap_data, 1);
+
/* If line is not empty and hscrolled, maybe insert truncation glyphs
at the left window margin. */
if (it->first_visible_x