commit 9e4a6ad1c77c62e4a7d5b708567e5a1e23b9cdfd (HEAD, refs/remotes/origin/master) Author: Tassilo Horn Date: Thu Oct 1 08:07:40 2015 +0200 Un- and re-prettification are not exclusive * lisp/progmodes/prog-mode.el (prettify-symbols--post-command-hook): Re-apply prettification to previous symbol also when unprettifying next one. diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 90c496f..6696356 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -209,21 +209,23 @@ on the symbol." (when (and (eq prettify-symbols-unprettify-at-point 'right-edge) (not (bobp))) (get-text-property (1- (point)) prop)))))) - (if-let ((c (get-prop-as-list 'composition)) - (s (get-prop-as-list 'prettify-symbols-start)) - (e (get-prop-as-list 'prettify-symbols-end)) - (s (apply #'min s)) - (e (apply #'max e))) - (with-silent-modifications - (setq prettify-symbols--current-symbol-bounds (list s e)) - (remove-text-properties s e '(composition))) - (when (and prettify-symbols--current-symbol-bounds - (or (< (point) (car prettify-symbols--current-symbol-bounds)) - (> (point) (cadr prettify-symbols--current-symbol-bounds)) - (and (not (eq prettify-symbols-unprettify-at-point 'right-edge)) - (= (point) (cadr prettify-symbols--current-symbol-bounds))))) - (apply #'font-lock-flush prettify-symbols--current-symbol-bounds) - (setq prettify-symbols--current-symbol-bounds nil))))) + ;; Re-apply prettification to the previous symbol. + (when (and prettify-symbols--current-symbol-bounds + (or (< (point) (car prettify-symbols--current-symbol-bounds)) + (> (point) (cadr prettify-symbols--current-symbol-bounds)) + (and (not (eq prettify-symbols-unprettify-at-point 'right-edge)) + (= (point) (cadr prettify-symbols--current-symbol-bounds))))) + (apply #'font-lock-flush prettify-symbols--current-symbol-bounds) + (setq prettify-symbols--current-symbol-bounds nil)) + ;; Unprettify the current symbol. + (when-let ((c (get-prop-as-list 'composition)) + (s (get-prop-as-list 'prettify-symbols-start)) + (e (get-prop-as-list 'prettify-symbols-end)) + (s (apply #'min s)) + (e (apply #'max e))) + (with-silent-modifications + (setq prettify-symbols--current-symbol-bounds (list s e)) + (remove-text-properties s e '(composition)))))) ;;;###autoload (define-minor-mode prettify-symbols-mode commit 35ad158f3d4b2481dcf5cca201697b42b1ba563e Author: Tassilo Horn Date: Thu Oct 1 07:54:45 2015 +0200 Don't unprettify symbol at point by default * lisp/progmodes/prog-mode.el (prettify-symbols-unprettify-at-point): Default to disabled (nil). diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 1192cb1..90c496f 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -189,7 +189,7 @@ Regexp match data 0 points to the chars." (defvar-local prettify-symbols--current-symbol-bounds nil) -(defcustom prettify-symbols-unprettify-at-point t +(defcustom prettify-symbols-unprettify-at-point nil "If non-nil, show the non-prettified version of a symbol when point is on it. If set to the symbol `right-edge', also unprettify if point is immediately after the symbol. The prettification will be commit cbae4820f9a328250c06d3c6a5d34864c800cacb Author: Artur Malabarba Date: Thu Oct 1 01:38:20 2015 +0100 * lisp/progmodes/prog-mode.el (prettify-symbols-unprettify-at-point): Support unprettifying when point is after a symbol. * etc/NEWS: Document `prettify-symbols-unprettify-at-point' diff --git a/etc/NEWS b/etc/NEWS index 26f0474..ac9a600 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -318,13 +318,17 @@ standards. ** Prog mode has some support for multi-mode indentation. See `prog-indentation-context' and `prog-widen'. -** Prettify Symbols mode supports custom composition predicates. By +** Prettify Symbols mode +*** Prettify Symbols mode supports custom composition predicates. By overriding the default `prettify-symbols-compose-predicate', modes can specify in which contexts a symbol map be composed to some unicode character. `prettify-symbols-default-compose-p' is the default which is suitable for most programming languages such as C or Lisp (but not (La)TeX). +*** Symbols are not prettified while point is inside them. +New variable `prettify-symbols-unprettify-at-point' configures this. + ** New `xterm-screen-extra-capabilities' config. ** The `save-place' variable is replaced by a `save-place-mode'. diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index e092e24..1192cb1 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -189,27 +189,42 @@ Regexp match data 0 points to the chars." (defvar-local prettify-symbols--current-symbol-bounds nil) -(defun prettify-symbols--post-command-hook () - (if-let ((c (get-text-property (point) 'composition)) - (s (get-text-property (point) 'prettify-symbols-start)) - (e (get-text-property (point) 'prettify-symbols-end))) - (with-silent-modifications - (setq prettify-symbols--current-symbol-bounds (list s e)) - (remove-text-properties s e '(composition))) - (when (and prettify-symbols--current-symbol-bounds - (or (< (point) (car prettify-symbols--current-symbol-bounds)) - (>= (point) (cadr prettify-symbols--current-symbol-bounds)))) - (apply #'font-lock-flush prettify-symbols--current-symbol-bounds) - (setq prettify-symbols--current-symbol-bounds nil)))) - (defcustom prettify-symbols-unprettify-at-point t "If non-nil, show the non-prettified version of a symbol when point is on it. -The prettification will be reapplied as soon as point moves away -from the symbol. If set to nil, the prettification persists even -when point is on the symbol." - :type 'boolean +If set to the symbol `right-edge', also unprettify if point +is immediately after the symbol. The prettification will be +reapplied as soon as point moves away from the symbol. If +set to nil, the prettification persists even when point is +on the symbol." + :type '(choice (const :tag "Never unprettify" nil) + (const :tag "Unprettify when point is inside" t) + (const :tag "Unprettify when point is inside or at right edge" right-edge)) :group 'prog-mode) +(defun prettify-symbols--post-command-hook () + (cl-labels ((get-prop-as-list + (prop) + (remove nil + (list (get-text-property (point) prop) + (when (and (eq prettify-symbols-unprettify-at-point 'right-edge) + (not (bobp))) + (get-text-property (1- (point)) prop)))))) + (if-let ((c (get-prop-as-list 'composition)) + (s (get-prop-as-list 'prettify-symbols-start)) + (e (get-prop-as-list 'prettify-symbols-end)) + (s (apply #'min s)) + (e (apply #'max e))) + (with-silent-modifications + (setq prettify-symbols--current-symbol-bounds (list s e)) + (remove-text-properties s e '(composition))) + (when (and prettify-symbols--current-symbol-bounds + (or (< (point) (car prettify-symbols--current-symbol-bounds)) + (> (point) (cadr prettify-symbols--current-symbol-bounds)) + (and (not (eq prettify-symbols-unprettify-at-point 'right-edge)) + (= (point) (cadr prettify-symbols--current-symbol-bounds))))) + (apply #'font-lock-flush prettify-symbols--current-symbol-bounds) + (setq prettify-symbols--current-symbol-bounds nil))))) + ;;;###autoload (define-minor-mode prettify-symbols-mode "Toggle Prettify Symbols mode. commit 4a6780ea89009806928617a5ccf0e21d646452a7 Author: Eli Zaretskii Date: Wed Sep 30 22:43:42 2015 +0300 Avoid assertion violations in push_prefix_prop * src/xdisp.c (push_prefix_prop): Avoid assertion violations when a line that has a line-prefix defined starts with an image. (Bug#21428) diff --git a/src/xdisp.c b/src/xdisp.c index 41b8446..bc76384 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -19836,7 +19836,8 @@ push_prefix_prop (struct it *it, Lisp_Object prop) eassert (it->method == GET_FROM_BUFFER || it->method == GET_FROM_DISPLAY_VECTOR - || it->method == GET_FROM_STRING); + || it->method == GET_FROM_STRING + || it->method == GET_FROM_IMAGE); /* We need to save the current buffer/string position, so it will be restored by pop_it, because iterate_out_of_display_property commit 80a86074a8cbbfc8dffb54c9d872b47e2bdfd701 Author: Eli Zaretskii Date: Wed Sep 30 22:42:59 2015 +0300 ; Revert inadvertent premature commit. diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index c0f9959..62d18e2 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -2315,35 +2315,6 @@ the end of the current result or async record is reached." ; list ==> ; "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]" -;; The idea of the following function was suggested -;; by Kenichi Handa . -;; -;; FIXME: This is fragile: it relies on the assumption that all the -;; non-ASCII strings output by GDB, including names of the source -;; files, values of string variables in the inferior, etc., are all -;; encoded in the same encoding. It also assumes that the \nnn -;; sequences are not split between chunks of GDB process output due to -;; buffering, and arrive together. When/if GDB acquires the ability -;; to not escape-protect non-ASCII characters in its MI output, this -;; kludge should be removed. -(defun gdb-mi-decode (string) - "Decode octal escapes in MI output STRING into multibyte text." - (let ((coding - (with-current-buffer - (gdb-get-buffer-create 'gdb-partial-output-buffer) - buffer-file-coding-system))) - (with-temp-buffer - (set-buffer-multibyte nil) - (insert (gdb-mi-quote string)) - (goto-char (point-min)) - ;; gdb-mi-quote quotes the octal escapes as well, which - ;; interferes with their interpretation by 'read' below. Remove - ;; the extra backslashes to countermand that. - (while (re-search-forward "\\\\\\(\\\\[2-3][0-7][0-7]\\)" nil t) - (replace-match "\\1" nil nil)) - (goto-char (point-min)) - (decode-coding-string (read (current-buffer)) coding)))) - (defun gud-gdbmi-marker-filter (string) "Filter GDB/MI output." commit 5c9304ea86b8cfc9d0b6d7769b90bd56e5dd1313 Author: Eli Zaretskii Date: Wed Sep 30 22:32:14 2015 +0300 Disable some display optimizations when frames need redisplay These optimizations were previously disabled by the windows_or_buffers_changed flag, which now is not set when only some frames need to be redrawn. * src/xdisp.c (redisplay_internal): Redisplay any frame whose 'redisplay' flag is set. (try_window_reusing_current_matrix, try_window_id) (try_cursor_movement): Disable these optimizations when the frame's 'redisplay' flag is set. diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 3860c81..c0f9959 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -2315,6 +2315,34 @@ the end of the current result or async record is reached." ; list ==> ; "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]" +;; The idea of the following function was suggested +;; by Kenichi Handa . +;; +;; FIXME: This is fragile: it relies on the assumption that all the +;; non-ASCII strings output by GDB, including names of the source +;; files, values of string variables in the inferior, etc., are all +;; encoded in the same encoding. It also assumes that the \nnn +;; sequences are not split between chunks of GDB process output due to +;; buffering, and arrive together. When/if GDB acquires the ability +;; to not escape-protect non-ASCII characters in its MI output, this +;; kludge should be removed. +(defun gdb-mi-decode (string) + "Decode octal escapes in MI output STRING into multibyte text." + (let ((coding + (with-current-buffer + (gdb-get-buffer-create 'gdb-partial-output-buffer) + buffer-file-coding-system))) + (with-temp-buffer + (set-buffer-multibyte nil) + (insert (gdb-mi-quote string)) + (goto-char (point-min)) + ;; gdb-mi-quote quotes the octal escapes as well, which + ;; interferes with their interpretation by 'read' below. Remove + ;; the extra backslashes to countermand that. + (while (re-search-forward "\\\\\\(\\\\[2-3][0-7][0-7]\\)" nil t) + (replace-match "\\1" nil nil)) + (goto-char (point-min)) + (decode-coding-string (read (current-buffer)) coding)))) (defun gud-gdbmi-marker-filter (string) "Filter GDB/MI output." diff --git a/src/xdisp.c b/src/xdisp.c index 259c363..41b8446 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -13336,6 +13336,9 @@ redisplay_internal (void) /* True means redisplay has to redisplay the miniwindow. */ bool update_miniwindow_p = false; + /* True means we need to redraw frames whose 'redisplay' bit is set. */ + bool consider_some_frames_p = false; + TRACE ((stderr, "redisplay_internal %d\n", redisplaying_p)); /* No redisplay if running in batch mode or frame is not yet fully @@ -13555,6 +13558,7 @@ redisplay_internal (void) && !FRAME_OBSCURED_P (XFRAME (w->frame)) && !XFRAME (w->frame)->cursor_type_changed && !XFRAME (w->frame)->face_change + && !XFRAME (w->frame)->redisplay /* Make sure recorded data applies to current buffer, etc. */ && this_line_buffer == current_buffer && match_p @@ -13750,13 +13754,29 @@ redisplay_internal (void) #endif /* Build desired matrices, and update the display. If - consider_all_windows_p, do it for all windows on all frames. - Otherwise do it for selected_window, only. */ + consider_all_windows_p, do it for all windows on all frames. If + a frame's 'redisplay' flag is set, do it for all windows on each + such frame. Otherwise do it for selected_window, only. */ - if (consider_all_windows_p) + if (!consider_all_windows_p) { FOR_EACH_FRAME (tail, frame) - XFRAME (frame)->updated_p = false; + { + if (XFRAME (frame)->redisplay && XFRAME (frame) != sf) + { + consider_some_frames_p = true; + break; + } + } + } + + if (consider_all_windows_p || consider_some_frames_p) + { + FOR_EACH_FRAME (tail, frame) + { + if (XFRAME (frame)->redisplay || consider_all_windows_p) + XFRAME (frame)->updated_p = false; + } propagate_buffer_redisplay (); @@ -13770,6 +13790,9 @@ redisplay_internal (void) && !EQ (FRAME_TTY (f)->top_frame, frame)) continue; + if (!consider_all_windows_p && !f->redisplay) + continue; + retry_frame: if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf) { @@ -15415,6 +15438,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, && !update_mode_lines && !windows_or_buffers_changed && !f->cursor_type_changed + && !f->redisplay && NILP (Vshow_trailing_whitespace) /* This code is not used for mini-buffer for the sake of the case of redisplaying to replace an echo area message; since in @@ -17025,6 +17049,7 @@ try_window_reusing_current_matrix (struct window *w) /* Don't try to reuse the display if windows have been split or such. */ || windows_or_buffers_changed + || f->redisplay || f->cursor_type_changed) return false; @@ -17802,7 +17827,7 @@ try_window_id (struct window *w) GIVE_UP (1); /* This flag is used to prevent redisplay optimizations. */ - if (windows_or_buffers_changed || f->cursor_type_changed) + if (windows_or_buffers_changed || f->cursor_type_changed || f->redisplay) GIVE_UP (2); /* This function's optimizations cannot be used if overlays have commit 82df1878e6559188e688195f992fff10f35035e8 Author: Tassilo Horn Date: Wed Sep 30 20:15:22 2015 +0200 Don't modify buffer by unprettification * lisp/progmodes/prog-mode.el (prettify-symbols--compose-symbol): (prettify-symbols--post-command-hook, prettify-symbols-mode): Don't modify buffer when setting/removing custom prettify-symbols-start/end text properties. Add them to font-lock-extra-managed-props, too. diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index b408509..e092e24 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -165,7 +165,7 @@ Regexp match data 0 points to the chars." (if (and (not (equal prettify-symbols--current-symbol-bounds (list start end))) (funcall prettify-symbols-compose-predicate start end match)) ;; That's a symbol alright, so add the composition. - (progn + (with-silent-modifications (compose-region start end (cdr (assoc match alist))) (add-text-properties start end @@ -193,7 +193,7 @@ Regexp match data 0 points to the chars." (if-let ((c (get-text-property (point) 'composition)) (s (get-text-property (point) 'prettify-symbols-start)) (e (get-text-property (point) 'prettify-symbols-end))) - (progn + (with-silent-modifications (setq prettify-symbols--current-symbol-bounds (list s e)) (remove-text-properties s e '(composition))) (when (and prettify-symbols--current-symbol-bounds @@ -236,7 +236,10 @@ support it." (when (setq prettify-symbols--keywords (prettify-symbols--make-keywords)) (font-lock-add-keywords nil prettify-symbols--keywords) (setq-local font-lock-extra-managed-props - (cons 'composition font-lock-extra-managed-props)) + (append font-lock-extra-managed-props + '(composition + prettify-symbols-start + prettify-symbols-end))) (when prettify-symbols-unprettify-at-point (add-hook 'post-command-hook #'prettify-symbols--post-command-hook nil t)) commit 8b1df960131a173779e88df605a21ebc0443634a Author: Stefan Monnier Date: Wed Sep 30 10:00:13 2015 -0400 Try to avoid redisplaying all frames when creating a new one * src/xfns.c (x_set_menu_bar_lines, x_change_tool_bar_height): * src/xfaces.c (Finternal_make_lisp_face, Finternal_copy_lisp_face) (Finternal_set_lisp_face_attribute, update_face_from_frame_parameter): * src/frame.c (x_set_screen_gamma): Set the specific frame's `redisplay' bit rather than windows_or_buffers_changed. * src/window.c (apply_window_adjustment): Remove redundant setting of windows_or_buffers_changed. * src/xdisp.c (redisplay_internal): Set the specific frame's `redisplay' bit rather than update_mode_lines in response to cursor_type_changed. (syms_of_xdisp): Use hash-tables for redisplay_*_cause tables. (AINC): Adjust accordingly. diff --git a/src/frame.c b/src/frame.c index 121c55f..f1a78fb 100644 --- a/src/frame.c +++ b/src/frame.c @@ -3539,8 +3539,8 @@ x_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu (f, bgcolor, Qnil); } - clear_face_cache (true); - windows_or_buffers_changed = 70; + clear_face_cache (true); /* FIXME: Why of all frames? */ + fset_redisplay (f); } diff --git a/src/window.c b/src/window.c index d61f586..6d06e54 100644 --- a/src/window.c +++ b/src/window.c @@ -6609,7 +6609,6 @@ apply_window_adjustment (struct window *w) eassert (w); clear_glyph_matrix (w->current_matrix); w->window_end_valid = false; - windows_or_buffers_changed = 30; wset_redisplay (w); adjust_frame_glyphs (XFRAME (WINDOW_FRAME (w))); } diff --git a/src/xdisp.c b/src/xdisp.c index 863d891..259c363 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -13432,7 +13432,7 @@ redisplay_internal (void) /* If cursor type has been changed on the frame other than selected, consider all frames. */ if (f != sf && f->cursor_type_changed) - update_mode_lines = 31; + fset_redisplay (f); } clear_desired_matrices (f); } @@ -13530,9 +13530,12 @@ redisplay_internal (void) consider_all_windows_p = (update_mode_lines || windows_or_buffers_changed); -#define AINC(a,i) \ - if (VECTORP (a) && i >= 0 && i < ASIZE (a) && INTEGERP (AREF (a, i))) \ - ASET (a, i, make_number (1 + XINT (AREF (a, i)))) +#define AINC(a,i) \ + { \ + Lisp_Object entry = Fgethash (make_number (i), a, make_number (0)); \ + if (INTEGERP (entry)) \ + Fputhash (make_number (i), make_number (1 + XINT (entry)), a); \ + } AINC (Vredisplay__all_windows_cause, windows_or_buffers_changed); AINC (Vredisplay__mode_lines_cause, update_mode_lines); @@ -31387,13 +31390,11 @@ display table takes effect; in this case, Emacs does not consult DEFVAR_LISP ("redisplay--all-windows-cause", Vredisplay__all_windows_cause, doc: /* */); - Vredisplay__all_windows_cause - = Fmake_vector (make_number (100), make_number (0)); + Vredisplay__all_windows_cause = Fmake_hash_table (0, NULL); DEFVAR_LISP ("redisplay--mode-lines-cause", Vredisplay__mode_lines_cause, doc: /* */); - Vredisplay__mode_lines_cause - = Fmake_vector (make_number (100), make_number (0)); + Vredisplay__mode_lines_cause = Fmake_hash_table (0, NULL); } diff --git a/src/xfaces.c b/src/xfaces.c index 40713f1..8cf0b42 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -631,7 +631,7 @@ free_frame_faces (struct frame *f) /* Clear face caches, and recompute basic faces for frame F. Call this after changing frame parameters on which those faces depend, or when realized faces have been freed due to changing attributes - of named faces. */ + of named faces. */ void recompute_basic_faces (struct frame *f) @@ -2528,10 +2528,15 @@ Value is a vector of face attributes. */) if (NILP (Fget (face, Qface_no_inherit))) { if (f) - f->face_change = 1; + { + f->face_change = true; + fset_redisplay (f); + } else - face_change = true; - windows_or_buffers_changed = 54; + { + face_change = true; + windows_or_buffers_changed = 54; + } } eassert (LFACEP (lface)); @@ -2613,10 +2618,15 @@ The value is TO. */) if (NILP (Fget (to, Qface_no_inherit))) { if (f) - f->face_change = 1; + { + f->face_change = true; + fset_redisplay (f); + } else - face_change = true; - windows_or_buffers_changed = 55; + { + face_change = true; + windows_or_buffers_changed = 55; + } } return to; @@ -3120,7 +3130,7 @@ FRAME 0 means change the face on all frames, and change the default && NILP (Fequal (old_value, value))) { f->face_change = true; - windows_or_buffers_changed = 56; + fset_redisplay (f); } if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value) @@ -3293,7 +3303,7 @@ update_face_from_frame_parameter (struct frame *f, Lisp_Object param, && NILP (Fget (face, Qface_no_inherit))) { f->face_change = true; - windows_or_buffers_changed = 57; + fset_redisplay (f); } } diff --git a/src/xfns.c b/src/xfns.c index d6a3d76..fc6111c 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -1041,7 +1041,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) nlines = 0; /* Make sure we redisplay all windows in this frame. */ - windows_or_buffers_changed = 59; + fset_redisplay (f); #if defined (USE_X_TOOLKIT) || defined (USE_GTK) FRAME_MENU_BAR_LINES (f) = 0; @@ -1160,8 +1160,7 @@ x_change_tool_bar_height (struct frame *f, int height) Lisp_Object fullscreen; /* Make sure we redisplay all windows in this frame. */ - windows_or_buffers_changed = 60; - + fset_redisplay (f); /* Recalculate tool bar and frame text sizes. */ FRAME_TOOL_BAR_HEIGHT (f) = height; commit 44298d3cf8749a89318422a2fb314dd4f3711961 Author: Eli Zaretskii Date: Wed Sep 30 16:51:48 2015 +0300 ; Yet another tweak of pos-visible-in-window-p doc string diff --git a/src/window.c b/src/window.c index 8d899d6..d61f586 100644 --- a/src/window.c +++ b/src/window.c @@ -1686,10 +1686,10 @@ Return nil if that position is scrolled vertically out of view. If a character is only partially visible, nil is returned, unless the optional argument PARTIALLY is non-nil. If POS is only out of view because of horizontal scrolling, return non-nil. If POS is t, it -specifies the position of either the first position displayed on the -last visible screen line in WINDOW, or the end-of-buffer position, -whichever comes first. POS defaults to point in WINDOW; WINDOW defaults -to the selected window. +specifies either the first position displayed on the last visible +screen line in WINDOW, or the end-of-buffer position, whichever comes +first. POS defaults to point in WINDOW; WINDOW defaults to the +selected window. If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil, the return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]), commit 8d5662cb300893599bd328df0fa9ef4bdfe7d458 Author: Michael Albinus Date: Wed Sep 30 15:28:41 2015 +0200 ; Minor updates in admin/MAINTAINERS diff --git a/admin/MAINTAINERS b/admin/MAINTAINERS index 8a158e4..43fa46d 100644 --- a/admin/MAINTAINERS +++ b/admin/MAINTAINERS @@ -218,6 +218,7 @@ Paul Eggert Michael Albinus src/inotify.c lisp/autorevert.el + lisp/eshell/em-tramp.el lisp/notifications.el test/automated/auto-revert-tests.el test/automated/inotify-test.el @@ -568,7 +569,6 @@ lisp/net/soap-inspect.el lisp/net/socks.el lisp/net/telnet.el lisp/net/tls.el -lisp/net/trampver.el lisp/net/webjump.el lisp/newcomment.el lisp/novice.el commit e73b0d6f03ffdbc1ec40636c662f010083af0b98 Author: Tassilo Horn Date: Tue Sep 29 21:34:18 2015 +0200 Implement unprettification of symbol at point * lisp/progmodes/prog-mode.el: Implement feature for unprettifying the symbol at point. (prettify-symbols--current-symbol-bounds): New variable. (prettify-symbols--post-command-hook): New function. (prettify-symbols-unprettify-at-point): New defcustom. (prettify-symbols-mode): Use it. (prettify-symbols--compose-symbol): Use them. diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index f1aa35f..b408509 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -29,7 +29,8 @@ ;;; Code: -(eval-when-compile (require 'cl-lib)) +(eval-when-compile (require 'cl-lib) + (require 'subr-x)) (defgroup prog-mode nil "Generic programming mode, from which others derive." @@ -161,13 +162,20 @@ Regexp match data 0 points to the chars." (let ((start (match-beginning 0)) (end (match-end 0)) (match (match-string 0))) - (if (funcall prettify-symbols-compose-predicate start end match) + (if (and (not (equal prettify-symbols--current-symbol-bounds (list start end))) + (funcall prettify-symbols-compose-predicate start end match)) ;; That's a symbol alright, so add the composition. - (compose-region start end (cdr (assoc match alist))) + (progn + (compose-region start end (cdr (assoc match alist))) + (add-text-properties + start end + `(prettify-symbols-start ,start prettify-symbols-end ,end))) ;; No composition for you. Let's actually remove any ;; composition we may have added earlier and which is now ;; incorrect. - (remove-text-properties start end '(composition)))) + (remove-text-properties start end '(composition + prettify-symbols-start + prettify-symbols-end)))) ;; Return nil because we're not adding any face property. nil) @@ -179,6 +187,29 @@ Regexp match data 0 points to the chars." (defvar-local prettify-symbols--keywords nil) +(defvar-local prettify-symbols--current-symbol-bounds nil) + +(defun prettify-symbols--post-command-hook () + (if-let ((c (get-text-property (point) 'composition)) + (s (get-text-property (point) 'prettify-symbols-start)) + (e (get-text-property (point) 'prettify-symbols-end))) + (progn + (setq prettify-symbols--current-symbol-bounds (list s e)) + (remove-text-properties s e '(composition))) + (when (and prettify-symbols--current-symbol-bounds + (or (< (point) (car prettify-symbols--current-symbol-bounds)) + (>= (point) (cadr prettify-symbols--current-symbol-bounds)))) + (apply #'font-lock-flush prettify-symbols--current-symbol-bounds) + (setq prettify-symbols--current-symbol-bounds nil)))) + +(defcustom prettify-symbols-unprettify-at-point t + "If non-nil, show the non-prettified version of a symbol when point is on it. +The prettification will be reapplied as soon as point moves away +from the symbol. If set to nil, the prettification persists even +when point is on the symbol." + :type 'boolean + :group 'prog-mode) + ;;;###autoload (define-minor-mode prettify-symbols-mode "Toggle Prettify Symbols mode. @@ -206,8 +237,12 @@ support it." (font-lock-add-keywords nil prettify-symbols--keywords) (setq-local font-lock-extra-managed-props (cons 'composition font-lock-extra-managed-props)) + (when prettify-symbols-unprettify-at-point + (add-hook 'post-command-hook + #'prettify-symbols--post-command-hook nil t)) (font-lock-flush)) ;; Turn off + (remove-hook 'post-command-hook #'prettify-symbols--post-command-hook t) (when prettify-symbols--keywords (font-lock-remove-keywords nil prettify-symbols--keywords) (setq prettify-symbols--keywords nil)) commit ecedfd66fc18e9db206c9f9a49fd5226561f94a9 Author: YAMAMOTO Mitsuharu Date: Wed Sep 30 19:05:27 2015 +0900 * src/macfont.m (mac_font_descriptor_supports_languages): Regard "zh" as synonym of "zh-Hans". diff --git a/src/macfont.m b/src/macfont.m index cfe0e0a..bab9f7c 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -3427,18 +3427,24 @@ mac_font_descriptor_supports_languages (CTFontDescriptorRef descriptor, result = false; else { - CFIndex desc_languages_count, i, languages_count; + CFRange range = CFRangeMake (0, CFArrayGetCount (desc_languages)); + CFIndex i, languages_count = CFArrayGetCount (languages); - desc_languages_count = CFArrayGetCount (desc_languages); - languages_count = CFArrayGetCount (languages); for (i = 0; i < languages_count; i++) - if (!CFArrayContainsValue (desc_languages, - CFRangeMake (0, desc_languages_count), - CFArrayGetValueAtIndex (languages, i))) - { - result = false; - break; - } + { + CFStringRef language = CFArrayGetValueAtIndex (languages, i); + + if (!CFArrayContainsValue (desc_languages, range, language) + /* PingFang SC contains "zh" and "zh-Hant" as covered + languages, but does not contain "zh-Hans". */ + && !(CFEqual (language, CFSTR ("zh-Hans")) + && CFArrayContainsValue (desc_languages, range, + CFSTR ("zh")))) + { + result = false; + break; + } + } CFRelease (desc_languages); } commit d22634e518078a9a51c9a30b44a72e0c9e7c96cd Author: YAMAMOTO Mitsuharu Date: Wed Sep 30 18:56:30 2015 +0900 Work around crash when displaying etc/HELLO on OS X 10.11 * src/macfont.m (mac_font_get_weight) (mac_font_descriptor_get_adjusted_weight): New functions. (macfont_store_descriptor_attributes): Adjust weight. diff --git a/src/macfont.m b/src/macfont.m index 6964076..cfe0e0a 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -190,6 +190,14 @@ cfstring_create_with_string_noencode (Lisp_Object s) return string; } +static CFIndex +mac_font_get_weight (CTFontRef font) +{ + NSFont *nsFont = (NSFont *) font; + + return [[NSFontManager sharedFontManager] weightOfFont:nsFont]; +} + static CGFloat mac_screen_font_get_advance_width_for_glyph (ScreenFontRef font, CGGlyph glyph) { @@ -758,6 +766,46 @@ cfnumber_get_font_symbolic_traits_value (CFNumberRef number, return false; } +static CGFloat +mac_font_descriptor_get_adjusted_weight (CTFontDescriptorRef desc, CGFloat val) +{ + long percent_val = lround (val * 100); + + if (percent_val == -40 || percent_val == 56) + { + CTFontRef font = NULL; + CFStringRef name = + CTFontDescriptorCopyAttribute (desc, kCTFontNameAttribute); + + if (name) + { + font = CTFontCreateWithName (name, 0, NULL); + CFRelease (name); + } + if (font) + { + CFIndex weight = mac_font_get_weight (font); + + if (percent_val == -40) + { + /* Workaround for crash when displaying Oriya characters + with Arial Unicode MS on OS X 10.11. */ + if (weight == 5) + val = 0; + } + else /* percent_val == 56 */ + { + if (weight == 9) + /* Adjustment for HiraginoSans-W7 on OS X 10.11. */ + val = 0.4; + } + CFRelease (font); + } + } + + return val; +} + static void macfont_store_descriptor_attributes (CTFontDescriptorRef desc, Lisp_Object spec_or_entity) @@ -781,6 +829,7 @@ macfont_store_descriptor_attributes (CTFontDescriptorRef desc, enum font_property_index index; CFStringRef trait; CGPoint points[6]; + CGFloat (*adjust_func) (CTFontDescriptorRef, CGFloat); } numeric_traits[] = {{FONT_WEIGHT_INDEX, kCTFontWeightTrait, {{-0.4, 50}, /* light */ @@ -788,11 +837,12 @@ macfont_store_descriptor_attributes (CTFontDescriptorRef desc, {0, 100}, /* normal */ {0.24, 140}, /* (semi-bold + normal) / 2 */ {0.4, 200}, /* bold */ - {CGFLOAT_MAX, CGFLOAT_MAX}}}, + {CGFLOAT_MAX, CGFLOAT_MAX}}, + mac_font_descriptor_get_adjusted_weight}, {FONT_SLANT_INDEX, kCTFontSlantTrait, - {{0, 100}, {0.1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}, + {{0, 100}, {0.1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}, NULL}, {FONT_WIDTH_INDEX, kCTFontWidthTrait, - {{0, 100}, {1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}}; + {{0, 100}, {1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}, NULL}}; int i; for (i = 0; i < ARRAYELTS (numeric_traits); i++) @@ -802,6 +852,8 @@ macfont_store_descriptor_attributes (CTFontDescriptorRef desc, { CGPoint *point = numeric_traits[i].points; + if (numeric_traits[i].adjust_func) + floatval = (*numeric_traits[i].adjust_func) (desc, floatval); while (point->x < floatval) point++; if (point == numeric_traits[i].points) commit 1c6a58705b653b62c71266497564b1880c5b1340 Author: Eli Zaretskii Date: Wed Sep 30 12:46:17 2015 +0300 ; Clarify docs of pos-visible-in-window-p some more diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 881d364..1da2d1c 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -3174,12 +3174,14 @@ position that works well with point, and thus @var{position} is not used. @defun pos-visible-in-window-p &optional position window partially This function returns non-@code{nil} if @var{position} is within the range of text currently visible on the screen in @var{window}. It -returns @code{nil} if @var{position} is scrolled vertically out of view. -Locations that are partially obscured are not considered visible unless -@var{partially} is non-@code{nil}. The argument @var{position} defaults -to the current position of point in @var{window}; @var{window}, to the -selected window. If @var{position} is @code{t}, that means to check the -first visible position of the last visible screen line in @var{window}. +returns @code{nil} if @var{position} is scrolled vertically out of +view. Locations that are partially obscured are not considered +visible unless @var{partially} is non-@code{nil}. The argument +@var{position} defaults to the current position of point in +@var{window}; @var{window} defaults to the selected window. If +@var{position} is @code{t}, that means to check either the first +visible position of the last screen line in @var{window}, or the +end-of-buffer position, whichever comes first. This function considers only vertical scrolling. If @var{position} is out of view only because @var{window} has been scrolled horizontally, diff --git a/src/window.c b/src/window.c index 0f35066..8d899d6 100644 --- a/src/window.c +++ b/src/window.c @@ -1686,8 +1686,9 @@ Return nil if that position is scrolled vertically out of view. If a character is only partially visible, nil is returned, unless the optional argument PARTIALLY is non-nil. If POS is only out of view because of horizontal scrolling, return non-nil. If POS is t, it -specifies the position of the first glyph displayed on the last visible -screen line in WINDOW. POS defaults to point in WINDOW; WINDOW defaults +specifies the position of either the first position displayed on the +last visible screen line in WINDOW, or the end-of-buffer position, +whichever comes first. POS defaults to point in WINDOW; WINDOW defaults to the selected window. If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil, commit ecbb6aeb5f10e0ca4ba404570ee36961273fc139 Author: YAMAMOTO Mitsuharu Date: Wed Sep 30 18:43:25 2015 +0900 * src/macfont.m: Fix compilation with USE_CT_GLYPH_INFO. diff --git a/src/macfont.m b/src/macfont.m index 97a255b..6964076 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -198,57 +198,53 @@ mac_screen_font_get_advance_width_for_glyph (ScreenFontRef font, CGGlyph glyph) return advancement.width; } +#if !USE_CT_GLYPH_INFO static CGGlyph mac_font_get_glyph_for_cid (CTFontRef font, CTCharacterCollection collection, CGFontIndex cid) { -#if USE_CT_GLYPH_INFO - return mac_ctfont_get_glyph_for_cid ((CTFontRef) font, collection, cid); -#else - { - CGGlyph result = kCGFontIndexInvalid; - NSFont *nsFont = (NSFont *) font; - unichar characters[] = {0xfffd}; - NSString *string = - [NSString stringWithCharacters:characters - length:ARRAYELTS (characters)]; - NSGlyphInfo *glyphInfo = - [NSGlyphInfo glyphInfoWithCharacterIdentifier:cid - collection:collection - baseString:string]; - NSDictionary *attributes = - [NSDictionary dictionaryWithObjectsAndKeys:nsFont,NSFontAttributeName, - glyphInfo,NSGlyphInfoAttributeName,nil]; - NSTextStorage *textStorage = - [[NSTextStorage alloc] initWithString:string - attributes:attributes]; - NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init]; - NSTextContainer *textContainer = [[NSTextContainer alloc] init]; - NSFont *fontInTextStorage; - - [layoutManager addTextContainer:textContainer]; - [textContainer release]; - [textStorage addLayoutManager:layoutManager]; - [layoutManager release]; - - /* Force layout. */ - (void) [layoutManager glyphRangeForTextContainer:textContainer]; - - fontInTextStorage = [textStorage attribute:NSFontAttributeName atIndex:0 - effectiveRange:NULL]; - if (fontInTextStorage == nsFont - || [[fontInTextStorage fontName] isEqualToString:[nsFont fontName]]) - { - NSGlyph glyph = [layoutManager glyphAtIndex:0]; + CGGlyph result = kCGFontIndexInvalid; + NSFont *nsFont = (NSFont *) font; + unichar characters[] = {0xfffd}; + NSString *string = + [NSString stringWithCharacters:characters + length:ARRAYELTS (characters)]; + NSGlyphInfo *glyphInfo = + [NSGlyphInfo glyphInfoWithCharacterIdentifier:cid + collection:collection + baseString:string]; + NSDictionary *attributes = + [NSDictionary dictionaryWithObjectsAndKeys:nsFont,NSFontAttributeName, + glyphInfo,NSGlyphInfoAttributeName,nil]; + NSTextStorage *textStorage = + [[NSTextStorage alloc] initWithString:string + attributes:attributes]; + NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init]; + NSTextContainer *textContainer = [[NSTextContainer alloc] init]; + NSFont *fontInTextStorage; - if (glyph < [nsFont numberOfGlyphs]) - result = glyph; - } + [layoutManager addTextContainer:textContainer]; + [textContainer release]; + [textStorage addLayoutManager:layoutManager]; + [layoutManager release]; - [textStorage release]; + /* Force layout. */ + (void) [layoutManager glyphRangeForTextContainer:textContainer]; - return result; - } + fontInTextStorage = [textStorage attribute:NSFontAttributeName atIndex:0 + effectiveRange:NULL]; + if (fontInTextStorage == nsFont + || [[fontInTextStorage fontName] isEqualToString:[nsFont fontName]]) + { + NSGlyph glyph = [layoutManager glyphAtIndex:0]; + + if (glyph < [nsFont numberOfGlyphs]) + result = glyph; + } + + [textStorage release]; + + return result; } #endif