commit c617b4bf1e50bf33f0016bbcd5f502cc88150f26 (HEAD, refs/remotes/origin/master) Author: YAMAMOTO Mitsuharu Date: Tue May 28 17:31:57 2019 +0900 Support tool bar icon image also on GTK+2 with cairo * src/gtkutil.c (xg_get_pixbuf_from_surface) [USE_CAIRO && !HAVE_GTK3]: New function. (xg_get_image_for_pixmap) [USE_CAIRO && !HAVE_GTK3]: Use it. (xg_tool_item_stale_p, update_frame_tool_bar) [USE_CAIRO && !HAVE_GTK3]: Use cairo code also on GTK+2. diff --git a/src/gtkutil.c b/src/gtkutil.c index 43918dd3da..c6534585f8 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -279,6 +279,51 @@ xg_get_pixbuf_from_pix_and_mask (struct frame *f, return icon_buf; } +#if defined USE_CAIRO && !defined HAVE_GTK3 +static GdkPixbuf * +xg_get_pixbuf_from_surface (struct frame *f, cairo_surface_t *surface) +{ + int width = cairo_image_surface_get_width (surface); + int height = cairo_image_surface_get_height (surface); + GdkPixbuf *icon_buf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, + width, height); + if (icon_buf) + { + guchar *pixels = gdk_pixbuf_get_pixels (icon_buf); + int rowstride = gdk_pixbuf_get_rowstride (icon_buf); + cairo_surface_t *icon_surface + = cairo_image_surface_create_for_data (pixels, CAIRO_FORMAT_ARGB32, + width, height, rowstride); + cairo_t *cr = cairo_create (icon_surface); + cairo_surface_destroy (icon_surface); + cairo_set_source_surface (cr, surface, 0, 0); + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + cairo_paint (cr); + cairo_destroy (cr); + + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + guint32 argb = ((guint32 *) pixels)[x]; +#ifdef WORDS_BIGENDIAN + /* ARGB -> RGBA (gdk_pixbuf, big endian) */ + ((guint32 *) pixels)[x] = (argb << 8) | (argb >> 24); +#else /* !WORDS_BIGENDIAN */ + /* ARGB -> ABGR (gdk_pixbuf, little endian) */ + ((guint32 *) pixels)[x] = (( argb & 0xff00ff00) + | ((argb << 16) & 0x00ff0000) + | ((argb >> 16) & 0x000000ff)); +#endif /* !WORDS_BIGENDIAN */ + } + pixels += rowstride; + } + } + + return icon_buf; +} +#endif /* USE_CAIRO && !HAVE_GTK3 */ + static Lisp_Object file_for_image (Lisp_Object image) { @@ -311,7 +356,7 @@ xg_get_image_for_pixmap (struct frame *f, GtkWidget *widget, GtkImage *old_widget) { -#if defined USE_CAIRO && defined HAVE_GTK3 +#ifdef USE_CAIRO cairo_surface_t *surface; #else GdkPixbuf *icon_buf; @@ -343,15 +388,29 @@ xg_get_image_for_pixmap (struct frame *f, on a monochrome display, and sometimes bad on all displays with certain themes. */ -#if defined USE_CAIRO && defined HAVE_GTK3 +#ifdef USE_CAIRO surface = img->cr_data; if (surface) { +#ifdef HAVE_GTK3 if (! old_widget) old_widget = GTK_IMAGE (gtk_image_new_from_surface (surface)); else gtk_image_set_from_surface (old_widget, surface); +#else /* !HAVE_GTK3 */ + GdkPixbuf *icon_buf = xg_get_pixbuf_from_surface (f, surface); + + if (icon_buf) + { + if (! old_widget) + old_widget = GTK_IMAGE (gtk_image_new_from_pixbuf (icon_buf)); + else + gtk_image_set_from_pixbuf (old_widget, icon_buf); + + g_object_unref (G_OBJECT (icon_buf)); + } +#endif /* !HAVE_GTK3 */ } #else /* This is a workaround to make icons look good on pseudo color @@ -4689,7 +4748,7 @@ xg_tool_item_stale_p (GtkWidget *wbutton, const char *stock_name, { gpointer gold_img = g_object_get_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA); -#if defined USE_CAIRO && defined HAVE_GTK3 +#ifdef USE_CAIRO void *old_img = (void *) gold_img; if (old_img != img->cr_data) return 1; @@ -4990,7 +5049,7 @@ update_frame_tool_bar (struct frame *f) prepare_image_for_display (f, img); if (img->load_failed_p -#if defined USE_CAIRO && defined HAVE_GTK3 +#ifdef USE_CAIRO || img->cr_data == NULL #else || img->pixmap == None @@ -5045,7 +5104,7 @@ update_frame_tool_bar (struct frame *f) { w = xg_get_image_for_pixmap (f, img, x->widget, NULL); g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA, -#if defined USE_CAIRO && defined HAVE_GTK3 +#ifdef USE_CAIRO (gpointer)img->cr_data #else (gpointer)img->pixmap commit f113512ffcd2bce6af6cc0f8f49df11d1dcf0fe9 Author: Glenn Morris Date: Mon May 27 17:20:12 2019 -0700 * test/lisp/autorevert-tests.el: Give on on remote hydra.nixos tests. (auto-revert--test-enabled-remote): Disable on hydra.nixos. diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el index 79eba8b165..00c7ee2575 100644 --- a/test/lisp/autorevert-tests.el +++ b/test/lisp/autorevert-tests.el @@ -62,9 +62,6 @@ tramp-verbose 0 tramp-message-show-message nil) -(when (getenv "EMACS_HYDRA_CI") - (add-to-list 'tramp-remote-path 'tramp-own-remote-path)) - (defconst auto-revert--timeout 10 "Time to wait for a message.") @@ -114,6 +111,7 @@ being the result.") (cons t (ignore-errors (and + (not (getenv "EMACS_HYDRA_CI")) (file-remote-p auto-revert-test-remote-temporary-file-directory) (file-directory-p auto-revert-test-remote-temporary-file-directory) (file-writable-p commit 8f3bd2600a42509adffb886a534442234e2c284e Author: Glenn Morris Date: Mon May 27 14:08:07 2019 -0700 * test/lisp/autorevert-tests.el: Try to fix remote hydra.nixos tests. diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el index 5024a2daf0..79eba8b165 100644 --- a/test/lisp/autorevert-tests.el +++ b/test/lisp/autorevert-tests.el @@ -62,6 +62,9 @@ tramp-verbose 0 tramp-message-show-message nil) +(when (getenv "EMACS_HYDRA_CI") + (add-to-list 'tramp-remote-path 'tramp-own-remote-path)) + (defconst auto-revert--timeout 10 "Time to wait for a message.") commit 464770d2e9abba4d4860637140410c9340312a83 Author: Simen Heggestøyl Date: Mon May 27 21:12:53 2019 +0200 Remap `complete-symbol' in CSS mode * lisp/textmodes/css-mode.el (css-mode-map): Remap `complete-symbol' to `completion-at-point'. (css-mode): Update docstring to produce the right key binding. diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index ae7b8eacd1..5d5d787945 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -844,6 +844,8 @@ cannot be completed sensibly: `custom-ident', (defvar css-mode-map (let ((map (make-sparse-keymap))) (define-key map [remap info-lookup-symbol] 'css-lookup-symbol) + ;; `info-complete-symbol' is not used. + (define-key map [remap complete-symbol] 'completion-at-point) (define-key map "\C-c\C-f" 'css-cycle-color-format) (easy-menu-define css-menu map "CSS mode menu" '("CSS" @@ -855,7 +857,7 @@ cannot be completed sensibly: `custom-ident', "-" ["Describe symbol" css-lookup-symbol :help "Display documentation for a CSS symbol"] - ["Complete symbol" complete-symbol + ["Complete symbol" completion-at-point :help "Complete symbol before point"])) map) "Keymap used in `css-mode'.") @@ -1619,7 +1621,7 @@ rgb()/rgba()." This mode provides syntax highlighting, indentation, completion, and documentation lookup for CSS. -Use `\\[complete-symbol]' to complete CSS properties, property values, +Use `\\[completion-at-point]' to complete CSS properties, property values, pseudo-elements, pseudo-classes, at-rules, bang-rules, and HTML tags, classes and IDs. Completion candidates for HTML class names and IDs are found by looking through open HTML mode commit 68b374a62d8b7b98fd0b144ae83077d698e20bdb Author: Mattias Engdegård Date: Fri May 17 11:25:06 2019 +0200 Correctly eliminate duplicate cases in switch compilation Fix code mistakes that prevented the correct elimination of duplicated cases when compiling a `cond' form to a switch bytecode, as in (cond ((eq x 'a) 1) ((eq x 'b) 2) ((eq x 'a) 3) ; should be elided ((eq x 'c) 4)) Sometimes, this caused the bytecode to use the wrong branch (bug#35770). * lisp/emacs-lisp/bytecomp.el (byte-compile-cond-vars): Return obj2 eval'ed. (byte-compile-cond-jump-table-info): Discard redundant condition. Use `obj2' as evaluated. Discard duplicated cases instead of failing the table generation. * test/lisp/emacs-lisp/bytecomp-tests.el (toplevel): Require subr-x. (byte-opt-testsuite-arith-data, bytecomp-test--switch-duplicates): Test. diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index e76baf5ed0..ce348ed313 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -4091,8 +4091,8 @@ that suppresses all warnings during execution of BODY." ;; and the other is a constant expression whose value can be ;; compared with `eq' (with `macroexp-const-p'). (or - (and (symbolp obj1) (macroexp-const-p obj2) (cons obj1 obj2)) - (and (symbolp obj2) (macroexp-const-p obj1) (cons obj2 obj1)))) + (and (symbolp obj1) (macroexp-const-p obj2) (cons obj1 (eval obj2))) + (and (symbolp obj2) (macroexp-const-p obj1) (cons obj2 (eval obj1))))) (defconst byte-compile--default-val (cons nil nil) "A unique object.") @@ -4121,12 +4121,11 @@ Return a list of the form ((TEST . VAR) ((VALUE BODY) ...))" (unless prev-test (setq prev-test test)) (if (and obj1 (memq test '(eq eql equal)) - (consp condition) (eq test prev-test) - (eq obj1 prev-var) - ;; discard duplicate clauses - (not (assq obj2 cases))) - (push (list (if (consp obj2) (eval obj2) obj2) body) cases) + (eq obj1 prev-var)) + ;; discard duplicate clauses + (unless (assoc obj2 cases test) + (push (list obj2 body) cases)) (if (and (macroexp-const-p condition) condition) (progn (push (list byte-compile--default-val (or body `(,condition))) diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 5fb64ff288..ed100020de 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -27,6 +27,7 @@ (require 'ert) (require 'cl-lib) +(require 'subr-x) (require 'bytecomp) ;;; Code: @@ -296,7 +297,21 @@ ((eq variable 'default) (message "equal")) (t - (message "not equal"))))) + (message "not equal")))) + ;; Bug#35770 + (let ((x 'a)) (cond ((eq x 'a) 'correct) + ((eq x 'b) 'incorrect) + ((eq x 'a) 'incorrect) + ((eq x 'c) 'incorrect))) + (let ((x #x10000000000000000)) + (cond ((eql x #x10000000000000000) 'correct) + ((eql x #x10000000000000001) 'incorrect) + ((eql x #x10000000000000000) 'incorrect) + ((eql x #x10000000000000002) 'incorrect))) + (let ((x "a")) (cond ((equal x "a") 'correct) + ((equal x "b") 'incorrect) + ((equal x "a") 'incorrect) + ((equal x "c") 'incorrect)))) "List of expression for test. Each element will be executed by interpreter and with bytecompiled code, and their results compared.") @@ -613,6 +628,44 @@ literals (Bug#20852)." (if (buffer-live-p byte-compile-log-buffer) (kill-buffer byte-compile-log-buffer))))) +(ert-deftest bytecomp-test--switch-duplicates () + "Check that duplicates in switches are eliminated correctly (bug#35770)." + (dolist (params + '(((lambda (x) + (cond ((eq x 'a) 111) + ((eq x 'b) 222) + ((eq x 'a) 333) + ((eq x 'c) 444))) + (a b c) + string<) + ((lambda (x) + (cond ((eql x #x10000000000000000) 111) + ((eql x #x10000000000000001) 222) + ((eql x #x10000000000000000) 333) + ((eql x #x10000000000000002) 444))) + (#x10000000000000000 #x10000000000000001 #x10000000000000002) + <) + ((lambda (x) + (cond ((equal x "a") 111) + ((equal x "b") 222) + ((equal x "a") 333) + ((equal x "c") 444))) + ("a" "b" "c") + string<))) + (let* ((lisp (nth 0 params)) + (keys (nth 1 params)) + (lessp (nth 2 params)) + (bc (byte-compile lisp)) + (lap (byte-decompile-bytecode (aref bc 1) (aref bc 2))) + ;; Assume the first constant is the switch table. + (table (cadr (assq 'byte-constant lap)))) + (should (hash-table-p table)) + (should (equal (sort (hash-table-keys table) lessp) keys)) + (should (member '(byte-constant 111) lap)) + (should (member '(byte-constant 222) lap)) + (should-not (member '(byte-constant 333) lap)) + (should (member '(byte-constant 444) lap))))) + ;; Local Variables: ;; no-byte-compile: t ;; End: