commit 1d135af78c3ddd502b5feb84884ea55cbc664753 (HEAD, refs/remotes/origin/master) Author: Philipp Stephani Date: Tue Feb 13 09:55:46 2018 +0100 Fix NS-related compilation errors. * src/nsterm.m (ns_set_represented_filename): Remove unused variable 'view'. * src/nsfns.m (x_implicitly_set_name, syms_of_nsfns): The type of a variable defined with DEFVAR_BOOL is 'bool', not 'Lisp_Object'. diff --git a/src/nsfns.m b/src/nsfns.m index bbb6644ce0..06827f6dd1 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -482,7 +482,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side { NSTRACE ("x_implicitly_set_name"); - if (! NILP (ns_use_proxy_icon)) + if (ns_use_proxy_icon) ns_set_represented_filename (f); ns_set_name (f, arg, 0); @@ -3234,7 +3234,7 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename DEFVAR_BOOL ("ns-use-proxy-icon", ns_use_proxy_icon, doc: /* When non-nil display a proxy icon in the titlebar. Default is t. */); - ns_use_proxy_icon = Qt; + ns_use_proxy_icon = true; defsubr (&Sns_read_file_name); defsubr (&Sns_get_resource); diff --git a/src/nsterm.m b/src/nsterm.m index 29aef0e9b6..8a66643cfb 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -471,7 +471,6 @@ - (NSColor *)colorUsingDefaultColorSpace void ns_set_represented_filename (struct frame *f) { - NSView *view; Lisp_Object filename, encoded_filename; Lisp_Object buf = XWINDOW (f->selected_window)->contents; NSAutoreleasePool *pool; commit 4b70de228d663cdbbae9668e6e990b0064e72fda Author: Rami Ylimäki Date: Tue Feb 13 07:33:39 2018 +0200 Expand direct color description in Emacs FAQ * doc/misc/efaq.texi (Colors on a TTY): Show how to list direct mode TERM definitions. (Bug#30429) diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi index fef9b1051b..5392748d00 100644 --- a/doc/misc/efaq.texi +++ b/doc/misc/efaq.texi @@ -1490,6 +1490,7 @@ exhibits all the colors Emacs knows about on the current display. Syntax highlighting is on by default since version 22.1. +@cindex direct color in terminals Emacs 26.1 and later support direct color mode in terminals. If Emacs finds Terminfo capabilities @samp{setb24} and @samp{setf24}, 24-bit direct color mode is used. The capability strings are expected to @@ -1504,14 +1505,17 @@ $ cat terminfo-custom.src xterm-emacs|xterm with 24-bit direct color mode for Emacs, use=xterm-256color, - setb24=\E[48\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%dm, - setf24=\E[38\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%dm, + setb24=\E[48\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&\ + %d\:%p1%@{255@}%&%dm, + setf24=\E[38\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&\ + %d\:%p1%@{255@}%&%dm, $ tic -x -o ~/.terminfo terminfo-custom.src $ TERM=xterm-emacs emacs -nw @end example +@cindex 24-bit direct color mode Emacs 27.1 and later support Terminfo capability @samp{RGB} for detecting 24-bit direct color mode. Multiple standard terminal definitions support this capability. @@ -1519,12 +1523,29 @@ definitions support this capability. @example $ TERM=xterm-direct infocmp | grep seta[bf] - setab=\E[%?%p1%@{8@}%<%t4%p1%d%e48\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%d%;m, - setaf=\E[%?%p1%@{8@}%<%t3%p1%d%e38\:2\:\:%p1%@{65536@}%/%d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%d%;m, + setab=\E[%?%p1%@{8@}%<%t4%p1%d%e48\:2\:\:%p1%@{65536@}%/\ + %d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%d%;m, + setaf=\E[%?%p1%@{8@}%<%t3%p1%d%e38\:2\:\:%p1%@{65536@}%/\ + %d\:%p1%@{256@}%/%@{255@}%&%d\:%p1%@{255@}%&%d%;m, $ TERM=xterm-direct emacs -nw @end example +If your terminal is incompatible with XTerm, you may have to use +another @env{TERM} definition. Any terminal whose name includes +@samp{direct} should be a candidate. The @command{toe} command can be +used to find out which of these are installed on your system: + +@example +$ toe | grep '\-direct' + +konsole-direct konsole with direct-color indexing +vte-direct vte with direct-color indexing +st-direct st with direct-color indexing +xterm-direct2 xterm with direct-color indexing (old) +xterm-direct xterm with direct-color indexing +@end example + Terminals with @samp{RGB} capability treat pixels #000001 - #000007 as indexed colors to maintain backward compatibility with applications that are unaware of direct color mode. Therefore the seven darkest commit 82c3be834786ff9afad4911cf3cc5aa0cd2c1b03 Author: Stefan Monnier Date: Tue Feb 13 00:17:38 2018 -0500 * lisp/gnus/message.el (message-ecomplete-capf): Fix call convention. diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index a0adccef7a..4f4ec3b408 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -8242,7 +8242,7 @@ Meant for use on `completion-at-point-functions'." (start (save-excursion (skip-chars-backward "^, \t\n") (point)))) - `(,start ,end ,(apply-partially #'ecomplete-completion-table 'mail))))) + `(,start ,end ,(ecomplete-completion-table 'mail))))) ;; To send pre-formatted letters like the example below, you can use ;; `message-send-form-letter': commit 0676633e8fd842554e91d0756115fa2d6b7cf69c Author: Noam Postavsky Date: Mon Feb 12 21:22:46 2018 -0500 * lisp/progmodes/python.el: Bump package version to 0.26. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index ff8269d970..8ff7a300d4 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4,7 +4,7 @@ ;; Author: Fabián E. Gallina ;; URL: https://github.com/fgallina/python.el -;; Version: 0.25.2 +;; Version: 0.26 ;; Package-Requires: ((emacs "24.1") (cl-lib "1.0")) ;; Maintainer: emacs-devel@gnu.org ;; Created: Jul 2010 commit b8c415180895f155b4aaebd9cae65124c95b0c98 Author: Paul Eggert Date: Mon Feb 12 16:39:56 2018 -0800 Work if libpng is in /usr/local (2nd try) Problem reported by Werner Lemberg in: https://lists.gnu.org/r/emacs-devel/2018-02/msg00304.html with a further fix suggested by Glenn Morris in Bug#30431#14. * configure.ac: Try pkg-config before libpng-config. Adjust LIBPNG accordingly, and append -lz regardless of whether it was pkg-config. diff --git a/configure.ac b/configure.ac index f2a8332d71..cb452e053b 100644 --- a/configure.ac +++ b/configure.ac @@ -3612,39 +3612,48 @@ elif test "${with_png}" != no; then if test "$opsys" = mingw32; then AC_CHECK_HEADER([png.h], [HAVE_PNG=yes]) elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then - AC_MSG_CHECKING([for png]) - png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` && - png_ldflags=`(libpng-config --ldflags) 2>&AS_MESSAGE_LOG_FD` || { - # libpng-config does not work; configure by hand. - # Debian unstable as of July 2003 has multiple libpngs, and puts png.h - # in /usr/include/libpng. - if test -r /usr/include/libpng/png.h && - test ! -r /usr/include/png.h; then - png_cflags=-I/usr/include/libpng - else - png_cflags= - fi - png_ldflags='-lpng' - } - SAVE_CFLAGS=$CFLAGS - SAVE_LIBS=$LIBS - CFLAGS="$CFLAGS $png_cflags" - LIBS="$png_ldflags -lz -lm $LIBS" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[#include ]], - [[return !png_get_channels (0, 0);]])], - [HAVE_PNG=yes - PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"` - LIBPNG=$png_ldflags - # $LIBPNG requires explicit -lz in some cases. - # We don't know what those cases are, exactly, so play it safe and - # append -lz to any nonempty $LIBPNG, unless we're already using LIBZ. - if test -n "$LIBPNG" && test -z "$LIBZ"; then - LIBPNG="$LIBPNG -lz" - fi]) - CFLAGS=$SAVE_CFLAGS - LIBS=$SAVE_LIBS - AC_MSG_RESULT([$HAVE_PNG]) + EMACS_CHECK_MODULES([PNG], [libpng >= 1.0.0]) + if test $HAVE_PNG = yes; then + LIBPNG=$PNG_LIBS + else + # Test old way in case pkg-config doesn't have it (older machines). + AC_MSG_CHECKING([for libpng not configured by pkg-config]) + + png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` && + png_ldflags=`(libpng-config --ldflags) 2>&AS_MESSAGE_LOG_FD` || { + # libpng-config does not work; configure by hand. + # Debian unstable as of July 2003 has multiple libpngs, and puts png.h + # in /usr/include/libpng. + if test -r /usr/include/libpng/png.h && + test ! -r /usr/include/png.h; then + png_cflags=-I/usr/include/libpng + else + png_cflags= + fi + png_ldflags='-lpng' + } + SAVE_CFLAGS=$CFLAGS + SAVE_LIBS=$LIBS + CFLAGS="$CFLAGS $png_cflags" + LIBS="$png_ldflags -lz -lm $LIBS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[return !png_get_channels (0, 0);]])], + [HAVE_PNG=yes + PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"` + LIBPNG=$png_ldflags]) + CFLAGS=$SAVE_CFLAGS + LIBS=$SAVE_LIBS + AC_MSG_RESULT([$HAVE_PNG]) + fi + + # $LIBPNG requires explicit -lz in some cases. + # We don't know what those cases are, exactly, so play it safe and + # append -lz to any nonempty $LIBPNG, unless we're already using LIBZ. + case " $LIBPNG ",$LIBZ in + *' -lz '*, | *' ',?*) ;; + *) LIBPNG="$LIBPNG -lz" ;; + esac fi fi if test $HAVE_PNG = yes; then commit 3a718ffca097b35218c3e041a94adff937f3052f Author: Paul Eggert Date: Mon Feb 12 12:52:44 2018 -0800 Finish renaming to internal--daemon-sockname * doc/lispref/processes.texi (Misc Network): Omit discussion of internal--daemon-sockname, as non-Emacs code shouldn't rely on it. * src/process.c (syms_of_process): Rename internal-daemon-sockname to internal--daemon-sockname. All uses changed. diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 07317dd0dd..af177e053c 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -2862,9 +2862,9 @@ non-@code{nil} if that particular network option is supported by @node Misc Network @section Misc Network Facilities - These additional functions and variables are useful for creating and -operating on network connections. Note that they are supported only -on some systems. + These additional functions are useful for creating and operating +on network connections. Note that they are supported only on some +systems. @defun network-interface-list This function returns a list describing the network interfaces @@ -2913,17 +2913,6 @@ If the vector does not include the port number, @var{p}, or if @code{:@var{p}} suffix. @end defun -@defvar internal--daemon-sockname -This variable is set to the full path of the socket that has been -passed to Emacs during socket activation. This is then used to update -the @code{server-name} and @code{server-socket-dir} variables to -reflect the name and path of the socket that was used to launch the -Emacs daemon process. - -If Emacs wasn't started with socket activation, the value of this -variable is @code{nil}. -@end defvar - @node Serial Ports @section Communicating with Serial Ports @cindex @file{/dev/tty} diff --git a/lisp/server.el b/lisp/server.el index 744568a77d..d3933883cf 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -258,8 +258,8 @@ prevents multiple initializations when an external socket has been consumed.") (defcustom server-name - (if internal-daemon-sockname - (file-name-nondirectory internal-daemon-sockname) + (if internal--daemon-sockname + (file-name-nondirectory internal--daemon-sockname) "server") "The name of the Emacs server, if this Emacs process creates one. The command `server-start' makes use of this. It should not be @@ -271,8 +271,8 @@ changed while a server is running." ;; We do not use `temporary-file-directory' here, because emacsclient ;; does not read the init file. (defvar server-socket-dir - (if internal-daemon-sockname - (file-name-directory internal-daemon-sockname) + (if internal--daemon-sockname + (file-name-directory internal--daemon-sockname) (and (featurep 'make-network-process '(:family local)) (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid)))) "The directory in which to place the server socket. @@ -631,7 +631,7 @@ To force-start a server, do \\[server-force-delete] and then ;; Check to see if an uninitialized external socket has been ;; passed in, if that is the case, skip checking ;; `server-running-p' as this will return the wrong result. - (if (and internal-daemon-sockname + (if (and internal--daemon-sockname (not server--external-socket-initialized)) (setq server--external-socket-initialized t) ;; Delete the socket files made by previous server invocations. diff --git a/src/process.c b/src/process.c index fe55a482f5..2ec10b12ec 100644 --- a/src/process.c +++ b/src/process.c @@ -8023,7 +8023,7 @@ init_process_emacs (int sockfd) sockname = conv_sockaddr_to_lisp (&sa.sa, salen); } # endif - Vinternal_daemon_sockname = sockname; + Vinternal__daemon_sockname = sockname; max_desc = -1; memset (fd_callback_info, 0, sizeof (fd_callback_info)); @@ -8217,9 +8217,9 @@ These functions are called in the order of the list, until one of them returns non-`nil'. */); Vinterrupt_process_functions = list1 (Qinternal_default_interrupt_process); - DEFVAR_LISP ("internal-daemon-sockname", Vinternal_daemon_sockname, + DEFVAR_LISP ("internal--daemon-sockname", Vinternal__daemon_sockname, doc: /* Name of external socket passed to Emacs, or nil if none. */); - Vinternal_daemon_sockname = Qnil; + Vinternal__daemon_sockname = Qnil; DEFSYM (Qinternal_default_interrupt_process, "internal-default-interrupt-process"); commit 99cf1bb011e9a0848e0e1988c2441c472f8d9980 Author: Matthew Leach Date: Mon Feb 12 12:52:44 2018 -0800 Rename internal--external-sockname and document (Bug#24218) * lisp/server.el: Rename `internal--external-sockname' to `internal-daemon-sockname'. * src/process.c: Likewise. * doc/lispref/processes.texi: Document `internal-daemon-sockname'. diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index af177e053c..07317dd0dd 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -2862,9 +2862,9 @@ non-@code{nil} if that particular network option is supported by @node Misc Network @section Misc Network Facilities - These additional functions are useful for creating and operating -on network connections. Note that they are supported only on some -systems. + These additional functions and variables are useful for creating and +operating on network connections. Note that they are supported only +on some systems. @defun network-interface-list This function returns a list describing the network interfaces @@ -2913,6 +2913,17 @@ If the vector does not include the port number, @var{p}, or if @code{:@var{p}} suffix. @end defun +@defvar internal--daemon-sockname +This variable is set to the full path of the socket that has been +passed to Emacs during socket activation. This is then used to update +the @code{server-name} and @code{server-socket-dir} variables to +reflect the name and path of the socket that was used to launch the +Emacs daemon process. + +If Emacs wasn't started with socket activation, the value of this +variable is @code{nil}. +@end defvar + @node Serial Ports @section Communicating with Serial Ports @cindex @file{/dev/tty} diff --git a/lisp/server.el b/lisp/server.el index 70ac51e27d..744568a77d 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -258,8 +258,8 @@ prevents multiple initializations when an external socket has been consumed.") (defcustom server-name - (if internal--external-sockname - (file-name-nondirectory internal--external-sockname) + (if internal-daemon-sockname + (file-name-nondirectory internal-daemon-sockname) "server") "The name of the Emacs server, if this Emacs process creates one. The command `server-start' makes use of this. It should not be @@ -271,8 +271,8 @@ changed while a server is running." ;; We do not use `temporary-file-directory' here, because emacsclient ;; does not read the init file. (defvar server-socket-dir - (if internal--external-sockname - (file-name-directory internal--external-sockname) + (if internal-daemon-sockname + (file-name-directory internal-daemon-sockname) (and (featurep 'make-network-process '(:family local)) (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid)))) "The directory in which to place the server socket. @@ -631,7 +631,7 @@ To force-start a server, do \\[server-force-delete] and then ;; Check to see if an uninitialized external socket has been ;; passed in, if that is the case, skip checking ;; `server-running-p' as this will return the wrong result. - (if (and internal--external-sockname + (if (and internal-daemon-sockname (not server--external-socket-initialized)) (setq server--external-socket-initialized t) ;; Delete the socket files made by previous server invocations. diff --git a/src/process.c b/src/process.c index 8396a939c2..fe55a482f5 100644 --- a/src/process.c +++ b/src/process.c @@ -8023,7 +8023,7 @@ init_process_emacs (int sockfd) sockname = conv_sockaddr_to_lisp (&sa.sa, salen); } # endif - Vinternal__external_sockname = sockname; + Vinternal_daemon_sockname = sockname; max_desc = -1; memset (fd_callback_info, 0, sizeof (fd_callback_info)); @@ -8217,9 +8217,9 @@ These functions are called in the order of the list, until one of them returns non-`nil'. */); Vinterrupt_process_functions = list1 (Qinternal_default_interrupt_process); - DEFVAR_LISP ("internal--external-sockname", Vinternal__external_sockname, + DEFVAR_LISP ("internal-daemon-sockname", Vinternal_daemon_sockname, doc: /* Name of external socket passed to Emacs, or nil if none. */); - Vinternal__external_sockname = Qnil; + Vinternal_daemon_sockname = Qnil; DEFSYM (Qinternal_default_interrupt_process, "internal-default-interrupt-process"); commit b9a3cd6899136e13088003c3430e227be3faf9bb Author: Matthew Leach Date: Mon Feb 12 12:52:43 2018 -0800 Update `server-name' :version & document sockname (Bug#24218) * lisp/server.el: (server-name): Update :version tag. * etc/NEWS: Document that `server-name' and `server-socket-dir' automatically update. * doc/misc.texi: (Emacs Server): Likewise. diff --git a/etc/NEWS b/etc/NEWS index 005f177a27..71569c95ad 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -248,6 +248,9 @@ forward-comment, scan-sexps, and forward-sexp when parsing backward. The new variable 'comment-use-syntax-ppss' can be set to nil to recover the old behavior if needed. +** The `server-name' and `server-socket-dir' variables are set when a +socket has been pased to Emacs (Bug#24218). + --- ** The 'file-system-info' function is now available on all platforms. instead of just Microsoft platforms. This fixes a 'get-free-disk-space' commit d43a724f4ee247ad7a95d9e6ef174c7d16195fbe Author: Paul Eggert Date: Mon Feb 12 12:52:43 2018 -0800 Minor cleanups for server-name fix (Bug#24218) * lisp/server.el (server--external-socket-initialized): Rename from server-external-socket-initialised, since it should be private and Emacs uses American spelling. All uses changed. * src/emacs.c, src/lisp.h: Revert previous changes, as the initialization is now done in src/process.c, which already includes the relevant files. * src/process.c (union u_sockaddr): Move decl to top level. (external_sock_name, Fget_external_sockname): Remove, replacing with Vinternal__external_sockname. All uses changed. (init_process_emacs): Deduce socket name ourselves rather than have main.c do it. Use conv_sockaddr_to_lisp instead of doing it by hand. Conditionalize it on HAVE_GETSOCKNAME. diff --git a/lisp/server.el b/lisp/server.el index d2406e21bd..70ac51e27d 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -251,15 +251,15 @@ This means that the server should not kill the buffer when you say you are done with it in the server.") (make-variable-buffer-local 'server-existing-buffer) -(defvar server-external-socket-initialised nil +(defvar server--external-socket-initialized nil "When an external socket is passed into Emacs, we need to call -`server-start' in order to initialise the connection. This flag -prevents multiple initialisations when an external socket has +`server-start' in order to initialize the connection. This flag +prevents multiple initializations when an external socket has been consumed.") (defcustom server-name - (if (get-external-sockname) - (file-name-nondirectory (get-external-sockname)) + (if internal--external-sockname + (file-name-nondirectory internal--external-sockname) "server") "The name of the Emacs server, if this Emacs process creates one. The command `server-start' makes use of this. It should not be @@ -271,8 +271,8 @@ changed while a server is running." ;; We do not use `temporary-file-directory' here, because emacsclient ;; does not read the init file. (defvar server-socket-dir - (if (get-external-sockname) - (file-name-directory (get-external-sockname)) + (if internal--external-sockname + (file-name-directory internal--external-sockname) (and (featurep 'make-network-process '(:family local)) (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid)))) "The directory in which to place the server socket. @@ -628,15 +628,15 @@ To force-start a server, do \\[server-force-delete] and then (when server-process ;; kill it dead! (ignore-errors (delete-process server-process))) - ;; Check to see if an uninitialised external socket has been + ;; Check to see if an uninitialized external socket has been ;; passed in, if that is the case, skip checking ;; `server-running-p' as this will return the wrong result. - (if (and (get-external-sockname) - (not server-external-socket-initialised)) - (setq server-external-socket-initialised t) + (if (and internal--external-sockname + (not server--external-socket-initialized)) + (setq server--external-socket-initialized t) ;; Delete the socket files made by previous server invocations. (if (not (eq t (server-running-p server-name))) - ;; Remove any leftover socket or authentication file + ;; Remove any leftover socket or authentication file. (ignore-errors (let (delete-by-moving-to-trash) (delete-file server-file))) diff --git a/src/emacs.c b/src/emacs.c index c423faf6c0..8ea61b71fb 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -60,7 +60,6 @@ along with GNU Emacs. If not, see . */ #ifdef HAVE_LIBSYSTEMD # include # include -# include #endif #ifdef HAVE_WINDOW_SYSTEM @@ -1003,7 +1002,6 @@ main (int argc, char **argv) int sockfd = -1; - char *sockname = NULL; if (argmatch (argv, argc, "-fg-daemon", "--fg-daemon", 10, NULL, &skip_args) || argmatch (argv, argc, "-fg-daemon", "--fg-daemon", 10, &dname_arg, &skip_args)) @@ -1063,16 +1061,8 @@ main (int argc, char **argv) "Try 'Accept=false' in the Emacs socket unit file.\n")); else if (systemd_socket == 1 && (0 < sd_is_socket (SD_LISTEN_FDS_START, - AF_UNIX, SOCK_STREAM, 1))) - { - struct sockaddr_un sockaddr; - socklen_t sockaddr_sz = sizeof(sockaddr); - - sockfd = SD_LISTEN_FDS_START; - - if (!getsockname(sockfd, &sockaddr, &sockaddr_sz)) - sockname = strdup(sockaddr.sun_path); - } + AF_UNSPEC, SOCK_STREAM, 1))) + sockfd = SD_LISTEN_FDS_START; #endif /* HAVE_LIBSYSTEMD */ #ifdef USE_GTK @@ -1670,7 +1660,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem /* This can create a thread that may call getenv, so it must follow all calls to putenv and setenv. Also, this sets up add_keyboard_wait_descriptor, which init_display uses. */ - init_process_emacs (sockfd, sockname); + init_process_emacs (sockfd); init_keyboard (); /* This too must precede init_sys_modes. */ if (!noninteractive) diff --git a/src/lisp.h b/src/lisp.h index 0bd0e5e53c..a7f0a1d78f 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4316,7 +4316,7 @@ extern void delete_keyboard_wait_descriptor (int); extern void add_gpm_wait_descriptor (int); extern void delete_gpm_wait_descriptor (int); #endif -extern void init_process_emacs (int, char *); +extern void init_process_emacs (int); extern void syms_of_process (void); extern void setup_process_coding_systems (Lisp_Object); diff --git a/src/process.c b/src/process.c index 405c06db46..8396a939c2 100644 --- a/src/process.c +++ b/src/process.c @@ -160,6 +160,18 @@ static bool kbd_is_on_hold; when exiting. */ bool inhibit_sentinels; +union u_sockaddr +{ + struct sockaddr sa; + struct sockaddr_in in; +#ifdef AF_INET6 + struct sockaddr_in6 in6; +#endif +#ifdef HAVE_LOCAL_SOCKETS + struct sockaddr_un un; +#endif +}; + #ifdef subprocesses #ifndef SOCK_CLOEXEC @@ -276,10 +288,6 @@ static int max_desc; the file descriptor of a socket that is already bound. */ static int external_sock_fd; -/* The name (path) of the socket that was passed to Emacs, when - `external_sock_fd' is not -1. */ -static const char *external_sock_name = NULL; - /* Indexed by descriptor, gives the process (if any) for that descriptor. */ static Lisp_Object chan_process[FD_SETSIZE]; static void wait_for_socket_fds (Lisp_Object, char const *); @@ -4677,16 +4685,7 @@ server_accept_connection (Lisp_Object server, int channel) struct Lisp_Process *ps = XPROCESS (server); struct Lisp_Process *p; int s; - union u_sockaddr { - struct sockaddr sa; - struct sockaddr_in in; -#ifdef AF_INET6 - struct sockaddr_in6 in6; -#endif -#ifdef HAVE_LOCAL_SOCKETS - struct sockaddr_un un; -#endif - } saddr; + union u_sockaddr saddr; socklen_t len = sizeof saddr; ptrdiff_t count; @@ -7976,21 +7975,10 @@ restore_nofile_limit (void) } -DEFUN ("get-external-sockname", Fget_external_sockname, Sget_external_sockname, 0, 0, 0, - doc: /* Return the path of an external socket passed to Emacs. -Otherwise return nil. */) - (void) -{ - if (external_sock_name) - return make_string(external_sock_name, strlen(external_sock_name)); - else - return Qnil; -} - /* This is not called "init_process" because that is the name of a Mach system call, so it would cause problems on Darwin systems. */ void -init_process_emacs (int sockfd, char *sockname) +init_process_emacs (int sockfd) { #ifdef subprocesses int i; @@ -8025,7 +8013,18 @@ init_process_emacs (int sockfd, char *sockname) #endif external_sock_fd = sockfd; - external_sock_name = sockname; + Lisp_Object sockname = Qnil; +# if HAVE_GETSOCKNAME + if (0 <= sockfd) + { + union u_sockaddr sa; + socklen_t salen = sizeof sa; + if (getsockname (sockfd, &sa.sa, &salen) == 0) + sockname = conv_sockaddr_to_lisp (&sa.sa, salen); + } +# endif + Vinternal__external_sockname = sockname; + max_desc = -1; memset (fd_callback_info, 0, sizeof (fd_callback_info)); @@ -8218,6 +8217,10 @@ These functions are called in the order of the list, until one of them returns non-`nil'. */); Vinterrupt_process_functions = list1 (Qinternal_default_interrupt_process); + DEFVAR_LISP ("internal--external-sockname", Vinternal__external_sockname, + doc: /* Name of external socket passed to Emacs, or nil if none. */); + Vinternal__external_sockname = Qnil; + DEFSYM (Qinternal_default_interrupt_process, "internal-default-interrupt-process"); DEFSYM (Qinterrupt_process_functions, "interrupt-process-functions"); @@ -8320,5 +8323,4 @@ returns non-`nil'. */); defsubr (&Sprocess_inherit_coding_system_flag); defsubr (&Slist_system_processes); defsubr (&Sprocess_attributes); - defsubr (&Sget_external_sockname); } commit e1ca0ea87222e70710b3878ac80ed01f2378f050 Author: Matthew Leach Date: Mon Feb 12 12:52:43 2018 -0800 Fix `server-name' and `server-socket-dir' for (Bug#24218) * lisp/server.el: (server-external-socket-initialised): New (server-name): Compute server name from `get-external-sockname'. (server-socket-dir): Compute socket dir from `get-external-sockname'. (server-start): Don't check for existing server when an uninitialised external socket has been passed to Emacs. * src/emacs.c: (main): Obtain socket name via getsockname and pass to `init_process_emacs'. * src/lisp.h: (init_process_emacs): Add second parameter. * src/process.c: (external_sock_name): New. (get-external-sockname): New. (init_process_emacs): Set `external_sock_name' to `sockname' parameter. diff --git a/lisp/server.el b/lisp/server.el index d91a51e425..d2406e21bd 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -251,8 +251,16 @@ This means that the server should not kill the buffer when you say you are done with it in the server.") (make-variable-buffer-local 'server-existing-buffer) -;;;###autoload -(defcustom server-name "server" +(defvar server-external-socket-initialised nil + "When an external socket is passed into Emacs, we need to call +`server-start' in order to initialise the connection. This flag +prevents multiple initialisations when an external socket has +been consumed.") + +(defcustom server-name + (if (get-external-sockname) + (file-name-nondirectory (get-external-sockname)) + "server") "The name of the Emacs server, if this Emacs process creates one. The command `server-start' makes use of this. It should not be changed while a server is running." @@ -263,8 +271,10 @@ changed while a server is running." ;; We do not use `temporary-file-directory' here, because emacsclient ;; does not read the init file. (defvar server-socket-dir - (and (featurep 'make-network-process '(:family local)) - (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid))) + (if (get-external-sockname) + (file-name-directory (get-external-sockname)) + (and (featurep 'make-network-process '(:family local)) + (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid)))) "The directory in which to place the server socket. If local sockets are not supported, this is nil.") @@ -618,23 +628,29 @@ To force-start a server, do \\[server-force-delete] and then (when server-process ;; kill it dead! (ignore-errors (delete-process server-process))) - ;; Delete the socket files made by previous server invocations. - (if (not (eq t (server-running-p server-name))) - ;; Remove any leftover socket or authentication file - (ignore-errors - (let (delete-by-moving-to-trash) - (delete-file server-file))) - (setq server-mode nil) ;; already set by the minor mode code - (display-warning - 'server - (concat "Unable to start the Emacs server.\n" - (format "There is an existing Emacs server, named %S.\n" - server-name) - (substitute-command-keys - "To start the server in this Emacs process, stop the existing + ;; Check to see if an uninitialised external socket has been + ;; passed in, if that is the case, skip checking + ;; `server-running-p' as this will return the wrong result. + (if (and (get-external-sockname) + (not server-external-socket-initialised)) + (setq server-external-socket-initialised t) + ;; Delete the socket files made by previous server invocations. + (if (not (eq t (server-running-p server-name))) + ;; Remove any leftover socket or authentication file + (ignore-errors + (let (delete-by-moving-to-trash) + (delete-file server-file))) + (setq server-mode nil) ;; already set by the minor mode code + (display-warning + 'server + (concat "Unable to start the Emacs server.\n" + (format "There is an existing Emacs server, named %S.\n" + server-name) + (substitute-command-keys + "To start the server in this Emacs process, stop the existing server or call `\\[server-force-delete]' to forcibly disconnect it.")) - :warning) - (setq leave-dead t)) + :warning) + (setq leave-dead t))) ;; If this Emacs already had a server, clear out associated status. (while server-clients (server-delete-client (car server-clients))) diff --git a/src/emacs.c b/src/emacs.c index 8ea61b71fb..c423faf6c0 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -60,6 +60,7 @@ along with GNU Emacs. If not, see . */ #ifdef HAVE_LIBSYSTEMD # include # include +# include #endif #ifdef HAVE_WINDOW_SYSTEM @@ -1002,6 +1003,7 @@ main (int argc, char **argv) int sockfd = -1; + char *sockname = NULL; if (argmatch (argv, argc, "-fg-daemon", "--fg-daemon", 10, NULL, &skip_args) || argmatch (argv, argc, "-fg-daemon", "--fg-daemon", 10, &dname_arg, &skip_args)) @@ -1061,8 +1063,16 @@ main (int argc, char **argv) "Try 'Accept=false' in the Emacs socket unit file.\n")); else if (systemd_socket == 1 && (0 < sd_is_socket (SD_LISTEN_FDS_START, - AF_UNSPEC, SOCK_STREAM, 1))) - sockfd = SD_LISTEN_FDS_START; + AF_UNIX, SOCK_STREAM, 1))) + { + struct sockaddr_un sockaddr; + socklen_t sockaddr_sz = sizeof(sockaddr); + + sockfd = SD_LISTEN_FDS_START; + + if (!getsockname(sockfd, &sockaddr, &sockaddr_sz)) + sockname = strdup(sockaddr.sun_path); + } #endif /* HAVE_LIBSYSTEMD */ #ifdef USE_GTK @@ -1660,7 +1670,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem /* This can create a thread that may call getenv, so it must follow all calls to putenv and setenv. Also, this sets up add_keyboard_wait_descriptor, which init_display uses. */ - init_process_emacs (sockfd); + init_process_emacs (sockfd, sockname); init_keyboard (); /* This too must precede init_sys_modes. */ if (!noninteractive) diff --git a/src/lisp.h b/src/lisp.h index a7f0a1d78f..0bd0e5e53c 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4316,7 +4316,7 @@ extern void delete_keyboard_wait_descriptor (int); extern void add_gpm_wait_descriptor (int); extern void delete_gpm_wait_descriptor (int); #endif -extern void init_process_emacs (int); +extern void init_process_emacs (int, char *); extern void syms_of_process (void); extern void setup_process_coding_systems (Lisp_Object); diff --git a/src/process.c b/src/process.c index 2cc2c86df3..405c06db46 100644 --- a/src/process.c +++ b/src/process.c @@ -276,6 +276,10 @@ static int max_desc; the file descriptor of a socket that is already bound. */ static int external_sock_fd; +/* The name (path) of the socket that was passed to Emacs, when + `external_sock_fd' is not -1. */ +static const char *external_sock_name = NULL; + /* Indexed by descriptor, gives the process (if any) for that descriptor. */ static Lisp_Object chan_process[FD_SETSIZE]; static void wait_for_socket_fds (Lisp_Object, char const *); @@ -7972,10 +7976,21 @@ restore_nofile_limit (void) } +DEFUN ("get-external-sockname", Fget_external_sockname, Sget_external_sockname, 0, 0, 0, + doc: /* Return the path of an external socket passed to Emacs. +Otherwise return nil. */) + (void) +{ + if (external_sock_name) + return make_string(external_sock_name, strlen(external_sock_name)); + else + return Qnil; +} + /* This is not called "init_process" because that is the name of a Mach system call, so it would cause problems on Darwin systems. */ void -init_process_emacs (int sockfd) +init_process_emacs (int sockfd, char *sockname) { #ifdef subprocesses int i; @@ -8010,6 +8025,7 @@ init_process_emacs (int sockfd) #endif external_sock_fd = sockfd; + external_sock_name = sockname; max_desc = -1; memset (fd_callback_info, 0, sizeof (fd_callback_info)); @@ -8304,4 +8320,5 @@ returns non-`nil'. */); defsubr (&Sprocess_inherit_coding_system_flag); defsubr (&Slist_system_processes); defsubr (&Sprocess_attributes); + defsubr (&Sget_external_sockname); } commit b3f45140ec441bf88fa25f4e615b18e076d51342 Author: Tom Tromey Date: Wed Feb 7 21:26:53 2018 -0700 Minor fixes to .gdbinit * src/.gdbinit (xcompiled): Emit a final newline. (python): Define "long" if not already defined. Use casts to long, not int. diff --git a/src/.gdbinit b/src/.gdbinit index a5411e66d5..9fdcaf8661 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -819,6 +819,7 @@ define xcompiled xgetptr $ print (struct Lisp_Vector *) $ptr output ($->contents[0])@($->header.size & 0xff) + echo \n end document xcompiled Print $ as a compiled function pointer. @@ -1270,6 +1271,12 @@ end python +# Python 3 compatibility. +try: + long +except: + long = int + # Omit pretty-printing in older (pre-7.3) GDBs that lack it. if hasattr(gdb, 'printing'): @@ -1306,13 +1313,13 @@ if hasattr(gdb, 'printing'): # symbol table, guess reasonable defaults. sym = gdb.lookup_symbol ("EMACS_INT_WIDTH")[0] if sym: - EMACS_INT_WIDTH = int (sym.value ()) + EMACS_INT_WIDTH = long (sym.value ()) else: sym = gdb.lookup_symbol ("EMACS_INT")[0] EMACS_INT_WIDTH = 8 * sym.type.sizeof sym = gdb.lookup_symbol ("USE_LSB_TAG")[0] if sym: - USE_LSB_TAG = int (sym.value ()) + USE_LSB_TAG = long (sym.value ()) else: USE_LSB_TAG = 1 @@ -1334,7 +1341,7 @@ if hasattr(gdb, 'printing'): # integer. Also, val.cast (gdb.lookup.type ("EMACS_UINT")) # would have problems with GDB 7.12.1; see # . - ival = int (val) + ival = long (val) # For nil, yield "XIL(0)", which is easier to read than "XIL(0x0)". if not ival: commit 1590f8823d858b7bbad7f8a067fe356a19e1d5f8 Author: Paul Eggert Date: Mon Feb 12 07:26:45 2018 -0800 Revert libpng /usr/local patch It broke builds on Arch, Debian, OpenSuSE; see thread containing: https://lists.gnu.org/r/2018-02/msg00330.html * configure.ac: Don't try pkg-config; just use libpng-config. diff --git a/configure.ac b/configure.ac index ec25e9b8c7..f2a8332d71 100644 --- a/configure.ac +++ b/configure.ac @@ -3612,11 +3612,7 @@ elif test "${with_png}" != no; then if test "$opsys" = mingw32; then AC_CHECK_HEADER([png.h], [HAVE_PNG=yes]) elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then - EMACS_CHECK_MODULES([PNG], [libpng >= 1.0.0]) - if test $HAVE_PNG = no; then - # Test old way in case pkg-config doesn't have it (older machines). - AC_MSG_CHECKING([for libpng not configured by pkg-config]) - + AC_MSG_CHECKING([for png]) png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` && png_ldflags=`(libpng-config --ldflags) 2>&AS_MESSAGE_LOG_FD` || { # libpng-config does not work; configure by hand. @@ -3649,7 +3645,6 @@ elif test "${with_png}" != no; then CFLAGS=$SAVE_CFLAGS LIBS=$SAVE_LIBS AC_MSG_RESULT([$HAVE_PNG]) - fi fi fi if test $HAVE_PNG = yes; then commit e9ca57cfcbaf1a8dfc6bde5a2afd5f3c7b357cb1 Author: Paul Eggert Date: Sun Feb 11 18:43:34 2018 -0800 Work even if libpng is installed in /usr/local Problem reported by Werner Lemberg in: https://lists.gnu.org/r/emacs-devel/2018-02/msg00304.html * configure.ac: Try pkg-config before libpng-config. diff --git a/configure.ac b/configure.ac index f2a8332d71..ec25e9b8c7 100644 --- a/configure.ac +++ b/configure.ac @@ -3612,7 +3612,11 @@ elif test "${with_png}" != no; then if test "$opsys" = mingw32; then AC_CHECK_HEADER([png.h], [HAVE_PNG=yes]) elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then - AC_MSG_CHECKING([for png]) + EMACS_CHECK_MODULES([PNG], [libpng >= 1.0.0]) + if test $HAVE_PNG = no; then + # Test old way in case pkg-config doesn't have it (older machines). + AC_MSG_CHECKING([for libpng not configured by pkg-config]) + png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` && png_ldflags=`(libpng-config --ldflags) 2>&AS_MESSAGE_LOG_FD` || { # libpng-config does not work; configure by hand. @@ -3645,6 +3649,7 @@ elif test "${with_png}" != no; then CFLAGS=$SAVE_CFLAGS LIBS=$SAVE_LIBS AC_MSG_RESULT([$HAVE_PNG]) + fi fi fi if test $HAVE_PNG = yes; then commit 76a1bd1896655ef092f4510f2099a772d6bb1df5 Author: Dmitry Gutov Date: Mon Feb 12 03:27:52 2018 +0300 Fix an infloop in python-nav-beginning-of-statement * lisp/progmodes/python.el (python-nav-beginning-of-statement): Fix an infloop (bug#30277). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 5baf6e0f80..ff8269d970 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1474,7 +1474,7 @@ nested definitions." (defun python-nav-beginning-of-statement () "Move to start of current statement." (interactive "^") - (back-to-indentation) + (forward-line 0) (let* ((ppss (syntax-ppss)) (context-point (or @@ -1489,6 +1489,7 @@ nested definitions." (python-info-line-ends-backslash-p)) (forward-line -1) (python-nav-beginning-of-statement)))) + (back-to-indentation) (point-marker)) (defun python-nav-end-of-statement (&optional noend) commit 37b2f9f356b7ea7b3329345dac0eaae04c1ff642 Author: Paul Eggert Date: Sun Feb 11 13:09:24 2018 -0800 Merge from pkg-config * m4/pkg.m4: Copy from pkg-config 0.29.2. diff --git a/m4/pkg.m4 b/m4/pkg.m4 index 82bea96ee7..13a8890178 100644 --- a/m4/pkg.m4 +++ b/m4/pkg.m4 @@ -1,6 +1,6 @@ -dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -dnl serial 11 (pkg-config-0.29.1) -dnl +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 12 (pkg-config-0.29.2) + dnl Copyright © 2004 Scott James Remnant . dnl Copyright © 2012-2015 Dan Nicholson dnl @@ -41,7 +41,7 @@ dnl dnl See the "Since" comment for each macro you use to see what version dnl of the macros you require. m4_defun([PKG_PREREQ], -[m4_define([PKG_MACROS_VERSION], [0.29.1]) +[m4_define([PKG_MACROS_VERSION], [0.29.2]) m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) ])dnl PKG_PREREQ @@ -142,7 +142,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no -AC_MSG_CHECKING([for $1]) +AC_MSG_CHECKING([for $2]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) @@ -152,11 +152,11 @@ and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then - AC_MSG_RESULT([no]) + AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` - else + else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs @@ -173,7 +173,7 @@ installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then - AC_MSG_RESULT([no]) + AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full commit 65ebf7890922156eb056a1e61421f77d7ce158ef Author: Alan Third Date: Wed Feb 7 22:39:17 2018 +0000 Fix modifier keys on NS port * src/nsterm.m (EV_MODIFIERS_OPTION): (EV_MODIFIERS_CONTROL): (EV_MODIFIERS_COMMAND): New macros. (ev_modifiers_helper): New function. (EV_MODIFIERS2): Use new helper function. (EmacsView::keyDown): Remove duplicate functionality and handle fn key correctly. diff --git a/src/nsterm.m b/src/nsterm.m index 56a1e01ba1..29aef0e9b6 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -352,31 +352,56 @@ - (NSColor *)colorUsingDefaultColorSpace #define NSRightCommandKeyMask (0x000010 | NSEventModifierFlagCommand) #define NSLeftAlternateKeyMask (0x000020 | NSEventModifierFlagOption) #define NSRightAlternateKeyMask (0x000040 | NSEventModifierFlagOption) -#define EV_MODIFIERS2(flags) \ - (((flags & NSEventModifierFlagHelp) ? \ - hyper_modifier : 0) \ - | (!EQ (ns_right_alternate_modifier, Qleft) && \ - ((flags & NSRightAlternateKeyMask) \ - == NSRightAlternateKeyMask) ? \ - parse_solitary_modifier (ns_right_alternate_modifier) : 0) \ - | ((flags & NSEventModifierFlagOption) ? \ - parse_solitary_modifier (ns_alternate_modifier) : 0) \ - | ((flags & NSEventModifierFlagShift) ? \ - shift_modifier : 0) \ - | (!EQ (ns_right_control_modifier, Qleft) && \ - ((flags & NSRightControlKeyMask) \ - == NSRightControlKeyMask) ? \ - parse_solitary_modifier (ns_right_control_modifier) : 0) \ - | ((flags & NSEventModifierFlagControl) ? \ - parse_solitary_modifier (ns_control_modifier) : 0) \ - | ((flags & NS_FUNCTION_KEY_MASK) ? \ - parse_solitary_modifier (ns_function_modifier) : 0) \ - | (!EQ (ns_right_command_modifier, Qleft) && \ - ((flags & NSRightCommandKeyMask) \ - == NSRightCommandKeyMask) ? \ - parse_solitary_modifier (ns_right_command_modifier) : 0) \ - | ((flags & NSEventModifierFlagCommand) ? \ - parse_solitary_modifier (ns_command_modifier):0)) + +static unsigned int +ev_modifiers_helper (unsigned int flags, unsigned int left_mask, + unsigned int right_mask, unsigned int either_mask, + Lisp_Object left_modifier, Lisp_Object right_modifier) +{ + unsigned int modifiers = 0; + + if (flags & either_mask) + { + BOOL left_key = (flags & left_mask) == left_mask; + BOOL right_key = (flags & right_mask) == right_mask + && ! EQ (right_modifier, Qleft); + + if (right_key) + modifiers |= parse_solitary_modifier (right_modifier); + + /* GNUstep (and possibly macOS in certain circumstances) doesn't + differentiate between the left and right keys, so if we can't + identify which key it is, we use the left key setting. */ + if (left_key || ! right_key) + modifiers |= parse_solitary_modifier (left_modifier); + } + + return modifiers; +} + +#define EV_MODIFIERS2(flags) \ + (((flags & NSEventModifierFlagHelp) ? \ + hyper_modifier : 0) \ + | ((flags & NSEventModifierFlagShift) ? \ + shift_modifier : 0) \ + | ((flags & NS_FUNCTION_KEY_MASK) ? \ + parse_solitary_modifier (ns_function_modifier) : 0) \ + | ev_modifiers_helper (flags, NSLeftControlKeyMask, \ + NSRightControlKeyMask, \ + NSEventModifierFlagControl, \ + ns_control_modifier, \ + ns_right_control_modifier) \ + | ev_modifiers_helper (flags, NSLeftCommandKeyMask, \ + NSRightCommandKeyMask, \ + NSEventModifierFlagCommand, \ + ns_command_modifier, \ + ns_right_command_modifier) \ + | ev_modifiers_helper (flags, NSLeftAlternateKeyMask, \ + NSRightAlternateKeyMask, \ + NSEventModifierFlagOption, \ + ns_alternate_modifier, \ + ns_right_alternate_modifier)) + #define EV_MODIFIERS(e) EV_MODIFIERS2 ([e modifierFlags]) #define EV_UDMODIFIERS(e) \ @@ -6158,15 +6183,6 @@ flag set (this is probably a bug in the OS). code = fnKeysym; } - /* are there modifiers? */ - emacs_event->modifiers = 0; - - if (flags & NSEventModifierFlagHelp) - emacs_event->modifiers |= hyper_modifier; - - if (flags & NSEventModifierFlagShift) - emacs_event->modifiers |= shift_modifier; - /* The ⌘ and ⌥ modifiers can be either shift-like (for alternate character input) or control-like (as command prefix). If we have only shift-like modifiers, then we should use the @@ -6183,8 +6199,16 @@ untranslated characters (returned by the modifier keys, which returns 0 for shift-like modifiers. Therefore its return value is the set of control-like modifiers. */ - unsigned int control_modifiers = EV_MODIFIERS2 (flags); - emacs_event->modifiers |= control_modifiers; + emacs_event->modifiers = EV_MODIFIERS2 (flags); + + /* Function keys (such as the F-keys, arrow keys, etc.) set + modifiers as though the fn key has been pressed when it + hasn't. Also some combinations of fn and a function key + return a different key than was pressed (e.g. fn- gives + ). We need to unset the fn modifier in these cases. + FIXME: Can we avoid setting it in the first place. */ + if (fnKeysym && (flags & NS_FUNCTION_KEY_MASK)) + emacs_event->modifiers ^= parse_solitary_modifier (ns_function_modifier); if (NS_KEYLOG) fprintf (stderr, "keyDown: code =%x\tfnKey =%x\tflags = %x\tmods = %x\n", commit 68d8925077928422cf57625b0ad4b441e233b830 Author: Alan Third Date: Mon Feb 5 19:46:48 2018 +0000 Tidy up NS keybindings * lisp/term/ns-win.el: Remove unneeded mappings to super-shifted keys. diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index 4673af3001..ca2cc725a6 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el @@ -125,7 +125,6 @@ The properties returned may include `top', `left', `height', and `width'." (define-key global-map [?\s-h] 'ns-do-hide-emacs) (define-key global-map [?\s-H] 'ns-do-hide-others) (define-key global-map [?\M-\s-h] 'ns-do-hide-others) -(define-key key-translation-map [?\M-\s-\u02D9] [?\M-\s-h]) (define-key global-map [?\s-j] 'exchange-point-and-mark) (define-key global-map [?\s-k] 'kill-current-buffer) (define-key global-map [?\s-l] 'goto-line) @@ -144,8 +143,7 @@ The properties returned may include `top', `left', `height', and `width'." (define-key global-map [?\s-z] 'undo) (define-key global-map [?\s-|] 'shell-command-on-region) (define-key global-map [s-kp-bar] 'shell-command-on-region) -(define-key global-map [C-s- ] 'ns-do-show-character-palette) -(define-key key-translation-map [C-s-268632064] [C-s- ]) +(define-key global-map [?\C-\s- ] 'ns-do-show-character-palette) ;; (as in Terminal.app) (define-key global-map [s-right] 'ns-next-frame) (define-key global-map [s-left] 'ns-prev-frame) commit f7a853d818d4ef04ceefe5e34d445fd73da8fe11 Author: Alan Third Date: Sun Feb 11 11:34:49 2018 +0000 Remove NS special handling of 'frame-title-format' * lisp/term/ns-win.el (frame-title-format, icon-title-format): Change default format to just the filename. * src/nsfns.m (ns-use-proxy-icon): New variable. (ns_set_name_as_filename): Remove function. (x_implicitly_set_name): Get rid of special handling of frame-title-format. * src/nsterm.h (ns_set_represented_filename): Use new definition. * src/nsterm.m (ns_set_represented_filename): Move some of the logic from ns_set_name_as_filename into this function. diff --git a/etc/NEWS b/etc/NEWS index 8fed15af5b..005f177a27 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -289,6 +289,11 @@ Previously it was supported only in the Cygwin-w32 build. ** Emacs now handles key combinations involving the macOS "command" and "option" modifier keys more correctly. +** The special handling of `frame-title-format' on NS where setting it +to `t' would enable the macOS proxy icon has been replaced with a +separate variable, `ns-use-proxy-icon'. `frame-title-format' will now +work as on other platforms. + ---------------------------------------------------------------------- This file is part of GNU Emacs. diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index f8da1b2196..4673af3001 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el @@ -809,8 +809,8 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") ;; Set some options to be as Nextstep-like as possible. -(setq frame-title-format t - icon-title-format t) +(setq frame-title-format "%b" + icon-title-format "%b") (defvar ns-initialized nil diff --git a/src/nsfns.m b/src/nsfns.m index 0f60bb8107..bbb6644ce0 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -61,7 +61,6 @@ Updated by Christian Limpach (chris@nice.ch) static ptrdiff_t image_cache_refcount; static struct ns_display_info *ns_display_info_for_name (Lisp_Object); -static void ns_set_name_as_filename (struct frame *); /* ========================================================================== @@ -483,17 +482,10 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side { NSTRACE ("x_implicitly_set_name"); - Lisp_Object frame_title = buffer_local_value - (Qframe_title_format, XWINDOW (f->selected_window)->contents); - Lisp_Object icon_title = buffer_local_value - (Qicon_title_format, XWINDOW (f->selected_window)->contents); + if (! NILP (ns_use_proxy_icon)) + ns_set_represented_filename (f); - /* Deal with NS specific format t. */ - if (FRAME_NS_P (f) && ((FRAME_ICONIFIED_P (f) && EQ (icon_title, Qt)) - || EQ (frame_title, Qt))) - ns_set_name_as_filename (f); - else - ns_set_name (f, arg, 0); + ns_set_name (f, arg, 0); } @@ -520,78 +512,6 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side ns_set_name_internal (f, name); } - -static void -ns_set_name_as_filename (struct frame *f) -{ - NSView *view; - Lisp_Object name, filename; - Lisp_Object buf = XWINDOW (f->selected_window)->contents; - const char *title; - NSAutoreleasePool *pool; - Lisp_Object encoded_name, encoded_filename; - NSString *str; - NSTRACE ("ns_set_name_as_filename"); - - if (f->explicit_name || ! NILP (f->title)) - return; - - block_input (); - pool = [[NSAutoreleasePool alloc] init]; - filename = BVAR (XBUFFER (buf), filename); - name = BVAR (XBUFFER (buf), name); - - if (NILP (name)) - { - if (! NILP (filename)) - name = Ffile_name_nondirectory (filename); - else - name = build_string ([ns_app_name UTF8String]); - } - - encoded_name = ENCODE_UTF_8 (name); - - view = FRAME_NS_VIEW (f); - - title = FRAME_ICONIFIED_P (f) ? [[[view window] miniwindowTitle] UTF8String] - : [[[view window] title] UTF8String]; - - if (title && (! strcmp (title, SSDATA (encoded_name)))) - { - [pool release]; - unblock_input (); - return; - } - - str = [NSString stringWithUTF8String: SSDATA (encoded_name)]; - if (str == nil) str = @"Bad coding"; - - if (FRAME_ICONIFIED_P (f)) - [[view window] setMiniwindowTitle: str]; - else - { - NSString *fstr; - - if (! NILP (filename)) - { - encoded_filename = ENCODE_UTF_8 (filename); - - fstr = [NSString stringWithUTF8String: SSDATA (encoded_filename)]; - if (fstr == nil) fstr = @""; - } - else - fstr = @""; - - ns_set_represented_filename (fstr, f); - [[view window] setTitle: str]; - fset_name (f, name); - } - - [pool release]; - unblock_input (); -} - - void ns_set_doc_edited (void) { @@ -3311,6 +3231,11 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename doc: /* Toolkit version for NS Windowing. */); Vns_version_string = ns_appkit_version_str (); + DEFVAR_BOOL ("ns-use-proxy-icon", ns_use_proxy_icon, + doc: /* When non-nil display a proxy icon in the titlebar. +Default is t. */); + ns_use_proxy_icon = Qt; + defsubr (&Sns_read_file_name); defsubr (&Sns_get_resource); defsubr (&Sns_set_resource); diff --git a/src/nsterm.h b/src/nsterm.h index cc4c6d5e91..8b985930ec 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -1237,7 +1237,7 @@ extern void ns_finish_events (void); #ifdef __OBJC__ /* Needed in nsfns.m. */ extern void -ns_set_represented_filename (NSString *fstr, struct frame *f); +ns_set_represented_filename (struct frame *f); #endif diff --git a/src/nsterm.m b/src/nsterm.m index b7f5a32c09..56a1e01ba1 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -444,10 +444,38 @@ - (NSColor *)colorUsingDefaultColorSpace ========================================================================== */ void -ns_set_represented_filename (NSString *fstr, struct frame *f) +ns_set_represented_filename (struct frame *f) { + NSView *view; + Lisp_Object filename, encoded_filename; + Lisp_Object buf = XWINDOW (f->selected_window)->contents; + NSAutoreleasePool *pool; + NSString *fstr; + + NSTRACE ("ns_set_represented_filename"); + + if (f->explicit_name || ! NILP (f->title)) + return; + + block_input (); + pool = [[NSAutoreleasePool alloc] init]; + filename = BVAR (XBUFFER (buf), filename); + + if (! NILP (filename)) + { + encoded_filename = ENCODE_UTF_8 (filename); + + fstr = [NSString stringWithUTF8String: SSDATA (encoded_filename)]; + if (fstr == nil) fstr = @""; + } + else + fstr = @""; + represented_filename = [fstr retain]; represented_frame = f; + + [pool release]; + unblock_input (); } void commit 5a75cd1f8fbdb1dc5dbadf32c1e224e32a712194 Author: Paul Eggert Date: Sun Feb 11 09:58:10 2018 -0800 * src/xdisp.c (Vmessage_stack): Fix comment to match code. diff --git a/src/xdisp.c b/src/xdisp.c index 9a5bd2eb96..7c90d32db6 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -440,10 +440,8 @@ static Lisp_Object default_invis_vector[3]; Lisp_Object echo_area_window; -/* List of pairs (MESSAGE . MULTIBYTE). The function save_message - pushes the current message and the value of - message_enable_multibyte on the stack, the function restore_message - pops the stack and displays MESSAGE again. */ +/* Stack of messages, which are pushed by push_message and popped and + displayed by restore_message. */ static Lisp_Object Vmessage_stack;