* lisp/subr.el (string-mark-left-to-right): New function.
* lisp/buff-menu.el (Buffer-menu-buffer+size): Remove LRM argument.
Use string-mark-left-to-right.
(list-buffers-noselect): Caller changed.
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Use
string-mark-left-to-right.
(tabulated-list-print): Recenter after moving point.
*** New function `special-variable-p' to check whether a variable is
declared as dynamically bound.
+** New function `string-mark-left-to-right' appends a Unicode LRM
+(left-to-right mark) character to a string if it terminates in
+right-to-left script. This is useful when the buffer has overall
+left-to-right paragraph direction and you need to insert a string
+whose contents (and directionality) are not known in advance.
+
** pre/post-command-hook are not reset to nil upon error.
Instead, the offending function is removed.
+2011-08-10 Chong Yidong <cyd@stupidchicken.com>
+
+ * subr.el (string-mark-left-to-right): New function.
+
+ * buff-menu.el (Buffer-menu-buffer+size): Remove LRM argument.
+ Use string-mark-left-to-right.
+ (list-buffers-noselect): Caller changed.
+
+ * emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Use
+ string-mark-left-to-right.
+ (tabulated-list-print): Recenter after moving point.
+
2011-08-10 Juri Linkov <juri@jurta.org>
* progmodes/grep.el (rgrep): Don't bind `process-connection-type'.
":" ;; (if (char-displayable-p ?…) "…" ":")
)
-(defun Buffer-menu-buffer+size (name size &optional name-props size-props lrm)
+(defun Buffer-menu-buffer+size (name size &optional name-props size-props)
(if (> (+ (string-width name) (string-width size) 2)
Buffer-menu-buffer+size-width)
(setq name
(string-width tail)
2))
Buffer-menu-short-ellipsis
- tail
- ;; Append an invisible LRM character to the
- ;; buffer's name to avoid ugly display with the
- ;; buffer size to the left of the name, when the
- ;; name begins with R2L character.
- (if lrm (propertize (string ?\x200e) 'invisible t) ""))))
+ (string-mark-left-to-right tail))))
;; Don't put properties on (buffer-name).
- (setq name (concat (copy-sequence name)
- (if lrm
- (propertize (string ?\x200e) 'invisible t)
- ""))))
+ (setq name (string-mark-left-to-right name)))
(add-text-properties 0 (length name) name-props name)
(add-text-properties 0 (length size) size-props size)
(let ((name+space-width (- Buffer-menu-buffer+size-width
(max (length size) 3)
2))
name
- "mouse-2: select this buffer"))
- nil t))
+ "mouse-2: select this buffer"))))
" "
(if (> (string-width (nth 4 buffer)) Buffer-menu-mode-width)
(truncate-string-to-width (nth 4 buffer)
;; If REMEMBER-POS was specified, move to the "old" location.
(if saved-pt
(progn (goto-char saved-pt)
- (move-to-column saved-col))
+ (move-to-column saved-col)
+ (recenter))
(goto-char (point-min)))))
(defun tabulated-list-print-entry (id cols)
(> (length label) width)
(setq label (concat (substring label 0 (- width 3))
"...")))
+ (setq label (string-mark-left-to-right label))
(if (stringp desc)
(insert (propertize label 'help-echo help-echo))
(apply 'insert-text-button label (cdr desc)))
to case differences."
(eq t (compare-strings str1 nil nil
str2 0 (length str1) ignore-case)))
+
+(defun string-mark-left-to-right (str)
+ "Return a string that can be safely embedded in left-to-right text.
+If STR ends in right-to-left (RTL) script, return a string
+consisting of STR followed by an invisible left-to-right
+mark (LRM) character. Otherwise, return STR."
+ (unless (stringp str)
+ (signal 'wrong-type-argument (list 'stringp str)))
+ (if (and (> (length str) 0)
+ (eq (get-char-code-property (aref str (1- (length str)))
+ 'bidi-class)
+ 'R))
+ (concat str (propertize (string ?\x200e) 'invisible t))
+ str))
\f
;;;; invisibility specs