commit cf897a70b70d0f82708be52e1734aac8f68eaf12 (HEAD, refs/remotes/origin/master) Author: Ken Brown Date: Wed Nov 16 18:24:41 2016 -0500 Unbreak the build on Darwin (Bug#24957) * src/fileio.c (file_name_case_insensitive_p) [DARWIN_OS]: Fix mistakes in recent commit. diff --git a/src/fileio.c b/src/fileio.c index 70799eb..66a4873 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2282,7 +2282,7 @@ file_name_case_insensitive_p (const char *filename) { /* This is based on developer.apple.com's getattrlist man page. */ struct attrlist alist = {.volattr = ATTR_VOL_CAPABILITIES}; - struct vol_capabilities_attr_t vcaps; + vol_capabilities_attr_t vcaps; if (getattrlist (filename, &alist, &vcaps, sizeof vcaps, 0) == 0) { if (vcaps.valid[VOL_CAPABILITIES_FORMAT] & VOL_CAP_FMT_CASE_SENSITIVE) @@ -2295,7 +2295,7 @@ file_name_case_insensitive_p (const char *filename) /* The following is based on http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */ struct attrlist alist; - unsigned char buffer[sizeof (vol_capabilities_attr_t) sizeof (size_t)]; + unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (size_t)]; memset (&alist, 0, sizeof (alist)); alist.volattr = ATTR_VOL_CAPABILITIES; commit f63976857b4458bc7712e91d95c04fe2e2ca0106 Author: Nicolas Petton Date: Wed Nov 16 18:37:26 2016 +0100 Do not use map.el in seq-tests.el * test/lisp/emacs-lisp/seq-tests.el: Do not use map.el. map.el was introduced in Emacs 25.1, but seq.el is also available in GNU ELPA for Emacs 24.5. diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el index 6d17b7c..2e533ac 100644 --- a/test/lisp/emacs-lisp/seq-tests.el +++ b/test/lisp/emacs-lisp/seq-tests.el @@ -28,7 +28,6 @@ (require 'ert) (require 'seq) -(require 'map) (defmacro with-test-sequences (spec &rest body) "Successively bind VAR to a list, vector, and string built from SEQ. @@ -374,14 +373,13 @@ Evaluate BODY for each created sequence. (ert-deftest test-seq-random-elt-take-all () (let ((seq '(a b c d e)) - (count '())) - (should (= 0 (map-length count))) + (elts '())) + (should (= 0 (length elts))) (dotimes (_ 1000) (let ((random-elt (seq-random-elt seq))) - (map-put count - random-elt - (map-elt count random-elt 0)))) - (should (= 5 (map-length count))))) + (add-to-list 'elts + random-elt))) + (should (= 5 (length elts))))) (ert-deftest test-seq-random-elt-signal-on-empty () (should-error (seq-random-elt nil)) commit 5ffdbe0a5ebcb3437356f60102b8e622cc608294 Author: Tino Calancha Date: Thu Nov 17 00:39:43 2016 +0900 Update parameter :version to 26.1 in several defcustom Following defcustom where added or modified for 25.2 release. In fact all these changes belong to 26.1 release. * lisp/battery.el (battery-linux-sysfs-regexp) * lisp/comint.el (comint-password-prompt-regexp) * lisp/dired.el (dired-always-read-filesystem) * lisp/image.el (image-scaling-factor) * lisp/ibuf-ext.el (ibuffer-never-search-content-name) (ibuffer-never-search-content-mode) * lisp/mouse.el (mouse-select-region-move-to-beginning) * lisp/net/net-utils.el (iwconfig-program, iwconfig-program-options) (netstat-program, route-program, route-program-options) * lisp/net/sieve-manage.el (sieve-manage-default-stream) * lisp/progmodes/grep.el (grep-save-buffers) * lisp/vc/add-log.el (change-log-directory-files) * lisp/url/url-vars.el (url-user-agent) * lisp/vc/vc-hg.el (vc-hg-symbolic-revision-styles) (vc-hg-use-file-version-for-mode-line-version) (vc-hg-parse-hg-data-structures) * lisp/wdired.el (wdired-create-parent-directories) * lisp/faces.el (homoglyph, nobreak-hyphen, read-multiple-choice-face) * lisp/gnus/gnus-art.el (gnus-article-encrypt-protocol) (gnus-button-url-regexp) * lisp/window.el (switch-to-buffer-preserve-window-point) * lisp/ibuffer.el (ibuffer-formats, ibuffer-locked-char) (ibuffer-locked-buffer) * lisp/textmodes/flyspell.el (flyspell-sort-corrections-function) * lisp/emacs-lisp/edebug.el (edebug-sit-on-break) * lisp/gnus/message.el (message-user-fqdn) * lisp/simple.el (shell-command-dont-erase-buffer) (extended-command-suggest-shorter) * lisp/net/shr.el (shr-use-fonts) * lisp/files.el (mounted-file-systems, kill-emacs-query-functions) diff --git a/lisp/battery.el b/lisp/battery.el index e6e79b0..10a3403 100644 --- a/lisp/battery.el +++ b/lisp/battery.el @@ -41,7 +41,7 @@ (defcustom battery-linux-sysfs-regexp "[bB][aA][tT][0-9]?$" "Regexp for folder names to be searched under /sys/class/power_supply/ that contain battery information." - :version "25.2" + :version "26.1" :type 'regexp :group 'battery) diff --git a/lisp/comint.el b/lisp/comint.el index 0319eeb..919265f 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -354,7 +354,7 @@ This variable is buffer-local." "\\(?: for .+\\)?[::៖]\\s *\\'") "Regexp matching prompts for passwords in the inferior process. This is used by `comint-watch-for-password-prompt'." - :version "25.2" + :version "26.1" :type 'regexp :group 'comint) diff --git a/lisp/dired.el b/lisp/dired.el index 7ead087..daa6d77 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -264,7 +264,7 @@ new Dired buffers." them: the search is performed on the temporary buffer, the original buffer visiting the file is not modified." :type 'boolean - :version "25.2" + :version "26.1" :group 'dired) ;; Internal variables diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index db78d94..66117b8 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -237,7 +237,7 @@ If the result is non-nil, then break. Errors are ignored." "Whether or not to pause for `edebug-sit-for-seconds' on reaching a break." :type 'boolean :group 'edebug - :version "25.2") + :version "26.1") ;;; Form spec utilities. diff --git a/lisp/faces.el b/lisp/faces.el index d6ec98b..6e3b08c 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -2476,7 +2476,7 @@ If you set `term-file-prefix' to nil, this function does nothing." (t :foreground "brown")) "Face for lookalike characters." :group 'basic-faces - :version "25.2") + :version "26.1") (defface nobreak-space '((((class color) (min-colors 88)) :inherit escape-glyph :underline t) @@ -2492,7 +2492,7 @@ If you set `term-file-prefix' to nil, this function does nothing." (t :foreground "brown")) "Face for displaying nobreak hyphens." :group 'basic-faces - :version "25.2") + :version "26.1") (defgroup mode-line-faces nil "Faces used in the mode line." @@ -2759,7 +2759,7 @@ It is used for characters of no fonts too." :weight bold))) "Face for the symbol name in `read-multiple-choice' output." :group 'basic-faces - :version "25.2") + :version "26.1") ;; Faces for TTY menus. (defface tty-menu-enabled-face diff --git a/lisp/files.el b/lisp/files.el index 7cfb20d..c50e6aa 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1321,7 +1321,7 @@ Optional second argument FLAVOR controls the units and the display format: "^\\(?:/\\(?:afs/\\|m\\(?:edia/\\|nt\\)\\|\\(?:ne\\|tmp_mn\\)t/\\)\\)") "File systems which ought to be mounted." :group 'files - :version "25.2" + :version "26.1" :require 'regexp-opt :type 'regexp) @@ -6756,7 +6756,7 @@ If any of these functions returns nil, killing Emacs is canceled. `save-buffers-kill-emacs' calls these functions, but `kill-emacs', the low level primitive, does not. See also `kill-emacs-hook'." :type 'hook - :version "25.2" + :version "26.1" :group 'convenience) (defcustom confirm-kill-emacs nil diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index 738adb5..0080b41 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -1612,7 +1612,7 @@ It is a string, such as \"PGP\". If nil, ask user." (defcustom gnus-use-idna t "Whether IDNA decoding of headers is used when viewing messages." - :version "25.2" + :version "26.1" :group 'gnus-article-headers :type 'boolean) @@ -7368,7 +7368,7 @@ groups." (defcustom gnus-button-valid-fqdn-regexp "\\([-A-Za-z0-9]+\\.\\)+[A-Za-z]+" "Regular expression that matches a valid FQDN." - :version "25.2" + :version "26.1" :group 'gnus-article-buttons :type 'regexp) diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index bdf1b15..52eaff3 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -1764,7 +1764,7 @@ no, only reply back to the author." (defcustom message-use-idna t "Whether to encode non-ASCII in domain names into ASCII according to IDNA." - :version "25.2" + :version "26.1" :group 'message-headers :link '(custom-manual "(message)IDNA") :type '(choice (const :tag "Ask" ask) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 1918ce8..b3d1452 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -98,7 +98,7 @@ regardless of any active filters in this buffer." (push (format "%s%s%s" beg str end) excluded))) "A list of regexps for buffers ignored by `ibuffer-mark-by-content-regexp'. Buffers whose name matches a regexp in this list, are not searched." - :version "25.2" + :version "26.1" :type '(repeat regexp) :require 'ibuf-ext :group 'ibuffer) @@ -106,7 +106,7 @@ Buffers whose name matches a regexp in this list, are not searched." (defcustom ibuffer-never-search-content-mode '(dired-mode) "A list of major modes ignored by `ibuffer-mark-by-content-regexp'. Buffers whose major mode is in this list, are not searched." - :version "25.2" + :version "26.1" :type '(repeat regexp) :require 'ibuf-ext :group 'ibuffer) diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index 9becfc9..b33c2e3 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el @@ -138,7 +138,7 @@ value for this variable would be Using \\[ibuffer-switch-format], you can rotate the display between the specified formats in the list." - :version "25.2" + :version "26.1" :type '(repeat sexp) :group 'ibuffer) @@ -285,7 +285,7 @@ Note that this specialized filtering occurs before real filtering." (defcustom ibuffer-locked-char ?L "The character to display for locked buffers." - :version "25.2" + :version "26.1" :type 'character :group 'ibuffer) @@ -1773,7 +1773,7 @@ If point is on a group name, this function operates on that group." '((((background dark)) (:foreground "RosyBrown")) (t (:foreground "brown4"))) "*Face used for locked buffers in Ibuffer." - :version "25.2" + :version "26.1" :group 'ibuffer :group 'font-lock-highlighting-faces) (defvar ibuffer-locked-buffer 'ibuffer-locked-buffer) diff --git a/lisp/image.el b/lisp/image.el index e1f52de..82e0162 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -135,7 +135,7 @@ size), or the symbol `auto', which will compute a scaling factor based on the font pixel size." :type '(choice number (const :tag "Automatically compute" auto)) - :version "25.2") + :version "26.1") ;; Map put into text properties on images. (defvar image-map diff --git a/lisp/mouse.el b/lisp/mouse.el index 8c83f5e..db9f13b 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -551,7 +551,7 @@ non-nil means move point to beginning of region." :type '(choice (const :tag "Don't move point" nil) (const :tag "Move point to beginning of region" t)) :group 'mouse - :version "25.2") + :version "26.1") (defun mouse-set-point (event &optional promote-to-region) "Move point to the position clicked on with the mouse. diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el index 1547f52..73d6ff4 100644 --- a/lisp/net/net-utils.el +++ b/lisp/net/net-utils.el @@ -119,7 +119,7 @@ These options can be used to limit how many ICMP packets are emitted." "Program to print wireless network configuration information." :group 'net-utils :type 'string - :version "25.2") + :version "26.1") (defcustom iwconfig-program-options (cond ((string-match-p "iw\\'" iwconfig-program) (list "dev")) @@ -127,7 +127,7 @@ These options can be used to limit how many ICMP packets are emitted." "Options for the iwconfig program." :group 'net-utils :type '(repeat string) - :version "25.2") + :version "26.1") (defcustom netstat-program (cond ((executable-find "netstat") "netstat") @@ -136,7 +136,7 @@ These options can be used to limit how many ICMP packets are emitted." "Program to print network statistics." :group 'net-utils :type 'string - :version "25.2") + :version "26.1") (defcustom netstat-program-options (list "-a") @@ -165,7 +165,7 @@ These options can be used to limit how many ICMP packets are emitted." "Program to print routing tables." :group 'net-utils :type 'string - :version "25.2") + :version "26.1") (defcustom route-program-options (cond ((eq system-type 'windows-nt) (list "print")) @@ -174,7 +174,7 @@ These options can be used to limit how many ICMP packets are emitted." "Options for the route program." :group 'net-utils :type '(repeat string) - :version "25.2") + :version "26.1") (defcustom nslookup-program "nslookup" "Program to interactively query DNS information." diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 5660355..f1b0087 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -68,7 +68,7 @@ fit these criteria." (defcustom shr-use-colors t "If non-nil, respect color specifications in the HTML." - :version "25.2" + :version "26.1" :group 'shr :type 'boolean) diff --git a/lisp/net/sieve-manage.el b/lisp/net/sieve-manage.el index c8276e7..8f7bd44 100644 --- a/lisp/net/sieve-manage.el +++ b/lisp/net/sieve-manage.el @@ -148,7 +148,7 @@ for doing the actual authentication." (defcustom sieve-manage-ignore-starttls nil "Ignore STARTTLS even if STARTTLS capability is provided." - :version "25.2" + :version "26.1" :type 'boolean :group 'sieve-manage) diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index f7f097b..5112c6b 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -235,7 +235,7 @@ buffer should be saved or not. E.g., one can set this to (lambda () (string-prefix-p my-grep-root (file-truename (buffer-file-name)))) to limit saving to files located under `my-grep-root'." - :version "25.2" + :version "26.1" :type '(choice (const :tag "Ask before saving" ask) (const :tag "Don't save buffers" nil) diff --git a/lisp/simple.el b/lisp/simple.el index fe61325..2506c4a 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -50,7 +50,7 @@ restore the buffer position before the command." (const :tag "Set point to end of last output" end-last-out) (const :tag "Save point" save-point)) :group 'shell - :version "25.2") + :version "26.1") (defvar shell-command-saved-pos nil "Point position in the output buffer after command complete. @@ -1659,7 +1659,7 @@ If the value is non-nil and not a number, we wait 2 seconds." "If non-nil, show a shorter M-x invocation when there is one." :group 'keyboard :type 'boolean - :version "25.2") + :version "26.1") (defun execute-extended-command--shorter-1 (name length) (cond diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 042b7d4..29aa231 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -102,7 +102,7 @@ This only happens if `flyspell-sort-corrections' is non-nil. The function takes three parameters -- the two correction candidates to be sorted, and the third parameter is the word that's being corrected." - :version "25.2" + :version "26.1" :type 'function :group 'flyspell) diff --git a/lisp/url/url-vars.el b/lisp/url/url-vars.el index f6aae21..1286d6c 100644 --- a/lisp/url/url-vars.el +++ b/lisp/url/url-vars.el @@ -373,7 +373,7 @@ Should be one of: (const :tag "No User-Agent at all" :value nil) (const :tag "An string auto-generated according to `url-privacy-level'" :value default)) - :version "25.2" + :version "26.1" :group 'url) (defvar url-setup-done nil "Has setup configuration been done?") diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el index b516b67..7124df0 100644 --- a/lisp/vc/add-log.el +++ b/lisp/vc/add-log.el @@ -175,7 +175,7 @@ Note: The search is conducted only within 10%, at the beginning of the file." "List of files that cause `find-change-log' to stop in containing directory. This applies if no pre-existing ChangeLog is found. If nil, then in such a case simply use the directory containing the changed file." - :version "25.2" + :version "26.1" :type '(repeat file) :group 'change-log) diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 78ff56c..cee01ee 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -280,7 +280,7 @@ If no list entry produces a useful revision, return `nil'." (const :tag "Active bookmark" 'bookmark) (string :tag "Hg template") (function :tag "Custom"))) - :version "25.2" + :version "26.1" :group 'vc-hg) (defcustom vc-hg-use-file-version-for-mode-line-version nil @@ -289,7 +289,7 @@ When not, the revision in the modeline is for the repository working copy. `nil' is the much faster setting for large repositories." :type 'boolean - :version "25.2" + :version "26.1" :group 'vc-hg) (defun vc-hg--active-bookmark-internal (rev) @@ -574,7 +574,7 @@ directly instead of always running Mercurial. We try to be safe against Mercurial data structure format changes and always fall back to running Mercurial directly." :type 'boolean - :version "25.2" + :version "26.1" :group 'vc-hg) (defsubst vc-hg--read-u8 () diff --git a/lisp/wdired.el b/lisp/wdired.el index 5b23f84..f059ab7 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -158,7 +158,7 @@ If non-nil, when you rename a file to a destination path within a nonexistent directory, wdired will create any parent directories necessary. When nil, attempts to rename a file into a nonexistent directory will fail." - :version "25.2" + :version "26.1" :type 'boolean :group 'wdired) diff --git a/lisp/window.el b/lisp/window.el index da3691e..5255905 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -7519,7 +7519,7 @@ the selected window or never appeared in it before, or if (const :tag "If already displayed elsewhere" already-displayed) (const :tag "Always" t)) :group 'windows - :version "25.2") + :version "26.1") (defcustom switch-to-buffer-in-dedicated-window nil "Allow switching to buffer in strongly dedicated windows. commit 36b99556dea23f17d5598bbed366e7201eec9fbb Author: Glenn Morris Date: Tue Nov 15 23:28:47 2016 -0800 Add --new-daemon, which runs in the foreground and does not fork This is intended for modern init systems such as systemd, which manage many of the traditional aspects of daemon behavior themselves. (Bug#2677) * src/emacs.c (daemon_type): New integer. (usage, standard_args): Add --old-daemon and --new-daemon. (main): Handle --old-daemon and --new-daemon arguments. Restrict all the forking and complicated daemon stuff to old-daemon. (Fdaemon_initialized): Handle new-style daemon. * src/lisp.h (IS_DAEMON, DAEMON_RUNNING) [!WINDOWNT]: Replace daemon_pipe with daemon_type. * doc/emacs/cmdargs.texi (Initial Options): * doc/emacs/glossary.texi (Glossary): * doc/emacs/misc.texi (Emacs Server): * doc/lispref/display.texi (Window Systems): * doc/lispref/os.texi (Startup Summary): Related doc updates. * etc/NEWS: Mention this. * etc/emacs.service: Use Type=simple and --new-daemon. diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi index 444d305..8d3d936 100644 --- a/doc/emacs/cmdargs.texi +++ b/doc/emacs/cmdargs.texi @@ -334,17 +334,18 @@ setting @code{inhibit-x-resources} to @code{t} (@pxref{Resources}). @item -daemon @opindex -daemon -@itemx --daemon +@itemx --daemon[=@var{name}] @opindex --daemon +@itemx --old-daemon[=@var{name}] +@itemx --new-daemon[=@var{name}] Start Emacs as a daemon---after Emacs starts up, it starts the Emacs -server and disconnects from the terminal without opening any frames. +server without opening any frames. +(Optionally, you can specify an explicit @var{name} for the server.) You can then use the @command{emacsclient} command to connect to Emacs for editing. @xref{Emacs Server}, for information about using Emacs -as a daemon. - -@item -daemon=@var{SERVER-NAME} -Start emacs in background as a daemon, and use @var{SERVER-NAME} as -the server name. +as a daemon. An ``old-style'' daemon disconnects from the terminal +and runs in the background (@samp{--daemon} is an alias for +@samp{--old-daemon}). @item --no-desktop @opindex --no-desktop diff --git a/doc/emacs/glossary.texi b/doc/emacs/glossary.texi index bce97da..d648939 100644 --- a/doc/emacs/glossary.texi +++ b/doc/emacs/glossary.texi @@ -338,8 +338,8 @@ or by rebinding key sequences (@pxref{Keymaps}). @item Daemon A daemon is a standard term for a system-level process that runs in the background. Daemons are often started when the system first starts up. -When Emacs runs in daemon-mode, it runs in the background and does not -open a display. You can then connect to it with the +When Emacs runs in daemon-mode, it does not +open a display. You connect to it with the @command{emacsclient} program. @xref{Emacs Server}. @item Default Argument diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index cb0a116..2290dec 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi @@ -1583,11 +1583,10 @@ dies with the Emacs process. @cindex daemon, Emacs @item -Run Emacs as a @dfn{daemon}, using the @samp{--daemon} command-line -option. @xref{Initial Options}. When Emacs is started this way, it -calls @code{server-start} after initialization, and returns control to -the calling terminal instead of opening an initial frame; it then -waits in the background, listening for edit requests. +Run Emacs as a @dfn{daemon}, using one of the @samp{--daemon} command-line +options. @xref{Initial Options}. When Emacs is started this way, it +calls @code{server-start} after initialization and does not open an +initial frame. It then waits for edit requests from clients. @cindex systemd unit file @item diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 381edba..d050738 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -7166,7 +7166,7 @@ Emacs is displaying the frame on a character-based terminal. @defvar initial-window-system This variable holds the value of @code{window-system} used for the first frame created by Emacs during startup. (When Emacs is invoked -with the @option{--daemon} option, it does not create any initial +as a daemon, it does not create any initial frames, so @code{initial-window-system} is @code{nil}, except on MS-Windows, where it is still @code{w32}. @xref{Initial Options, daemon,, emacs, The GNU Emacs Manual}.) diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 97b086c..3312705 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -112,8 +112,8 @@ compiled into the Emacs executable when it was built. It runs the normal hook @code{before-init-hook}. @item -If appropriate, it creates a graphical frame. This is not done if the -options @samp{--batch} or @samp{--daemon} were specified. +If appropriate, it creates a graphical frame. This is not done in +batch (noninteractive) or daemon mode. @item It initializes the initial frame's faces, and sets up the menu bar @@ -256,10 +256,10 @@ options were specified. @c last few bits of command-line-1 are not done in batch mode. @item -If the option @code{--daemon} was specified, it calls -@code{server-start}, and on Posix systems also detaches from the -controlling terminal. @xref{Emacs Server,,, emacs, The GNU Emacs -Manual}. +If a daemon was requested, it calls @code{server-start}. +(On Posix systems, if a background daemon was requested, it then +detaches from the controlling terminal.) @xref{Emacs +Server,,, emacs, The GNU Emacs Manual}. @item If started by the X session manager, it calls @@ -337,7 +337,10 @@ Do not display a splash screen. Run without an interactive terminal. @xref{Batch Mode}. @item --daemon -Do not initialize any display; just start a server in the background. +@itemx --old-daemon +@itemx --new-daemon +Do not initialize any display; just start a server. +(An ``old-style'' daemon automatically runs in the background.) @item --no-init-file @itemx -q diff --git a/etc/NEWS b/etc/NEWS index 34d64bf..15c264f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -64,6 +64,12 @@ affected by this, as SGI stopped supporting IRIX in December 2013. * Startup Changes in Emacs 26.1 +** New option '--new-daemon'. This is the same as '--daemon', except +it runs in the foreground and does not fork. This is intended for +modern init systems such as systemd, which manage many of the traditional +aspects of daemon behavior themselves. '--old-daemon' is now an alias +for '--daemon'. + * Changes in Emacs 26.1 diff --git a/etc/emacs.service b/etc/emacs.service index 92cdeb5..d9f7fc5 100644 --- a/etc/emacs.service +++ b/etc/emacs.service @@ -7,8 +7,8 @@ Description=Emacs text editor Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/ [Service] -Type=forking -ExecStart=emacs --daemon +Type=simple +ExecStart=emacs --new-daemon ExecStop=emacsclient --eval "(kill-emacs)" Environment=SSH_AUTH_SOCK=%t/keyring/ssh Restart=on-failure diff --git a/src/emacs.c b/src/emacs.c index aeba963..92cbb08 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -162,8 +162,8 @@ char *stack_bottom; static uprintmax_t heap_bss_diff; #endif -/* To run as a daemon under Cocoa or Windows, we must do a fork+exec, - not a simple fork. +/* To run as a background daemon under Cocoa or Windows, + we must do a fork+exec, not a simple fork. On Cocoa, CoreFoundation lib fails in forked process: http://developer.apple.com/ReleaseNotes/ @@ -190,9 +190,12 @@ bool build_details; /* Name for the server started by the daemon.*/ static char *daemon_name; +/* 0 not a daemon, 1 new-style (foreground), 2 old-style (background). */ +int daemon_type; + #ifndef WINDOWSNT -/* Pipe used to send exit notification to the daemon parent at - startup. */ +/* Pipe used to send exit notification to the background daemon parent at + startup. On Windows, we use a kernel event instead. */ int daemon_pipe[2]; #else HANDLE w32_daemon_event; @@ -223,7 +226,8 @@ Initialization options:\n\ "\ --batch do not do interactive display; implies -q\n\ --chdir DIR change to directory DIR\n\ ---daemon[=NAME] start a (named) server in the background\n\ +--daemon, --old-daemon[=NAME] start a (named) server in the background\n\ +--new-daemon[=NAME] start a (named) server in the foreground\n\ --debug-init enable Emacs Lisp debugger for init file\n\ --display, -d DISPLAY use X server DISPLAY\n\ ", @@ -977,6 +981,8 @@ main (int argc, char **argv) exit (0); } + daemon_type = 0; + #ifndef WINDOWSNT /* Make sure IS_DAEMON starts up as false. */ daemon_pipe[1] = 0; @@ -987,38 +993,52 @@ main (int argc, char **argv) int sockfd = -1; - if (argmatch (argv, argc, "-daemon", "--daemon", 5, NULL, &skip_args) - || argmatch (argv, argc, "-daemon", "--daemon", 5, &dname_arg, &skip_args)) + if (argmatch (argv, argc, "-new-daemon", "--new-daemon", 10, NULL, &skip_args) + || argmatch (argv, argc, "-new-daemon", "--new-daemon", 10, &dname_arg, &skip_args)) + { + daemon_type = 1; /* foreground */ + } + else if (argmatch (argv, argc, "-daemon", "--daemon", 5, NULL, &skip_args) + || argmatch (argv, argc, "-daemon", "--daemon", 5, &dname_arg, &skip_args) + || argmatch (argv, argc, "-old-daemon", "--old-daemon", 10, NULL, &skip_args) + || argmatch (argv, argc, "-old-daemon", "--old-daemon", 10, &dname_arg, &skip_args)) + { + daemon_type = 2; /* background */ + } + + + if (daemon_type > 0) { #ifndef DOS_NT - pid_t f; - - /* Start as a daemon: fork a new child process which will run the - rest of the initialization code, then exit. - - Detaching a daemon requires the following steps: - - fork - - setsid - - exit the parent - - close the tty file-descriptors - - We only want to do the last 2 steps once the daemon is ready to - serve requests, i.e. after loading .emacs (initialization). - OTOH initialization may start subprocesses (e.g. ispell) and these - should be run from the proper process (the one that will end up - running as daemon) and with the proper "session id" in order for - them to keep working after detaching, so fork and setsid need to be - performed before initialization. - - We want to avoid exiting before the server socket is ready, so - use a pipe for synchronization. The parent waits for the child - to close its end of the pipe (using `daemon-initialized') - before exiting. */ - if (emacs_pipe (daemon_pipe) != 0) - { - fprintf (stderr, "Cannot pipe!\n"); - exit (1); - } + if (daemon_type == 2) + { + /* Start as a background daemon: fork a new child process which + will run the rest of the initialization code, then exit. + + Detaching a daemon requires the following steps: + - fork + - setsid + - exit the parent + - close the tty file-descriptors + + We only want to do the last 2 steps once the daemon is ready to + serve requests, i.e. after loading .emacs (initialization). + OTOH initialization may start subprocesses (e.g. ispell) and these + should be run from the proper process (the one that will end up + running as daemon) and with the proper "session id" in order for + them to keep working after detaching, so fork and setsid need to be + performed before initialization. + + We want to avoid exiting before the server socket is ready, so + use a pipe for synchronization. The parent waits for the child + to close its end of the pipe (using `daemon-initialized') + before exiting. */ + if (emacs_pipe (daemon_pipe) != 0) + { + fprintf (stderr, "Cannot pipe!\n"); + exit (1); + } + } /* daemon_type == 2 */ #ifdef HAVE_LIBSYSTEMD /* Read the number of sockets passed through by systemd. */ @@ -1035,99 +1055,105 @@ main (int argc, char **argv) sockfd = SD_LISTEN_FDS_START; #endif /* HAVE_LIBSYSTEMD */ -#ifndef DAEMON_MUST_EXEC #ifdef USE_GTK fprintf (stderr, "\nWarning: due to a long standing Gtk+ bug\nhttp://bugzilla.gnome.org/show_bug.cgi?id=85715\n\ Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.\n\ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.\n"); #endif /* USE_GTK */ - f = fork (); -#else /* DAEMON_MUST_EXEC */ - if (!dname_arg || !strchr (dname_arg, '\n')) - f = fork (); /* in orig */ - else - f = 0; /* in exec'd */ -#endif /* !DAEMON_MUST_EXEC */ - if (f > 0) - { - int retval; - char buf[1]; - - /* Close unused writing end of the pipe. */ - emacs_close (daemon_pipe[1]); - /* Just wait for the child to close its end of the pipe. */ - do - { - retval = read (daemon_pipe[0], &buf, 1); - } - while (retval == -1 && errno == EINTR); - - if (retval < 0) - { - fprintf (stderr, "Error reading status from child\n"); - exit (1); - } - else if (retval == 0) - { - fprintf (stderr, "Error: server did not start correctly\n"); - exit (1); - } + if (daemon_type == 2) + { + pid_t f; +#ifndef DAEMON_MUST_EXEC - emacs_close (daemon_pipe[0]); - exit (0); - } - if (f < 0) - { - emacs_perror ("fork"); - exit (EXIT_CANCELED); - } + f = fork (); +#else /* DAEMON_MUST_EXEC */ + if (!dname_arg || !strchr (dname_arg, '\n')) + f = fork (); /* in orig */ + else + f = 0; /* in exec'd */ +#endif /* !DAEMON_MUST_EXEC */ + if (f > 0) + { + int retval; + char buf[1]; + + /* Close unused writing end of the pipe. */ + emacs_close (daemon_pipe[1]); + + /* Just wait for the child to close its end of the pipe. */ + do + { + retval = read (daemon_pipe[0], &buf, 1); + } + while (retval == -1 && errno == EINTR); + + if (retval < 0) + { + fprintf (stderr, "Error reading status from child\n"); + exit (1); + } + else if (retval == 0) + { + fprintf (stderr, "Error: server did not start correctly\n"); + exit (1); + } + + emacs_close (daemon_pipe[0]); + exit (0); + } + if (f < 0) + { + emacs_perror ("fork"); + exit (EXIT_CANCELED); + } #ifdef DAEMON_MUST_EXEC - { - /* In orig process, forked as child, OR in exec'd. */ - if (!dname_arg || !strchr (dname_arg, '\n')) - { /* In orig, child: now exec w/special daemon name. */ - char fdStr[80]; - int fdStrlen = - snprintf (fdStr, sizeof fdStr, - "--daemon=\n%d,%d\n%s", daemon_pipe[0], - daemon_pipe[1], dname_arg ? dname_arg : ""); - - if (! (0 <= fdStrlen && fdStrlen < sizeof fdStr)) - { - fprintf (stderr, "daemon: child name too long\n"); - exit (EXIT_CANNOT_INVOKE); + { + /* In orig process, forked as child, OR in exec'd. */ + if (!dname_arg || !strchr (dname_arg, '\n')) + { /* In orig, child: now exec w/special daemon name. */ + char fdStr[80]; + int fdStrlen = + snprintf (fdStr, sizeof fdStr, + "--old-daemon=\n%d,%d\n%s", daemon_pipe[0], + daemon_pipe[1], dname_arg ? dname_arg : ""); + + if (! (0 <= fdStrlen && fdStrlen < sizeof fdStr)) + { + fprintf (stderr, "daemon: child name too long\n"); + exit (EXIT_CANNOT_INVOKE); + } + + argv[skip_args] = fdStr; + + fcntl (daemon_pipe[0], F_SETFD, 0); + fcntl (daemon_pipe[1], F_SETFD, 0); + execvp (argv[0], argv); + emacs_perror (argv[0]); + exit (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE); } - argv[skip_args] = fdStr; - - fcntl (daemon_pipe[0], F_SETFD, 0); - fcntl (daemon_pipe[1], F_SETFD, 0); - execvp (argv[0], argv); - emacs_perror (argv[0]); - exit (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE); - } - - /* In exec'd: parse special dname into pipe and name info. */ - if (!dname_arg || !strchr (dname_arg, '\n') - || strlen (dname_arg) < 1 || strlen (dname_arg) > 70) + /* In exec'd: parse special dname into pipe and name info. */ + if (!dname_arg || !strchr (dname_arg, '\n') + || strlen (dname_arg) < 1 || strlen (dname_arg) > 70) { fprintf (stderr, "emacs daemon: daemon name absent or too long\n"); exit (EXIT_CANNOT_INVOKE); } - dname_arg2[0] = '\0'; - sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]), - dname_arg2); - dname_arg = *dname_arg2 ? dname_arg2 : NULL; - fcntl (daemon_pipe[1], F_SETFD, FD_CLOEXEC); - } + dname_arg2[0] = '\0'; + sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]), + dname_arg2); + dname_arg = *dname_arg2 ? dname_arg2 : NULL; + fcntl (daemon_pipe[1], F_SETFD, FD_CLOEXEC); + } #endif /* DAEMON_MUST_EXEC */ - /* Close unused reading end of the pipe. */ - emacs_close (daemon_pipe[0]); + /* Close unused reading end of the pipe. */ + emacs_close (daemon_pipe[0]); - setsid (); + setsid (); + } /* daemon_type == 2 */ #elif defined(WINDOWSNT) /* Indicate that we want daemon mode. */ w32_daemon_event = CreateEvent (NULL, TRUE, FALSE, W32_DAEMON_EVENT); @@ -1138,7 +1164,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem exit (1); } #else /* MSDOS */ - fprintf (stderr, "This platform does not support the -daemon flag.\n"); + fprintf (stderr, "This platform does not support daemon mode.\n"); exit (1); #endif /* MSDOS */ if (dname_arg) @@ -1684,6 +1710,8 @@ static const struct standard_args standard_args[] = { "-batch", "--batch", 100, 0 }, { "-script", "--script", 100, 1 }, { "-daemon", "--daemon", 99, 0 }, + { "-old-daemon", "--old-daemon", 99, 0 }, + { "-new-daemon", "--new-daemon", 99, 0 }, { "-help", "--help", 90, 0 }, { "-nl", "--no-loadup", 70, 0 }, { "-nsl", "--no-site-lisp", 65, 0 }, @@ -2407,27 +2435,33 @@ from the parent process and its tty file descriptors. */) if (NILP (Vafter_init_time)) error ("This function can only be called after loading the init files"); #ifndef WINDOWSNT - int nfd; - - /* Get rid of stdin, stdout and stderr. */ - nfd = emacs_open ("/dev/null", O_RDWR, 0); - err |= nfd < 0; - err |= dup2 (nfd, STDIN_FILENO) < 0; - err |= dup2 (nfd, STDOUT_FILENO) < 0; - err |= dup2 (nfd, STDERR_FILENO) < 0; - err |= emacs_close (nfd) != 0; - - /* Closing the pipe will notify the parent that it can exit. - FIXME: In case some other process inherited the pipe, closing it here - won't notify the parent because it's still open elsewhere, so we - additionally send a byte, just to make sure the parent really exits. - Instead, we should probably close the pipe in start-process and - call-process to make sure the pipe is never inherited by - subprocesses. */ - err |= write (daemon_pipe[1], "\n", 1) < 0; - err |= emacs_close (daemon_pipe[1]) != 0; + + if (daemon_type == 2) + { + int nfd; + + /* Get rid of stdin, stdout and stderr. */ + nfd = emacs_open ("/dev/null", O_RDWR, 0); + err |= nfd < 0; + err |= dup2 (nfd, STDIN_FILENO) < 0; + err |= dup2 (nfd, STDOUT_FILENO) < 0; + err |= dup2 (nfd, STDERR_FILENO) < 0; + err |= emacs_close (nfd) != 0; + + /* Closing the pipe will notify the parent that it can exit. + FIXME: In case some other process inherited the pipe, closing it here + won't notify the parent because it's still open elsewhere, so we + additionally send a byte, just to make sure the parent really exits. + Instead, we should probably close the pipe in start-process and + call-process to make sure the pipe is never inherited by + subprocesses. */ + err |= write (daemon_pipe[1], "\n", 1) < 0; + err |= emacs_close (daemon_pipe[1]) != 0; + } + /* Set it to an invalid value so we know we've already run this function. */ - daemon_pipe[1] = -1; + daemon_type = -1; + #else /* WINDOWSNT */ /* Signal the waiting emacsclient process. */ err |= SetEvent (w32_daemon_event) == 0; diff --git a/src/lisp.h b/src/lisp.h index aaa4423..e087828 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4139,12 +4139,11 @@ extern bool no_site_lisp; /* True means put details like time stamps into builds. */ extern bool build_details; -/* Pipe used to send exit notification to the daemon parent at - startup. On Windows, we use a kernel event instead. */ #ifndef WINDOWSNT -extern int daemon_pipe[2]; -#define IS_DAEMON (daemon_pipe[1] != 0) -#define DAEMON_RUNNING (daemon_pipe[1] >= 0) +/* 0 not a daemon, 1 new-style (foreground), 2 old-style (background). */ +extern int daemon_type; +#define IS_DAEMON (daemon_type != 0) +#define DAEMON_RUNNING (daemon_type >= 0) #else /* WINDOWSNT */ extern void *w32_daemon_event; #define IS_DAEMON (w32_daemon_event != NULL) commit 35007ad9daca9cac39fe758b5815aa6389379d38 Author: Glenn Morris Date: Tue Nov 15 18:21:06 2016 -0500 * src/emacs.c (usage_message): Mention named daemon. (Bug#24949) * doc/man/emacs.1.in: Likewise. diff --git a/doc/man/emacs.1.in b/doc/man/emacs.1.in index 3b1566f..73bc38d 100644 --- a/doc/man/emacs.1.in +++ b/doc/man/emacs.1.in @@ -123,11 +123,13 @@ Use specified as the terminal instead of using stdin/stdout. This must be the first argument specified in the command line. .TP -.B \-\-daemon +.BI \-\-daemon "\fR[=\fPname\fR]" Start Emacs as a daemon, enabling the Emacs server and disconnecting -from the terminal. You can then use the emacsclient command to -connect to the server (see -.BR emacsclient (1)). +from the terminal. You can then use the emacsclient (see +.BR emacsclient (1)) +command to +connect to the server (with optional +.IR name ")." .TP .B \-\-version Display diff --git a/src/emacs.c b/src/emacs.c index 75328c5..aeba963 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -223,7 +223,7 @@ Initialization options:\n\ "\ --batch do not do interactive display; implies -q\n\ --chdir DIR change to directory DIR\n\ ---daemon start a server in the background\n\ +--daemon[=NAME] start a (named) server in the background\n\ --debug-init enable Emacs Lisp debugger for init file\n\ --display, -d DISPLAY use X server DISPLAY\n\ ", commit 8b48e937af801e11e2d1844d60b6e585ce09dcea Author: Ken Brown Date: Mon Nov 14 17:26:12 2016 -0500 Simplify case-insensitivity checks on Mac OS X * src/fileio.c (file_name_case_insensitive_p): Try skipping the Darwin code and instead using pathconf with _PC_CASE_SENSITIVE. Leave in two alternatives conditionally compiled based on DARWIN_OS_CASE_SENSITIVE_FIXME in case pathconf doesn't work. * etc/PROBLEMS: Mention the possible problem with pathconf on Mac OS X. diff --git a/etc/PROBLEMS b/etc/PROBLEMS index 62d2bd1..bbf865c 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS @@ -2415,6 +2415,18 @@ If this does not work, please inform bug-gnu-emacs@gnu.org. Then please call support for your X-server and see if you can get a fix. If you do, please send it to bug-gnu-emacs@gnu.org so we can list it here. + +* Runtime problems specific to Mac OS X + +** On Mac OS X, file-name-case-insensitive-p may be unreliable + +The implementation of that function on Mac OS X uses pathconf with the +_PC_CASE_SENSITIVE flag. There have been reports that this use of +pathconf does not work reliably. If you have a problem, please +recompile Emacs with -DDARWIN_OS_CASE_SENSITIVE_FIXME=1 or +-DDARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying +whether this fixed your problem. + * Build-time problems ** Configuration diff --git a/src/fileio.c b/src/fileio.c index f3f8f42..70799eb 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2251,33 +2251,66 @@ internal_delete_file (Lisp_Object filename) static bool file_name_case_insensitive_p (const char *filename) { -#ifdef DOS_NT - return 1; -#elif defined CYGWIN -/* As of Cygwin-2.6.1, pathconf supports _PC_CASE_INSENSITIVE. */ -# ifdef _PC_CASE_INSENSITIVE + /* Use pathconf with _PC_CASE_INSENSITIVE or _PC_CASE_SENSITIVE if + those flags are available. As of this writing (2016-11-14), + Cygwin is the only platform known to support the former (starting + with Cygwin-2.6.1), and Mac OS X is the only platform known to + support the latter. + + There have been reports that pathconf with _PC_CASE_SENSITIVE + does not work reliably on Mac OS X. If you have a problem, + please recompile Emacs with -DDARWIN_OS_CASE_SENSITIVE_FIXME=1 or + -DDARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying + whether this fixed your problem. */ + +#ifdef _PC_CASE_INSENSITIVE int res = pathconf (filename, _PC_CASE_INSENSITIVE); - if (res < 0) - return 1; - return res > 0; -# else - return 1; + if (res >= 0) + return res > 0; +#elif defined _PC_CASE_SENSITIVE && !defined DARWIN_OS_CASE_SENSITIVE_FIXME + int res = pathconf (filename, _PC_CASE_SENSITIVE); + if (res >= 0) + return res == 0; +#endif + +#ifdef DARWIN_OS +# ifndef DARWIN_OS_CASE_SENSITIVE_FIXME + int DARWIN_OS_CASE_SENSITIVE_FIXME = 0; # endif -#elif defined DARWIN_OS - /* The following is based on - http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */ - struct attrlist alist; - unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (size_t)]; - - memset (&alist, 0, sizeof (alist)); - alist.volattr = ATTR_VOL_CAPABILITIES; - if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0) - || !(alist.volattr & ATTR_VOL_CAPABILITIES)) - return 0; - vol_capabilities_attr_t *vcaps = buffer; - return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); + + if (DARWIN_OS_CASE_SENSITIVE_FIXME == 1) + { + /* This is based on developer.apple.com's getattrlist man page. */ + struct attrlist alist = {.volattr = ATTR_VOL_CAPABILITIES}; + struct vol_capabilities_attr_t vcaps; + if (getattrlist (filename, &alist, &vcaps, sizeof vcaps, 0) == 0) + { + if (vcaps.valid[VOL_CAPABILITIES_FORMAT] & VOL_CAP_FMT_CASE_SENSITIVE) + return ! (vcaps.capabilities[VOL_CAPABILITIES_FORMAT] + & VOL_CAP_FMT_CASE_SENSITIVE); + } + } + else if (DARWIN_OS_CASE_SENSITIVE_FIXME == 2) + { + /* The following is based on + http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */ + struct attrlist alist; + unsigned char buffer[sizeof (vol_capabilities_attr_t) sizeof (size_t)]; + + memset (&alist, 0, sizeof (alist)); + alist.volattr = ATTR_VOL_CAPABILITIES; + if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0) + || !(alist.volattr & ATTR_VOL_CAPABILITIES)) + return 0; + vol_capabilities_attr_t *vcaps = buffer; + return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); + } +#endif /* DARWIN_OS */ + +#if defined CYGWIN || defined DOS_NT + return true; #else - return 0; + return false; #endif } commit 9ed2502878d16ed7f20e8b4817e1eed963468de7 Author: Glenn Morris Date: Tue Nov 15 17:14:27 2016 -0500 * src/emacs.c (sort_args): Warn about multiple matches. diff --git a/src/emacs.c b/src/emacs.c index b74df21..75328c5 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1870,9 +1870,13 @@ sort_args (int argc, char **argv) fatal ("Option '%s' requires an argument\n", argv[from]); from += options[from]; } - /* FIXME When match < 0, shouldn't there be some error, - or at least indication to the user that there was a - problem? */ + else if (match == -2) + { + /* This is an internal error. + Eg if one long option is a prefix of another. */ + fprintf (stderr, "Option '%s' matched multiple standard arguments\n", argv[from]); + } + /* Should we not also warn if there was no match? */ } done: ; } commit 52092f0a85ee77d0d996f6bb148b9dc5e70640db Merge: 024d5b0 e6681b2 Author: Michael Albinus Date: Tue Nov 15 20:51:20 2016 +0100 Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs commit 024d5b0c41aa9963f87c50372ecca2c3883918bb Author: Michael Albinus Date: Tue Nov 15 20:50:49 2016 +0100 Implement file name handler for `file-name-case-insensitive-p' * doc/lispref/files.texi (Truenames): `file-name-case-insensitive-p' is also applicable for remote hosts. * lisp/net/tramp.el (tramp-methods): Improve docstring. (tramp-file-name-for-operation): Add `file-name-case-insensitive-p'. (tramp-handle-file-name-case-insensitive-p): New defun. * lisp/net/tramp-smb.el (tramp-methods) : Add `tramp-case-insensitive' entry. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist) * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist) * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist) * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist) : Add handler. (Bug#22300, Bug#24441) diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 70c7177..e189da9 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi @@ -1154,7 +1154,9 @@ on Mac OS X. Currently this function always returns @code{nil} on platforms other than MS-DOS, MS-Windows, Cygwin, and Mac OS X. It does not detect case-insensitivity of mounted filesystems, such as Samba shares or -NFS-mounted Windows volumes. +NFS-mounted Windows volumes. On remote hosts, it assumes @code{t} for +the @samp{smb} method. For all other connection methods, runtime +tests are performed. @end defun @defun file-in-directory-p file dir diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 1aae0ec..f03f50b 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -126,6 +126,7 @@ It is used for TCP/IP devices." (file-modes . tramp-handle-file-modes) (file-name-all-completions . tramp-adb-handle-file-name-all-completions) (file-name-as-directory . tramp-handle-file-name-as-directory) + (file-name-case-insensitive-p . tramp-handle-file-name-case-insensitive-p) (file-name-completion . tramp-handle-file-name-completion) (file-name-directory . tramp-handle-file-name-directory) (file-name-nondirectory . tramp-handle-file-name-nondirectory) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index a84097c..d87de46 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -480,6 +480,7 @@ Every entry is a list (NAME ADDRESS).") (file-modes . tramp-handle-file-modes) (file-name-all-completions . tramp-gvfs-handle-file-name-all-completions) (file-name-as-directory . tramp-handle-file-name-as-directory) + (file-name-case-insensitive-p . tramp-handle-file-name-case-insensitive-p) (file-name-completion . tramp-handle-file-name-completion) (file-name-directory . tramp-handle-file-name-directory) (file-name-nondirectory . tramp-handle-file-name-nondirectory) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 1682b16..9496ebf 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -1027,6 +1027,7 @@ of command line.") (file-modes . tramp-handle-file-modes) (file-name-all-completions . tramp-sh-handle-file-name-all-completions) (file-name-as-directory . tramp-handle-file-name-as-directory) + (file-name-case-insensitive-p . tramp-handle-file-name-case-insensitive-p) (file-name-completion . tramp-handle-file-name-completion) (file-name-directory . tramp-handle-file-name-directory) (file-name-nondirectory . tramp-handle-file-name-nondirectory) diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 7c60070..61796a2 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -49,7 +49,9 @@ ;; This is just a guess. We don't know whether the share "C$" ;; is available for public use, and whether the user has write ;; access. - (tramp-tmpdir "/C$/Temp")))) + (tramp-tmpdir "/C$/Temp") + ;; Another guess. We might implement a better check later on. + (tramp-case-insensitive t)))) ;; Add a default for `tramp-default-method-alist'. Rule: If there is ;; a domain in USER, it must be the SMB method. @@ -243,6 +245,7 @@ See `tramp-actions-before-shell' for more info.") (file-modes . tramp-handle-file-modes) (file-name-all-completions . tramp-smb-handle-file-name-all-completions) (file-name-as-directory . tramp-handle-file-name-as-directory) + (file-name-case-insensitive-p . tramp-handle-file-name-case-insensitive-p) (file-name-completion . tramp-handle-file-name-completion) (file-name-directory . tramp-handle-file-name-directory) (file-name-nondirectory . tramp-handle-file-name-nondirectory) @@ -501,7 +504,8 @@ pass to the OPERATION." ;; target. (make-directory (expand-file-name - ".." (concat tmpdir localname)) 'parents) + ".." (concat tmpdir localname)) + 'parents) (make-symbolic-link newname (directory-file-name (concat tmpdir localname)))) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 5d56fdf..b0391ec 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -255,6 +255,11 @@ pair of the form (KEY VALUE). The following KEYs are defined: In general, the global default value shall be used, but for some methods, like \"su\" or \"sudo\", a shorter timeout might be desirable. + * `tramp-case-insensitive' + Whether the remote file system handles file names case insensitive. + Only a non-nil value counts, the default value nil means to + perform further checks on the remote host. See + `tramp-connection-properties' for a way to overwrite this. What does all this mean? Well, you should specify `tramp-login-program' for all methods; this program is used to log in to the remote site. Then, @@ -1919,8 +1924,7 @@ ARGS are the arguments OPERATION has been called with." file-accessible-directory-p file-attributes file-directory-p file-executable-p file-exists-p file-local-copy file-modes - file-name-as-directory file-name-case-insensitive-p - file-name-directory + file-name-as-directory file-name-directory file-name-nondirectory file-name-sans-versions file-ownership-preserved-p file-readable-p file-regular-p file-remote-p file-symlink-p file-truename @@ -1931,7 +1935,9 @@ ARGS are the arguments OPERATION has been called with." unhandled-file-name-directory vc-registered ;; Emacs 24+ only. file-acl file-notify-add-watch file-selinux-context - set-file-acl set-file-selinux-context)) + set-file-acl set-file-selinux-context + ;; Emacs 26+ only. + file-name-case-insensitive-p)) (if (file-name-absolute-p (nth 0 args)) (nth 0 args) (expand-file-name (nth 0 args)))) @@ -2888,6 +2894,47 @@ User is always nil." 'file-name-as-directory (list (or (tramp-file-name-localname v) "")))) (tramp-file-name-hop v)))) +(defun tramp-handle-file-name-case-insensitive-p (filename) + "Like `file-name-case-insensitive-p' for Tramp files." + ;; We make it a connection property, assuming that all file systems + ;; on the remote host behave similar. This might be wrong for + ;; mounted NFS directories or SMB/AFP shares; such more granular + ;; tests will be added in case they are needed. + (setq filename (expand-file-name filename)) + (with-parsed-tramp-file-name filename nil + (or ;; Maybe there is a default value. + (tramp-get-method-parameter v 'tramp-case-insensitive) + + ;; There isn't. So we must check. + (with-tramp-connection-property v "case-insensitive" + ;; The idea is to compare a file with lower case letters with + ;; the same file with upper case letters. + (let ((candidate (directory-file-name filename)) + tmpfile) + ;; Check, whether we find an existing file with lower case + ;; letters. This avoids us to create a temporary file. + (while (and (string-match "[a-z]" (file-remote-p candidate 'localname)) + (not (file-exists-p candidate))) + (setq candidate + (directory-file-name (file-name-directory candidate)))) + ;; Nothing found, so we must use a temporary file for + ;; comparision. `make-nearby-temp-file' is added to Emacs + ;; 26+ like `file-name-case-insensitive-p', so there is no + ;; compatibility problem calling it. + (unless (string-match "[a-z]" (file-remote-p candidate 'localname)) + (setq tmpfile + (let ((default-directory (file-name-directory filename))) + (tramp-compat-funcall 'make-nearby-temp-file "tramp.")) + candidate tmpfile)) + ;; Check for the existence of the same file with upper case letters. + (unwind-protect + (file-exists-p + (concat + (file-remote-p candidate) + (upcase (file-remote-p candidate 'localname)))) + ;; Cleanup. + (when tmpfile (delete-file tmpfile)))))))) + (defun tramp-handle-file-name-completion (filename directory &optional predicate) "Like `file-name-completion' for Tramp files." commit e6681b27394a23979c3aef3925f78ef9cd75bd32 Author: Mark Oteiza Date: Tue Nov 15 13:31:31 2016 -0500 Nix more uses of default-FOO variables (Bug#24946) * lisp/cedet/semantic/util-modes.el (semantic-stickyfunc-mode): Check for header-line-format instead. * lisp/emulation/viper.el (viper-load-custom-file): Reference major-mode instead. * lisp-mail-feedmail.el (feedmail-fill-to-cc-fill-column): Use fill-column instead. diff --git a/lisp/cedet/semantic/util-modes.el b/lisp/cedet/semantic/util-modes.el index 6b80c96..4f7f051 100644 --- a/lisp/cedet/semantic/util-modes.el +++ b/lisp/cedet/semantic/util-modes.el @@ -712,7 +712,7 @@ minor mode is enabled." ;; Disable minor mode if semantic stuff not available (setq semantic-stickyfunc-mode nil) (error "Buffer %s was not set up for parsing" (buffer-name))) - (unless (boundp 'default-header-line-format) + (unless (boundp 'header-line-format) ;; Disable if there are no header lines to use. (setq semantic-stickyfunc-mode nil) (error "Sticky Function mode requires Emacs")) diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index 04a7c22..c5dac55 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el @@ -1234,7 +1234,7 @@ These two lines must come in the order given.")) (if (null viper-saved-non-viper-variables) (setq viper-saved-non-viper-variables (list - (cons 'default-major-mode (list (default-value 'major-mode))) + (cons 'major-mode (list (default-value 'major-mode))) (cons 'next-line-add-newlines (list next-line-add-newlines)) (cons 'require-final-newline (list require-final-newline)) (cons 'scroll-step (list scroll-step)) diff --git a/lisp/mail/feedmail.el b/lisp/mail/feedmail.el index bb93cff9..eed664d 100644 --- a/lisp/mail/feedmail.el +++ b/lisp/mail/feedmail.el @@ -504,7 +504,7 @@ as-is. The filling is done after mail address alias expansion." ) -(defcustom feedmail-fill-to-cc-fill-column default-fill-column +(defcustom feedmail-fill-to-cc-fill-column (default-value 'fill-column) "Fill column used by `feedmail-fill-to-cc'." :group 'feedmail-headers :type 'integer commit 4e2ef64449ce5dc91e2d533c0fbaaf50b0e92f3b Author: Simen Heggestøyl Date: Tue Nov 15 19:08:22 2016 +0100 Complete the name of PostgreSQL databases * lisp/progmodes/sql.el (sql-postgres-login-params): Complete database name. (sql-postgres-list-databases): New function returning a list of available PostgreSQL databases. * test/lisp/progmodes/sql-tests.el: New file with tests for sql.el. diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index a11d456..4d0bed7 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -1072,14 +1072,26 @@ add your name with a \"-U\" prefix (such as \"-Umark\") to the list." :version "20.8" :group 'SQL) -(defcustom sql-postgres-login-params `((user :default ,(user-login-name)) - (database :default ,(user-login-name)) - server) +(defcustom sql-postgres-login-params + `((user :default ,(user-login-name)) + (database :default ,(user-login-name) + :completion ,(completion-table-dynamic + (lambda (_) (sql-postgres-list-databases)))) + server) "List of login parameters needed to connect to Postgres." :type 'sql-login-params :version "24.1" :group 'SQL) +(defun sql-postgres-list-databases () + "Return a list of available PostgreSQL databases." + (when (executable-find sql-postgres-program) + (let ((res '())) + (dolist (row (process-lines sql-postgres-program "-ltX")) + (when (string-match "^ \\([[:alnum:]-_]+\\) +|.*" row) + (push (match-string 1 row) res))) + (nreverse res)))) + ;; Customization for Interbase (defcustom sql-interbase-program "isql" diff --git a/test/lisp/progmodes/sql-tests.el b/test/lisp/progmodes/sql-tests.el new file mode 100644 index 0000000..e05247a --- /dev/null +++ b/test/lisp/progmodes/sql-tests.el @@ -0,0 +1,47 @@ +;;; sql-tests.el --- Tests for sql.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2016 Free Software Foundation, Inc. + +;; Author: Simen Heggestøyl +;; Keywords: + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;; + +;;; Code: + +(require 'cl-lib) +(require 'ert) +(require 'sql) + +(ert-deftest sql-tests-postgres-list-databases () + "Test that output from `psql -ltX' is parsed correctly." + (cl-letf + (((symbol-function 'executable-find) + (lambda (_command) t)) + ((symbol-function 'process-lines) + (lambda (_program &rest _args) + '(" db-name-1 | foo-user | UTF8 | en_US.UTF-8 | en_US.UTF-8 | " + " db_name_2 | foo-user | UTF8 | en_US.UTF-8 | en_US.UTF-8 | " + "")))) + (should (equal (sql-postgres-list-databases) + '("db-name-1" "db_name_2"))))) + +(provide 'sql-tests) +;;; sql-tests.el ends here