aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-08-05 16:35:10 -0700
committerPaul Eggert2011-08-05 16:35:10 -0700
commit458bfed397af18e460d01b888d1da095b6b95034 (patch)
tree6f3933c2deab13b0df064d87e7b6fa25d835cfcb
parent0e51f7172bd1ab8b9c1bb52598afb5017e19b9c3 (diff)
parent4640dd881c07162a6120ccb3b117b748badf78c9 (diff)
downloademacs-458bfed397af18e460d01b888d1da095b6b95034.tar.gz
emacs-458bfed397af18e460d01b888d1da095b6b95034.zip
Merge from trunk.
-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 3348d3a4c02..5b28ad0808b 100644
--- a/autogen/Makefile.in
+++ b/autogen/Makefile.in
@@ -495,6 +495,7 @@ LIBXT_OTHER = @LIBXT_OTHER@
495LIBX_OTHER = @LIBX_OTHER@ 495LIBX_OTHER = @LIBX_OTHER@
496LIB_GCC = @LIB_GCC@ 496LIB_GCC = @LIB_GCC@
497LIB_MATH = @LIB_MATH@ 497LIB_MATH = @LIB_MATH@
498LIB_PTHREAD = @LIB_PTHREAD@
498LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ 499LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@
499LIB_STANDARD = @LIB_STANDARD@ 500LIB_STANDARD = @LIB_STANDARD@
500LTLIBINTL = @LTLIBINTL@ 501LTLIBINTL = @LTLIBINTL@
diff --git a/autogen/config.in b/autogen/config.in
index d4ec03b8343..ca44b80c91e 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/>. */
321/* Define to 1 if you have the `gtk_adjustment_get_page_size' function. */ 321/* Define to 1 if you have the `gtk_adjustment_get_page_size' function. */
322#undef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE 322#undef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE
323 323
324/* Define to 1 if you have GTK and pthread (-lpthread). */
325#undef HAVE_GTK_AND_PTHREAD
326
327/* Define to 1 if you have the `gtk_dialog_get_action_area' function. */ 324/* Define to 1 if you have the `gtk_dialog_get_action_area' function. */
328#undef HAVE_GTK_DIALOG_GET_ACTION_AREA 325#undef HAVE_GTK_DIALOG_GET_ACTION_AREA
329 326
@@ -582,6 +579,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
582/* Define to 1 if you have the `pstat_getdynamic' function. */ 579/* Define to 1 if you have the `pstat_getdynamic' function. */
583#undef HAVE_PSTAT_GETDYNAMIC 580#undef HAVE_PSTAT_GETDYNAMIC
584 581
582/* Define to 1 if you have pthread (-lpthread). */
583#undef HAVE_PTHREAD
584
585/* Define to 1 if you have the <pthread.h> header file. */ 585/* Define to 1 if you have the <pthread.h> header file. */
586#undef HAVE_PTHREAD_H 586#undef HAVE_PTHREAD_H
587 587
diff --git a/autogen/configure b/autogen/configure
index 074850731b0..351937c35a7 100755
--- a/autogen/configure
+++ b/autogen/configure
@@ -1139,6 +1139,7 @@ IMAGEMAGICK_LIBS
1139IMAGEMAGICK_CFLAGS 1139IMAGEMAGICK_CFLAGS
1140RSVG_LIBS 1140RSVG_LIBS
1141RSVG_CFLAGS 1141RSVG_CFLAGS
1142LIB_PTHREAD
1142VMLIMIT_OBJ 1143VMLIMIT_OBJ
1143GMALLOC_OBJ 1144GMALLOC_OBJ
1144HAVE_XSERVER 1145HAVE_XSERVER
@@ -9949,6 +9950,72 @@ if test "x$ac_cv_lib_Xbsd_main" = x""yes; then :
9949fi 9950fi
9950 9951
9951 9952
9953LIB_PTHREAD=
9954for ac_header in pthread.h
9955do :
9956 ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
9957if test "x$ac_cv_header_pthread_h" = x""yes; then :
9958 cat >>confdefs.h <<_ACEOF
9959#define HAVE_PTHREAD_H 1
9960_ACEOF
9961
9962fi
9963
9964done
9965
9966if test "$ac_cv_header_pthread_h"; then
9967 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5
9968$as_echo_n "checking for pthread_self in -lpthread... " >&6; }
9969if test "${ac_cv_lib_pthread_pthread_self+set}" = set; then :
9970 $as_echo_n "(cached) " >&6
9971else
9972 ac_check_lib_save_LIBS=$LIBS
9973LIBS="-lpthread $LIBS"
9974cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9975/* end confdefs.h. */
9976
9977/* Override any GCC internal prototype to avoid an error.
9978 Use char because int might match the return type of a GCC
9979 builtin and then its argument prototype would still apply. */
9980#ifdef __cplusplus
9981extern "C"
9982#endif
9983char pthread_self ();
9984int
9985main ()
9986{
9987return pthread_self ();
9988 ;
9989 return 0;
9990}
9991_ACEOF
9992if ac_fn_c_try_link "$LINENO"; then :
9993 ac_cv_lib_pthread_pthread_self=yes
9994else
9995 ac_cv_lib_pthread_pthread_self=no
9996fi
9997rm -f core conftest.err conftest.$ac_objext \
9998 conftest$ac_exeext conftest.$ac_ext
9999LIBS=$ac_check_lib_save_LIBS
10000fi
10001{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_self" >&5
10002$as_echo "$ac_cv_lib_pthread_pthread_self" >&6; }
10003if test "x$ac_cv_lib_pthread_pthread_self" = x""yes; then :
10004 HAVE_PTHREAD=yes
10005fi
10006
10007fi
10008if test "$HAVE_PTHREAD" = yes; then
10009 case "${canonical}" in
10010 *-hpux*) ;;
10011 *) LIB_PTHREAD="-lpthread" ;;
10012 esac
10013
10014$as_echo "#define HAVE_PTHREAD 1" >>confdefs.h
10015
10016fi
10017
10018
9952{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cma_open in -lpthreads" >&5 10019{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cma_open in -lpthreads" >&5
9953$as_echo_n "checking for cma_open in -lpthreads... " >&6; } 10020$as_echo_n "checking for cma_open in -lpthreads... " >&6; }
9954if test "${ac_cv_lib_pthreads_cma_open+set}" = set; then : 10021if test "${ac_cv_lib_pthreads_cma_open+set}" = set; then :
@@ -10774,70 +10841,6 @@ done
10774 10841
10775 fi 10842 fi
10776 10843
10777 HAVE_GTK_AND_PTHREAD=no
10778 for ac_header in pthread.h
10779do :
10780 ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
10781if test "x$ac_cv_header_pthread_h" = x""yes; then :
10782 cat >>confdefs.h <<_ACEOF
10783#define HAVE_PTHREAD_H 1
10784_ACEOF
10785
10786fi
10787
10788done
10789
10790 if test "$ac_cv_header_pthread_h"; then
10791 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5
10792$as_echo_n "checking for pthread_self in -lpthread... " >&6; }
10793if test "${ac_cv_lib_pthread_pthread_self+set}" = set; then :
10794 $as_echo_n "(cached) " >&6
10795else
10796 ac_check_lib_save_LIBS=$LIBS
10797LIBS="-lpthread $LIBS"
10798cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10799/* end confdefs.h. */
10800
10801/* Override any GCC internal prototype to avoid an error.
10802 Use char because int might match the return type of a GCC
10803 builtin and then its argument prototype would still apply. */
10804#ifdef __cplusplus
10805extern "C"
10806#endif
10807char pthread_self ();
10808int
10809main ()
10810{
10811return pthread_self ();
10812 ;
10813 return 0;
10814}
10815_ACEOF
10816if ac_fn_c_try_link "$LINENO"; then :
10817 ac_cv_lib_pthread_pthread_self=yes
10818else
10819 ac_cv_lib_pthread_pthread_self=no
10820fi
10821rm -f core conftest.err conftest.$ac_objext \
10822 conftest$ac_exeext conftest.$ac_ext
10823LIBS=$ac_check_lib_save_LIBS
10824fi
10825{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_self" >&5
10826$as_echo "$ac_cv_lib_pthread_pthread_self" >&6; }
10827if test "x$ac_cv_lib_pthread_pthread_self" = x""yes; then :
10828 HAVE_GTK_AND_PTHREAD=yes
10829fi
10830
10831 fi
10832 if test "$HAVE_GTK_AND_PTHREAD" = yes; then
10833 case "${canonical}" in
10834 *-hpux*) ;;
10835 *) GTK_LIBS="$GTK_LIBS -lpthread" ;;
10836 esac
10837
10838$as_echo "#define HAVE_GTK_AND_PTHREAD 1" >>confdefs.h
10839
10840 fi
10841 10844
10842 for ac_func in gtk_widget_get_window gtk_widget_set_has_window \ 10845 for ac_func in gtk_widget_get_window gtk_widget_set_has_window \
10843 gtk_dialog_get_action_area gtk_widget_get_sensitive \ 10846 gtk_dialog_get_action_area gtk_widget_get_sensitive \
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6a6abdf7e42..7c1fa3a656b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,22 @@
12011-08-05 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/js.el (js--regexp-literal): Accept regexps at the beginning
4 of statements and in a few more cases (bug#9183).
5
6 * emacs-lisp/cl-macs.el (cl--make-usage-var, cl--make-usage-args):
7 New functions.
8 (cl-transform-lambda): Use them (bug#9239).
9
102011-08-05 Martin Rudalics <rudalics@gmx.at>
11
12 * window.el (display-buffer-same-window)
13 (display-buffer-same-frame, display-buffer-other-window)
14 (pop-to-buffer-same-window, pop-to-buffer-same-frame)
15 (pop-to-buffer-other-window)
16 (pop-to-buffer-same-frame-other-window)
17 (pop-to-buffer-other-frame): Make them defuns.
18 (switch-to-buffer): Don't set LABEL argument of pop-to-buffer.
19
12011-08-03 Stefan Monnier <monnier@iro.umontreal.ca> 202011-08-03 Stefan Monnier <monnier@iro.umontreal.ca>
2 21
3 * subr.el (make-composed-keymap): Move from C. Change calling 22 * 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 4b9985380c3..7beb4d4b4cc 100644
--- a/lisp/emacs-lisp/cl-loaddefs.el
+++ b/lisp/emacs-lisp/cl-loaddefs.el
@@ -282,7 +282,7 @@ Not documented
282;;;;;; flet progv psetq do-all-symbols do-symbols dotimes dolist 282;;;;;; flet progv psetq do-all-symbols do-symbols dotimes dolist
283;;;;;; do* do loop return-from return block etypecase typecase ecase 283;;;;;; do* do loop return-from return block etypecase typecase ecase
284;;;;;; case load-time-value eval-when destructuring-bind function* 284;;;;;; case load-time-value eval-when destructuring-bind function*
285;;;;;; defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "21df83d6106cb0c3d037e75ad79359dc") 285;;;;;; defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "0907093f7720996444ededb4edfe8072")
286;;; Generated autoloads from cl-macs.el 286;;; Generated autoloads from cl-macs.el
287 287
288(autoload 'gensym "cl-macs" "\ 288(autoload 'gensym "cl-macs" "\
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 6d242eda3ab..fb19115287c 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:
238 238
239(declare-function help-add-fundoc-usage "help-fns" (docstring arglist)) 239(declare-function help-add-fundoc-usage "help-fns" (docstring arglist))
240 240
241(defun cl--make-usage-var (x)
242 "X can be a var or a (destructuring) lambda-list."
243 (cond
244 ((symbolp x) (make-symbol (upcase (symbol-name x))))
245 ((consp x) (cl--make-usage-args x))
246 (t x)))
247
248(defun cl--make-usage-args (arglist)
249 ;; `orig-args' can contain &cl-defs (an internal
250 ;; CL thingy I don't understand), so remove it.
251 (let ((x (memq '&cl-defs arglist)))
252 (when x (setq arglist (delq (car x) (remq (cadr x) arglist)))))
253 (let ((state nil))
254 (mapcar (lambda (x)
255 (cond
256 ((symbolp x)
257 (if (eq ?\& (aref (symbol-name x) 0))
258 (setq state x)
259 (make-symbol (upcase (symbol-name x)))))
260 ((not (consp x)) x)
261 ((memq state '(nil &rest)) (cl--make-usage-args x))
262 (t ;(VAR INITFORM SVAR) or ((KEYWORD VAR) INITFORM SVAR).
263 (list*
264 (if (and (consp (car x)) (eq state '&key))
265 (list (caar x) (cl--make-usage-var (nth 1 (car x))))
266 (cl--make-usage-var (car x)))
267 (nth 1 x) ;INITFORM.
268 (cl--make-usage-args (nthcdr 2 x)) ;SVAR.
269 ))))
270 arglist)))
271
241(defun cl-transform-lambda (form bind-block) 272(defun cl-transform-lambda (form bind-block)
242 (let* ((args (car form)) (body (cdr form)) (orig-args args) 273 (let* ((args (car form)) (body (cdr form)) (orig-args args)
243 (bind-defs nil) (bind-enquote nil) 274 (bind-defs nil) (bind-enquote nil)
@@ -282,11 +313,8 @@ It is a list of elements of the form either:
282 (require 'help-fns) 313 (require 'help-fns)
283 (cons (help-add-fundoc-usage 314 (cons (help-add-fundoc-usage
284 (if (stringp (car hdr)) (pop hdr)) 315 (if (stringp (car hdr)) (pop hdr))
285 ;; orig-args can contain &cl-defs (an internal 316 (format "(fn %S)"
286 ;; CL thingy I don't understand), so remove it. 317 (cl--make-usage-args orig-args)))
287 (let ((x (memq '&cl-defs orig-args)))
288 (if (null x) orig-args
289 (delq (car x) (remq (cadr x) orig-args)))))
290 hdr))) 318 hdr)))
291 (list (nconc (list 'let* bind-lets) 319 (list (nconc (list 'let* bind-lets)
292 (nreverse bind-forms) body))))))) 320 (nreverse bind-forms) body)))))))
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index b13e6a77d5d..5e034b14fde 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -65,7 +65,9 @@
65 65
66(defun help-split-fundoc (docstring def) 66(defun help-split-fundoc (docstring def)
67 "Split a function DOCSTRING into the actual doc and the usage info. 67 "Split a function DOCSTRING into the actual doc and the usage info.
68Return (USAGE . DOC) or nil if there's no usage info. 68Return (USAGE . DOC) or nil if there's no usage info, where USAGE info
69is a string describing the argument list of DEF, such as
70\"(apply FUNCTION &rest ARGUMENTS)\".
69DEF is the function whose usage we're looking for in DOCSTRING." 71DEF is the function whose usage we're looking for in DOCSTRING."
70 ;; Functions can get the calling sequence at the end of the doc string. 72 ;; Functions can get the calling sequence at the end of the doc string.
71 ;; In cases where `function' has been fset to a subr we can't search for 73 ;; 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."
156(defun help-make-usage (function arglist) 158(defun help-make-usage (function arglist)
157 (cons (if (symbolp function) function 'anonymous) 159 (cons (if (symbolp function) function 'anonymous)
158 (mapcar (lambda (arg) 160 (mapcar (lambda (arg)
159 (if (not (symbolp arg)) 161 (if (not (symbolp arg)) arg
160 (if (and (consp arg) (symbolp (car arg)))
161 ;; CL style default values for optional args.
162 (cons (intern (upcase (symbol-name (car arg))))
163 (cdr arg))
164 arg)
165 (let ((name (symbol-name arg))) 162 (let ((name (symbol-name arg)))
166 (cond 163 (cond
167 ((string-match "\\`&" name) arg) 164 ((string-match "\\`&" name) arg)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 1bdcb4cfa89..4abbe3b895f 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1658,15 +1658,19 @@ This performs fontification according to `js--class-styles'."
1658;; below. 1658;; below.
1659(eval-and-compile 1659(eval-and-compile
1660 (defconst js--regexp-literal 1660 (defconst js--regexp-literal
1661 "[=(,:]\\(?:\\s-\\|\n\\)*\\(/\\)\\(?:\\\\.\\|[^/*\\]\\)\\(?:\\\\.\\|[^/\\]\\)*\\(/\\)" 1661 (concat
1662 ;; We want to match regular expressions only at the beginning of
1663 ;; expressions.
1664 ;; FIXME: Should we also allow /regexp/ after infix operators such as +,
1665 ;; /, -, *, >, ...?
1666 "\\(?:\\`\\|[=([{,:;]\\)\\(?:\\s-\\|\n\\)*"
1667 "\\(/\\)\\(?:\\\\.\\|[^/*\\]\\)\\(?:\\\\.\\|[^/\\]\\)*\\(/\\)")
1662 "Regexp matching a JavaScript regular expression literal. 1668 "Regexp matching a JavaScript regular expression literal.
1663Match groups 1 and 2 are the characters forming the beginning and 1669Match groups 1 and 2 are the characters forming the beginning and
1664end of the literal.")) 1670end of the literal."))
1665 1671
1666(defconst js-syntax-propertize-function 1672(defconst js-syntax-propertize-function
1667 (syntax-propertize-rules 1673 (syntax-propertize-rules
1668 ;; We want to match regular expressions only at the beginning of
1669 ;; expressions.
1670 (js--regexp-literal (1 "\"") (2 "\"")))) 1674 (js--regexp-literal (1 "\"") (2 "\""))))
1671 1675
1672;;; Indentation 1676;;; Indentation
diff --git a/lisp/window.el b/lisp/window.el
index 215dbab7849..7e666af6abf 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -5796,7 +5796,7 @@ this list as arguments."
5796 ;; regardless of graphic-only restrictions. 5796 ;; regardless of graphic-only restrictions.
5797 (display-buffer-pop-up-frame buffer))))) 5797 (display-buffer-pop-up-frame buffer)))))
5798 5798
5799(defsubst display-buffer-same-window (&optional buffer-or-name label) 5799(defun display-buffer-same-window (&optional buffer-or-name label)
5800 "Display buffer specified by BUFFER-OR-NAME in the selected window. 5800 "Display buffer specified by BUFFER-OR-NAME in the selected window.
5801Another window will be used only if the buffer can't be shown in 5801Another window will be used only if the buffer can't be shown in
5802the selected window, usually because it is dedicated to another 5802the selected window, usually because it is dedicated to another
@@ -5805,7 +5805,7 @@ buffer. Optional argument BUFFER-OR-NAME and LABEL are as for
5805 (interactive "BDisplay buffer in same window:\nP") 5805 (interactive "BDisplay buffer in same window:\nP")
5806 (display-buffer buffer-or-name 'same-window label)) 5806 (display-buffer buffer-or-name 'same-window label))
5807 5807
5808(defsubst display-buffer-same-frame (&optional buffer-or-name label) 5808(defun display-buffer-same-frame (&optional buffer-or-name label)
5809 "Display buffer specified by BUFFER-OR-NAME in a window on the same frame. 5809 "Display buffer specified by BUFFER-OR-NAME in a window on the same frame.
5810Another frame will be used only if there is no other choice. 5810Another frame will be used only if there is no other choice.
5811Optional argument BUFFER-OR-NAME and LABEL are as for 5811Optional argument BUFFER-OR-NAME and LABEL are as for
@@ -5813,7 +5813,7 @@ Optional argument BUFFER-OR-NAME and LABEL are as for
5813 (interactive "BDisplay buffer on same frame:\nP") 5813 (interactive "BDisplay buffer on same frame:\nP")
5814 (display-buffer buffer-or-name 'same-frame label)) 5814 (display-buffer buffer-or-name 'same-frame label))
5815 5815
5816(defsubst display-buffer-other-window (&optional buffer-or-name label) 5816(defun display-buffer-other-window (&optional buffer-or-name label)
5817 "Display buffer specified by BUFFER-OR-NAME in another window. 5817 "Display buffer specified by BUFFER-OR-NAME in another window.
5818The selected window will be used only if there is no other 5818The selected window will be used only if there is no other
5819choice. Windows on the selected frame are preferred to windows 5819choice. Windows on the selected frame are preferred to windows
@@ -5887,7 +5887,7 @@ additional information."
5887 (select-frame-set-input-focus new-frame norecord)) 5887 (select-frame-set-input-focus new-frame norecord))
5888 buffer)) 5888 buffer))
5889 5889
5890(defsubst pop-to-buffer-same-window (&optional buffer-or-name norecord label) 5890(defun pop-to-buffer-same-window (&optional buffer-or-name norecord label)
5891 "Pop to buffer specified by BUFFER-OR-NAME in the selected window. 5891 "Pop to buffer specified by BUFFER-OR-NAME in the selected window.
5892Another window will be used only if the buffer can't be shown in 5892Another window will be used only if the buffer can't be shown in
5893the selected window, usually because it is dedicated to another 5893the selected window, usually because it is dedicated to another
@@ -5896,7 +5896,7 @@ as for `pop-to-buffer'."
5896 (interactive "BPop to buffer in selected window:\nP") 5896 (interactive "BPop to buffer in selected window:\nP")
5897 (pop-to-buffer buffer-or-name 'same-window norecord label)) 5897 (pop-to-buffer buffer-or-name 'same-window norecord label))
5898 5898
5899(defsubst pop-to-buffer-same-frame (&optional buffer-or-name norecord label) 5899(defun pop-to-buffer-same-frame (&optional buffer-or-name norecord label)
5900 "Pop to buffer specified by BUFFER-OR-NAME in a window on the selected frame. 5900 "Pop to buffer specified by BUFFER-OR-NAME in a window on the selected frame.
5901Another frame will be used only if there is no other choice. 5901Another frame will be used only if there is no other choice.
5902Optional arguments BUFFER-OR-NAME, NORECORD and LABEL are as for 5902Optional 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
5904 (interactive "BPop to buffer on same frame:\nP") 5904 (interactive "BPop to buffer on same frame:\nP")
5905 (pop-to-buffer buffer-or-name 'same-frame norecord label)) 5905 (pop-to-buffer buffer-or-name 'same-frame norecord label))
5906 5906
5907(defsubst pop-to-buffer-other-window (&optional buffer-or-name norecord label) 5907(defun pop-to-buffer-other-window (&optional buffer-or-name norecord label)
5908 "Pop to buffer specified by BUFFER-OR-NAME in another window. 5908 "Pop to buffer specified by BUFFER-OR-NAME in another window.
5909The selected window will be used only if there is no other 5909The selected window will be used only if there is no other
5910choice. Windows on the selected frame are preferred to windows 5910choice. Windows on the selected frame are preferred to windows
@@ -5913,7 +5913,7 @@ LABEL are as for `pop-to-buffer'."
5913 (interactive "BPop to buffer in another window:\nP") 5913 (interactive "BPop to buffer in another window:\nP")
5914 (pop-to-buffer buffer-or-name 'other-window norecord)) 5914 (pop-to-buffer buffer-or-name 'other-window norecord))
5915 5915
5916(defsubst pop-to-buffer-same-frame-other-window (&optional buffer-or-name norecord label) 5916(defun pop-to-buffer-same-frame-other-window (&optional buffer-or-name norecord label)
5917 "Pop to buffer specified by BUFFER-OR-NAME in another window on the selected frame. 5917 "Pop to buffer specified by BUFFER-OR-NAME in another window on the selected frame.
5918The selected window or another frame will be used only if there 5918The selected window or another frame will be used only if there
5919is no other choice. Optional arguments BUFFER-OR-NAME, NORECORD 5919is no other choice. Optional arguments BUFFER-OR-NAME, NORECORD
@@ -5921,7 +5921,7 @@ and LABEL are as for `pop-to-buffer'."
5921 (interactive "BPop to buffer in another window on same frame:\nP") 5921 (interactive "BPop to buffer in another window on same frame:\nP")
5922 (pop-to-buffer buffer-or-name 'same-frame-other-window norecord label)) 5922 (pop-to-buffer buffer-or-name 'same-frame-other-window norecord label))
5923 5923
5924(defsubst pop-to-buffer-other-frame (&optional buffer-or-name norecord label) 5924(defun pop-to-buffer-other-frame (&optional buffer-or-name norecord label)
5925 "Pop to buffer specified by BUFFER-OR-NAME on another frame. 5925 "Pop to buffer specified by BUFFER-OR-NAME on another frame.
5926The selected frame will be used only if there's no other choice. 5926The selected frame will be used only if there's no other choice.
5927Optional arguments BUFFER-OR-NAME, NORECORD and LABEL are as for 5927Optional arguments BUFFER-OR-NAME, NORECORD and LABEL are as for
@@ -5994,8 +5994,7 @@ Return the buffer switched to."
5994 (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name))) 5994 (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name)))
5995 (if (null force-same-window) 5995 (if (null force-same-window)
5996 (pop-to-buffer 5996 (pop-to-buffer
5997 buffer '(same-window (reuse-window-dedicated . weak)) 5997 buffer '(same-window (reuse-window-dedicated . weak)) norecord)
5998 norecord 'switch-to-buffer)
5999 (cond 5998 (cond
6000 ;; Don't call set-window-buffer if it's not needed since it 5999 ;; Don't call set-window-buffer if it's not needed since it
6001 ;; might signal an error (e.g. if the window is dedicated). 6000 ;; might signal an error (e.g. if the window is dedicated).
@@ -6005,6 +6004,7 @@ Return the buffer switched to."
6005 ((eq (window-dedicated-p) t) 6004 ((eq (window-dedicated-p) t)
6006 (error "Cannot switch buffers in a dedicated window")) 6005 (error "Cannot switch buffers in a dedicated window"))
6007 (t (set-window-buffer nil buffer))) 6006 (t (set-window-buffer nil buffer)))
6007
6008 (unless norecord 6008 (unless norecord
6009 (select-window (selected-window))) 6009 (select-window (selected-window)))
6010 (set-buffer buffer)))) 6010 (set-buffer buffer))))
diff --git a/src/ChangeLog b/src/ChangeLog
index 94e7d98f813..53925dae403 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -408,6 +408,34 @@
408 (gs_load): Use printmax_t to print the widest integers possible. 408 (gs_load): Use printmax_t to print the widest integers possible.
409 Check for integer overflow when computing image height and width. 409 Check for integer overflow when computing image height and width.
410 410
4112011-08-05 Eli Zaretskii <eliz@gnu.org>
412
413 * bidi.c <bidi_cache_total_alloc>: Now static.
414 (bidi_initialize): Initialize bidi_cache_total_alloc.
415
416 *xdisp.c (display_line): Release buffer allocated for shelved bidi
417 cache. (Bug#9221)
418
419 * bidi.c (bidi_shelve_cache, bidi_unshelve_cache): Track total
420 amount allocated this far in `bidi_cache_total_alloc'.
421 (bidi_unshelve_cache): Accept an additional argument JUST_FREE; if
422 non-zero, only free the data buffer without restoring the cache
423 contents. All callers changed.
424
425 * dispextern.h (bidi_unshelve_cache): Update prototype.
426
427 * xdisp.c (SAVE_IT, pos_visible_p, move_it_in_display_line_to)
428 (move_it_in_display_line, move_it_to)
429 (move_it_vertically_backward, move_it_by_lines): Replace the call
430 to xfree to an equivalent call to bidi_unshelve_cache.
431 (move_it_in_display_line_to): Fix logic of returning
432 MOVE_POS_MATCH_OR_ZV in the bidi case. (Bug#9224)
433
4342011-08-05 Eli Zaretskii <eliz@gnu.org>
435
436 * xdisp.c (set_cursor_from_row): Prefer the candidate glyph that
437 came from a string character with a `cursor' property. (Bug#9229)
438
4112011-08-04 Jan Djärv <jan.h.d@swipnet.se> 4392011-08-04 Jan Djärv <jan.h.d@swipnet.se>
412 440
413 * Makefile.in (LIB_PTHREAD): New variable. 441 * Makefile.in (LIB_PTHREAD): New variable.
diff --git a/src/bidi.c b/src/bidi.c
index f499ec37b9e..f6ad22f8ea2 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -628,17 +628,24 @@ bidi_pop_it (struct bidi_it *bidi_it)
628 bidi_cache_last_idx = -1; 628 bidi_cache_last_idx = -1;
629} 629}
630 630
631static ptrdiff_t bidi_cache_total_alloc;
632
631/* Stash away a copy of the cache and its control variables. */ 633/* Stash away a copy of the cache and its control variables. */
632void * 634void *
633bidi_shelve_cache (void) 635bidi_shelve_cache (void)
634{ 636{
635 unsigned char *databuf; 637 unsigned char *databuf;
638 ptrdiff_t alloc;
636 639
640 /* Empty cache. */
637 if (bidi_cache_idx == 0) 641 if (bidi_cache_idx == 0)
638 return NULL; 642 return NULL;
639 643
640 databuf = xmalloc (bidi_shelve_header_size 644 alloc = (bidi_shelve_header_size
641 + bidi_cache_idx * sizeof (struct bidi_it)); 645 + bidi_cache_idx * sizeof (struct bidi_it));
646 databuf = xmalloc (alloc);
647 bidi_cache_total_alloc += alloc;
648
642 memcpy (databuf, &bidi_cache_idx, sizeof (bidi_cache_idx)); 649 memcpy (databuf, &bidi_cache_idx, sizeof (bidi_cache_idx));
643 memcpy (databuf + sizeof (bidi_cache_idx), 650 memcpy (databuf + sizeof (bidi_cache_idx),
644 bidi_cache, bidi_cache_idx * sizeof (struct bidi_it)); 651 bidi_cache, bidi_cache_idx * sizeof (struct bidi_it));
@@ -664,7 +671,7 @@ bidi_shelve_cache (void)
664 671
665/* Restore the cache state from a copy stashed away by bidi_shelve_cache. */ 672/* Restore the cache state from a copy stashed away by bidi_shelve_cache. */
666void 673void
667bidi_unshelve_cache (void *databuf) 674bidi_unshelve_cache (void *databuf, int just_free)
668{ 675{
669 unsigned char *p = databuf; 676 unsigned char *p = databuf;
670 677
@@ -677,30 +684,43 @@ bidi_unshelve_cache (void *databuf)
677 } 684 }
678 else 685 else
679 { 686 {
680 memcpy (&bidi_cache_idx, p, sizeof (bidi_cache_idx)); 687 if (just_free)
681 bidi_cache_ensure_space (bidi_cache_idx); 688 {
682 memcpy (bidi_cache, p + sizeof (bidi_cache_idx), 689 ptrdiff_t idx;
683 bidi_cache_idx * sizeof (struct bidi_it)); 690
684 memcpy (bidi_cache_start_stack, 691 memcpy (&idx, p, sizeof (bidi_cache_idx));
685 p + sizeof (bidi_cache_idx) 692 bidi_cache_total_alloc -=
686 + bidi_cache_idx * sizeof (struct bidi_it), 693 bidi_shelve_header_size + idx * sizeof (struct bidi_it);
687 sizeof (bidi_cache_start_stack)); 694 }
688 memcpy (&bidi_cache_sp, 695 else
689 p + sizeof (bidi_cache_idx) 696 {
690 + bidi_cache_idx * sizeof (struct bidi_it) 697 memcpy (&bidi_cache_idx, p, sizeof (bidi_cache_idx));
691 + sizeof (bidi_cache_start_stack), 698 bidi_cache_ensure_space (bidi_cache_idx);
692 sizeof (bidi_cache_sp)); 699 memcpy (bidi_cache, p + sizeof (bidi_cache_idx),
693 memcpy (&bidi_cache_start, 700 bidi_cache_idx * sizeof (struct bidi_it));
694 p + sizeof (bidi_cache_idx) 701 memcpy (bidi_cache_start_stack,
695 + bidi_cache_idx * sizeof (struct bidi_it) 702 p + sizeof (bidi_cache_idx)
696 + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp), 703 + bidi_cache_idx * sizeof (struct bidi_it),
697 sizeof (bidi_cache_start)); 704 sizeof (bidi_cache_start_stack));
698 memcpy (&bidi_cache_last_idx, 705 memcpy (&bidi_cache_sp,
699 p + sizeof (bidi_cache_idx) 706 p + sizeof (bidi_cache_idx)
700 + bidi_cache_idx * sizeof (struct bidi_it) 707 + bidi_cache_idx * sizeof (struct bidi_it)
701 + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp) 708 + sizeof (bidi_cache_start_stack),
702 + sizeof (bidi_cache_start), 709 sizeof (bidi_cache_sp));
703 sizeof (bidi_cache_last_idx)); 710 memcpy (&bidi_cache_start,
711 p + sizeof (bidi_cache_idx)
712 + bidi_cache_idx * sizeof (struct bidi_it)
713 + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp),
714 sizeof (bidi_cache_start));
715 memcpy (&bidi_cache_last_idx,
716 p + sizeof (bidi_cache_idx)
717 + bidi_cache_idx * sizeof (struct bidi_it)
718 + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp)
719 + sizeof (bidi_cache_start),
720 sizeof (bidi_cache_last_idx));
721 bidi_cache_total_alloc -=
722 bidi_shelve_header_size + bidi_cache_idx * sizeof (struct bidi_it);
723 }
704 724
705 xfree (p); 725 xfree (p);
706 } 726 }
@@ -747,6 +767,7 @@ bidi_initialize (void)
747 staticpro (&paragraph_separate_re); 767 staticpro (&paragraph_separate_re);
748 768
749 bidi_cache_sp = 0; 769 bidi_cache_sp = 0;
770 bidi_cache_total_alloc = 0;
750 771
751 bidi_initialized = 1; 772 bidi_initialized = 1;
752} 773}
diff --git a/src/dispextern.h b/src/dispextern.h
index 49761310180..02d1089e3e7 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2979,7 +2979,7 @@ extern int bidi_mirror_char (int);
2979extern void bidi_push_it (struct bidi_it *); 2979extern void bidi_push_it (struct bidi_it *);
2980extern void bidi_pop_it (struct bidi_it *); 2980extern void bidi_pop_it (struct bidi_it *);
2981extern void *bidi_shelve_cache (void); 2981extern void *bidi_shelve_cache (void);
2982extern void bidi_unshelve_cache (void *); 2982extern void bidi_unshelve_cache (void *, int);
2983 2983
2984/* Defined in xdisp.c */ 2984/* Defined in xdisp.c */
2985 2985
diff --git a/src/dispnew.c b/src/dispnew.c
index fde9be6bf5c..5fedbb75a3a 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
5289 argument is ZV to prevent move_it_in_display_line from matching 5289 argument is ZV to prevent move_it_in_display_line from matching
5290 based on buffer positions. */ 5290 based on buffer positions. */
5291 move_it_in_display_line (&it, ZV, to_x, MOVE_TO_X); 5291 move_it_in_display_line (&it, ZV, to_x, MOVE_TO_X);
5292 bidi_unshelve_cache (itdata); 5292 bidi_unshelve_cache (itdata, 0);
5293 5293
5294 Fset_buffer (old_current_buffer); 5294 Fset_buffer (old_current_buffer);
5295 5295
diff --git a/src/indent.c b/src/indent.c
index 37873351aa0..313315e9081 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2126,7 +2126,7 @@ whether or not it is currently displayed in some window. */)
2126 } 2126 }
2127 2127
2128 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); 2128 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
2129 bidi_unshelve_cache (itdata); 2129 bidi_unshelve_cache (itdata, 0);
2130 } 2130 }
2131 2131
2132 if (BUFFERP (old_buffer)) 2132 if (BUFFERP (old_buffer))
diff --git a/src/window.c b/src/window.c
index 04fea6b9bf6..96b1144acf2 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1379,7 +1379,7 @@ if it isn't already recorded. */)
1379 if (it.current_y < it.last_visible_y) 1379 if (it.current_y < it.last_visible_y)
1380 move_it_past_eol (&it); 1380 move_it_past_eol (&it);
1381 value = make_number (IT_CHARPOS (it)); 1381 value = make_number (IT_CHARPOS (it));
1382 bidi_unshelve_cache (itdata); 1382 bidi_unshelve_cache (itdata, 0);
1383 1383
1384 if (old_buffer) 1384 if (old_buffer)
1385 set_buffer_internal (old_buffer); 1385 set_buffer_internal (old_buffer);
@@ -4273,7 +4273,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4273 } 4273 }
4274 4274
4275 start = it.current.pos; 4275 start = it.current.pos;
4276 bidi_unshelve_cache (itdata); 4276 bidi_unshelve_cache (itdata, 0);
4277 } 4277 }
4278 else if (auto_window_vscroll_p) 4278 else if (auto_window_vscroll_p)
4279 { 4279 {
@@ -4417,7 +4417,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4417 } 4417 }
4418 else 4418 else
4419 { 4419 {
4420 bidi_unshelve_cache (itdata); 4420 bidi_unshelve_cache (itdata, 0);
4421 if (noerror) 4421 if (noerror)
4422 return; 4422 return;
4423 else if (n < 0) /* could happen with empty buffers */ 4423 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)
4434 w->vscroll = 0; 4434 w->vscroll = 0;
4435 else 4435 else
4436 { 4436 {
4437 bidi_unshelve_cache (itdata); 4437 bidi_unshelve_cache (itdata, 0);
4438 if (noerror) 4438 if (noerror)
4439 return; 4439 return;
4440 else 4440 else
@@ -4583,7 +4583,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4583 SET_PT_BOTH (charpos, bytepos); 4583 SET_PT_BOTH (charpos, bytepos);
4584 } 4584 }
4585 } 4585 }
4586 bidi_unshelve_cache (itdata); 4586 bidi_unshelve_cache (itdata, 0);
4587} 4587}
4588 4588
4589 4589
@@ -5010,7 +5010,7 @@ displayed_window_lines (struct window *w)
5010 start_display (&it, w, start); 5010 start_display (&it, w, start);
5011 move_it_vertically (&it, height); 5011 move_it_vertically (&it, height);
5012 bottom_y = line_bottom_y (&it); 5012 bottom_y = line_bottom_y (&it);
5013 bidi_unshelve_cache (itdata); 5013 bidi_unshelve_cache (itdata, 0);
5014 5014
5015 /* rms: On a non-window display, 5015 /* rms: On a non-window display,
5016 the value of it.vpos at the bottom of the screen 5016 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. */)
5116 move_it_vertically_backward (&it, window_box_height (w) / 2); 5116 move_it_vertically_backward (&it, window_box_height (w) / 2);
5117 charpos = IT_CHARPOS (it); 5117 charpos = IT_CHARPOS (it);
5118 bytepos = IT_BYTEPOS (it); 5118 bytepos = IT_BYTEPOS (it);
5119 bidi_unshelve_cache (itdata); 5119 bidi_unshelve_cache (itdata, 0);
5120 } 5120 }
5121 else if (iarg < 0) 5121 else if (iarg < 0)
5122 { 5122 {
@@ -5164,7 +5164,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5164 } 5164 }
5165 if (h <= 0) 5165 if (h <= 0)
5166 { 5166 {
5167 bidi_unshelve_cache (itdata); 5167 bidi_unshelve_cache (itdata, 0);
5168 return Qnil; 5168 return Qnil;
5169 } 5169 }
5170 5170
@@ -5187,7 +5187,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5187 charpos = IT_CHARPOS (it); 5187 charpos = IT_CHARPOS (it);
5188 bytepos = IT_BYTEPOS (it); 5188 bytepos = IT_BYTEPOS (it);
5189 5189
5190 bidi_unshelve_cache (itdata); 5190 bidi_unshelve_cache (itdata, 0);
5191 } 5191 }
5192 else 5192 else
5193 { 5193 {
diff --git a/src/xdisp.c b/src/xdisp.c
index bffb7bcdd73..481dd35c5d0 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -604,7 +604,7 @@ int current_mode_line_height, current_header_line_height;
604#define SAVE_IT(ITCOPY,ITORIG,CACHE) \ 604#define SAVE_IT(ITCOPY,ITORIG,CACHE) \
605 do { \ 605 do { \
606 if (CACHE) \ 606 if (CACHE) \
607 xfree (CACHE); \ 607 bidi_unshelve_cache (CACHE, 1); \
608 ITCOPY = ITORIG; \ 608 ITCOPY = ITORIG; \
609 CACHE = bidi_shelve_cache(); \ 609 CACHE = bidi_shelve_cache(); \
610 } while (0) 610 } while (0)
@@ -613,7 +613,7 @@ int current_mode_line_height, current_header_line_height;
613 do { \ 613 do { \
614 if (pITORIG != pITCOPY) \ 614 if (pITORIG != pITCOPY) \
615 *(pITORIG) = *(pITCOPY); \ 615 *(pITORIG) = *(pITCOPY); \
616 bidi_unshelve_cache (CACHE); \ 616 bidi_unshelve_cache (CACHE, 0); \
617 CACHE = NULL; \ 617 CACHE = NULL; \
618 } while (0) 618 } while (0)
619 619
@@ -1341,9 +1341,9 @@ pos_visible_p (struct window *w, EMACS_INT charpos, int *x, int *y,
1341 *vpos = it2.vpos; 1341 *vpos = it2.vpos;
1342 } 1342 }
1343 else 1343 else
1344 xfree (it2data); 1344 bidi_unshelve_cache (it2data, 1);
1345 } 1345 }
1346 bidi_unshelve_cache (itdata); 1346 bidi_unshelve_cache (itdata, 0);
1347 1347
1348 if (old_buffer) 1348 if (old_buffer)
1349 set_buffer_internal_1 (old_buffer); 1349 set_buffer_internal_1 (old_buffer);
@@ -2624,7 +2624,7 @@ init_iterator (struct it *it, struct window *w,
2624 it->paragraph_embedding = R2L; 2624 it->paragraph_embedding = R2L;
2625 else 2625 else
2626 it->paragraph_embedding = NEUTRAL_DIR; 2626 it->paragraph_embedding = NEUTRAL_DIR;
2627 bidi_unshelve_cache (NULL); 2627 bidi_unshelve_cache (NULL, 0);
2628 bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f), 2628 bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f),
2629 &it->bidi_it); 2629 &it->bidi_it);
2630 } 2630 }
@@ -5615,7 +5615,7 @@ back_to_previous_visible_line_start (struct it *it)
5615 pos = --IT_CHARPOS (it2); 5615 pos = --IT_CHARPOS (it2);
5616 --IT_BYTEPOS (it2); 5616 --IT_BYTEPOS (it2);
5617 it2.sp = 0; 5617 it2.sp = 0;
5618 bidi_unshelve_cache (NULL); 5618 bidi_unshelve_cache (NULL, 0);
5619 it2.string_from_display_prop_p = 0; 5619 it2.string_from_display_prop_p = 0;
5620 it2.from_disp_prop_p = 0; 5620 it2.from_disp_prop_p = 0;
5621 if (handle_display_prop (&it2) == HANDLED_RETURN 5621 if (handle_display_prop (&it2) == HANDLED_RETURN
@@ -5825,7 +5825,7 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p)
5825 { 5825 {
5826 bidi_init_it (IT_CHARPOS (*it), IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f), 5826 bidi_init_it (IT_CHARPOS (*it), IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f),
5827 &it->bidi_it); 5827 &it->bidi_it);
5828 bidi_unshelve_cache (NULL); 5828 bidi_unshelve_cache (NULL, 0);
5829 it->bidi_it.paragraph_dir = NEUTRAL_DIR; 5829 it->bidi_it.paragraph_dir = NEUTRAL_DIR;
5830 it->bidi_it.string.s = NULL; 5830 it->bidi_it.string.s = NULL;
5831 it->bidi_it.string.lstring = Qnil; 5831 it->bidi_it.string.lstring = Qnil;
@@ -8006,13 +8006,13 @@ move_it_in_display_line_to (struct it *it,
8006 positions smaller than TO_CHARPOS, return 8006 positions smaller than TO_CHARPOS, return
8007 MOVE_POS_MATCH_OR_ZV, like the unidirectional display 8007 MOVE_POS_MATCH_OR_ZV, like the unidirectional display
8008 did. */ 8008 did. */
8009 if ((op & MOVE_TO_POS) != 0 8009 if (it->bidi_p && (op & MOVE_TO_POS) != 0
8010 && !saw_smaller_pos 8010 && !saw_smaller_pos
8011 && IT_CHARPOS (*it) > to_charpos) 8011 && IT_CHARPOS (*it) > to_charpos)
8012 { 8012 {
8013 result = MOVE_POS_MATCH_OR_ZV; 8013 if (IT_CHARPOS (ppos_it) < ZV)
8014 if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV)
8015 RESTORE_IT (it, &ppos_it, ppos_data); 8014 RESTORE_IT (it, &ppos_it, ppos_data);
8015 goto buffer_pos_reached;
8016 } 8016 }
8017 else 8017 else
8018 result = MOVE_NEWLINE_OR_CR; 8018 result = MOVE_NEWLINE_OR_CR;
@@ -8051,14 +8051,13 @@ move_it_in_display_line_to (struct it *it,
8051 character positions smaller than TO_CHARPOS, 8051 character positions smaller than TO_CHARPOS,
8052 return MOVE_POS_MATCH_OR_ZV, like the 8052 return MOVE_POS_MATCH_OR_ZV, like the
8053 unidirectional display did. */ 8053 unidirectional display did. */
8054 || ((op & MOVE_TO_POS) != 0 8054 || (it->bidi_p && (op & MOVE_TO_POS) != 0
8055 && !saw_smaller_pos 8055 && !saw_smaller_pos
8056 && IT_CHARPOS (*it) > to_charpos)) 8056 && IT_CHARPOS (*it) > to_charpos))
8057 { 8057 {
8058 result = MOVE_POS_MATCH_OR_ZV; 8058 if (!at_eob_p && IT_CHARPOS (ppos_it) < ZV)
8059 if (it->bidi_p && !at_eob_p && IT_CHARPOS (ppos_it) < ZV)
8060 RESTORE_IT (it, &ppos_it, ppos_data); 8059 RESTORE_IT (it, &ppos_it, ppos_data);
8061 break; 8060 goto buffer_pos_reached;
8062 } 8061 }
8063 if (ITERATOR_AT_END_OF_LINE_P (it)) 8062 if (ITERATOR_AT_END_OF_LINE_P (it))
8064 { 8063 {
@@ -8066,14 +8065,13 @@ move_it_in_display_line_to (struct it *it,
8066 break; 8065 break;
8067 } 8066 }
8068 } 8067 }
8069 else if ((op & MOVE_TO_POS) != 0 8068 else if (it->bidi_p && (op & MOVE_TO_POS) != 0
8070 && !saw_smaller_pos 8069 && !saw_smaller_pos
8071 && IT_CHARPOS (*it) > to_charpos) 8070 && IT_CHARPOS (*it) > to_charpos)
8072 { 8071 {
8073 result = MOVE_POS_MATCH_OR_ZV; 8072 if (IT_CHARPOS (ppos_it) < ZV)
8074 if (it->bidi_p && IT_CHARPOS (ppos_it) < ZV)
8075 RESTORE_IT (it, &ppos_it, ppos_data); 8073 RESTORE_IT (it, &ppos_it, ppos_data);
8076 break; 8074 goto buffer_pos_reached;
8077 } 8075 }
8078 result = MOVE_LINE_TRUNCATED; 8076 result = MOVE_LINE_TRUNCATED;
8079 break; 8077 break;
@@ -8093,13 +8091,13 @@ move_it_in_display_line_to (struct it *it,
8093 done: 8091 done:
8094 8092
8095 if (atpos_data) 8093 if (atpos_data)
8096 xfree (atpos_data); 8094 bidi_unshelve_cache (atpos_data, 1);
8097 if (atx_data) 8095 if (atx_data)
8098 xfree (atx_data); 8096 bidi_unshelve_cache (atx_data, 1);
8099 if (wrap_data) 8097 if (wrap_data)
8100 xfree (wrap_data); 8098 bidi_unshelve_cache (wrap_data, 1);
8101 if (ppos_data) 8099 if (ppos_data)
8102 xfree (ppos_data); 8100 bidi_unshelve_cache (ppos_data, 1);
8103 8101
8104 /* Restore the iterator settings altered at the beginning of this 8102 /* Restore the iterator settings altered at the beginning of this
8105 function. */ 8103 function. */
@@ -8134,7 +8132,7 @@ move_it_in_display_line (struct it *it,
8134 (it, -1, prev_x, MOVE_TO_X); 8132 (it, -1, prev_x, MOVE_TO_X);
8135 } 8133 }
8136 else 8134 else
8137 xfree (save_data); 8135 bidi_unshelve_cache (save_data, 1);
8138 } 8136 }
8139 else 8137 else
8140 move_it_in_display_line_to (it, to_charpos, to_x, op); 8138 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
8393 } 8391 }
8394 8392
8395 if (backup_data) 8393 if (backup_data)
8396 xfree (backup_data); 8394 bidi_unshelve_cache (backup_data, 1);
8397 8395
8398 TRACE_MOVE ((stderr, "move_it_to: reached %d\n", reached)); 8396 TRACE_MOVE ((stderr, "move_it_to: reached %d\n", reached));
8399} 8397}
@@ -8472,7 +8470,7 @@ move_it_vertically_backward (struct it *it, int dy)
8472 RESTORE_IT (it, it, it2data); 8470 RESTORE_IT (it, it, it2data);
8473 if (nlines > 0) 8471 if (nlines > 0)
8474 move_it_by_lines (it, nlines); 8472 move_it_by_lines (it, nlines);
8475 xfree (it3data); 8473 bidi_unshelve_cache (it3data, 1);
8476 } 8474 }
8477 else 8475 else
8478 { 8476 {
@@ -8668,7 +8666,7 @@ move_it_by_lines (struct it *it, int dvpos)
8668 if (IT_CHARPOS (*it) >= start_charpos) 8666 if (IT_CHARPOS (*it) >= start_charpos)
8669 RESTORE_IT (it, &it2, it2data); 8667 RESTORE_IT (it, &it2, it2data);
8670 else 8668 else
8671 xfree (it2data); 8669 bidi_unshelve_cache (it2data, 1);
8672 } 8670 }
8673 else 8671 else
8674 RESTORE_IT (it, it, it2data); 8672 RESTORE_IT (it, it, it2data);
@@ -13704,14 +13702,12 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
13704 w->cursor.vpos >= 0 13702 w->cursor.vpos >= 0
13705 /* that candidate is not the row we are processing */ 13703 /* that candidate is not the row we are processing */
13706 && MATRIX_ROW (matrix, w->cursor.vpos) != row 13704 && MATRIX_ROW (matrix, w->cursor.vpos) != row
13707 /* the row we are processing is part of a continued line */
13708 && (row->continued_p || MATRIX_ROW_CONTINUATION_LINE_P (row))
13709 /* Make sure cursor.vpos specifies a row whose start and end 13705 /* Make sure cursor.vpos specifies a row whose start and end
13710 charpos occlude point. This is because some callers of this 13706 charpos occlude point. This is because some callers of this
13711 function leave cursor.vpos at the row where the cursor was 13707 function leave cursor.vpos at the row where the cursor was
13712 displayed during the last redisplay cycle. */ 13708 displayed during the last redisplay cycle. */
13713 && MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) <= pt_old 13709 && MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) <= pt_old
13714 && pt_old < MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos))) 13710 && pt_old <= MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)))
13715 { 13711 {
13716 struct glyph *g1 = 13712 struct glyph *g1 =
13717 MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos; 13713 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,
13720 if (!(row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end)) 13716 if (!(row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end))
13721 return 0; 13717 return 0;
13722 /* Keep the candidate whose buffer position is the closest to 13718 /* Keep the candidate whose buffer position is the closest to
13723 point. */ 13719 point or has the `cursor' property. */
13724 if (/* previous candidate is a glyph in TEXT_AREA of that row */ 13720 if (/* previous candidate is a glyph in TEXT_AREA of that row */
13725 w->cursor.hpos >= 0 13721 w->cursor.hpos >= 0
13726 && w->cursor.hpos < MATRIX_ROW_USED (matrix, w->cursor.vpos) 13722 && w->cursor.hpos < MATRIX_ROW_USED (matrix, w->cursor.vpos)
13727 && BUFFERP (g1->object) 13723 && ((BUFFERP (g1->object)
13728 && (g1->charpos == pt_old /* an exact match always wins */ 13724 && (g1->charpos == pt_old /* an exact match always wins */
13729 || (BUFFERP (glyph->object) 13725 || (BUFFERP (glyph->object)
13730 && eabs (g1->charpos - pt_old) 13726 && eabs (g1->charpos - pt_old)
13731 < eabs (glyph->charpos - pt_old)))) 13727 < eabs (glyph->charpos - pt_old))))
13728 /* previous candidate is a glyph from a string that has
13729 a non-nil `cursor' property */
13730 || (STRINGP (g1->object)
13731 && !NILP (Fget_char_property (make_number (g1->charpos),
13732 Qcursor, g1->object)))))
13732 return 0; 13733 return 0;
13733 /* If this candidate gives an exact match, use that. */ 13734 /* If this candidate gives an exact match, use that. */
13734 if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old) 13735 if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old)
@@ -18774,6 +18775,9 @@ display_line (struct it *it)
18774 } 18775 }
18775 } 18776 }
18776 18777
18778 if (wrap_data)
18779 bidi_unshelve_cache (wrap_data, 1);
18780
18777 /* If line is not empty and hscrolled, maybe insert truncation glyphs 18781 /* If line is not empty and hscrolled, maybe insert truncation glyphs
18778 at the left window margin. */ 18782 at the left window margin. */
18779 if (it->first_visible_x 18783 if (it->first_visible_x