commit f1d34d9136fbf1dc2cf58b5ba36311451f024956 (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Tue Apr 4 18:39:43 2017 -0700 Minor cleanups related to type-of * src/data.c (Frecordp): Rename from Frecordp_p, for consistency. * src/data.c (syms_of_data): * src/frame.c (syms_of_frame): Put all the primitive type names together, under the "Types that type-of returns" comment. diff --git a/src/data.c b/src/data.c index 5fdbec2000..3ffca54658 100644 --- a/src/data.c +++ b/src/data.c @@ -368,7 +368,7 @@ DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, return Qnil; } -DEFUN ("recordp", Frecordp_p, Srecordp, 1, 1, 0, +DEFUN ("recordp", Frecordp, Srecordp, 1, 1, 0, doc: /* Return t if OBJECT is a record. */) (Lisp_Object object) { @@ -3589,7 +3589,6 @@ syms_of_data (void) DEFSYM (Qquote, "quote"); DEFSYM (Qlambda, "lambda"); - DEFSYM (Qsubr, "subr"); DEFSYM (Qerror_conditions, "error-conditions"); DEFSYM (Qerror_message, "error-message"); DEFSYM (Qtop_level, "top-level"); @@ -3737,6 +3736,7 @@ syms_of_data (void) DEFSYM (Qwindow_configuration, "window-configuration"); DEFSYM (Qprocess, "process"); DEFSYM (Qwindow, "window"); + DEFSYM (Qsubr, "subr"); DEFSYM (Qcompiled_function, "compiled-function"); DEFSYM (Qbuffer, "buffer"); DEFSYM (Qframe, "frame"); @@ -3748,12 +3748,12 @@ syms_of_data (void) DEFSYM (Qthread, "thread"); DEFSYM (Qmutex, "mutex"); DEFSYM (Qcondition_variable, "condition-variable"); - - DEFSYM (Qdefun, "defun"); - DEFSYM (Qfont_spec, "font-spec"); DEFSYM (Qfont_entity, "font-entity"); DEFSYM (Qfont_object, "font-object"); + DEFSYM (Qterminal, "terminal"); + + DEFSYM (Qdefun, "defun"); DEFSYM (Qinteractive_form, "interactive-form"); DEFSYM (Qdefalias_fset_function, "defalias-fset-function"); diff --git a/src/frame.c b/src/frame.c index 162b2038fd..d873147fc8 100644 --- a/src/frame.c +++ b/src/frame.c @@ -4923,8 +4923,6 @@ syms_of_frame (void) DEFSYM (Qx_resource_name, "x-resource-name"); DEFSYM (Qx_frame_parameter, "x-frame-parameter"); - DEFSYM (Qterminal, "terminal"); - DEFSYM (Qworkarea, "workarea"); DEFSYM (Qmm_size, "mm-size"); DEFSYM (Qframes, "frames"); commit ab0a27517c9f9cc9d7a29171558247471ebe1152 Author: Glenn Morris Date: Tue Apr 4 20:19:24 2017 -0400 ; * lisp/emacs-lisp/package.el (describe-package-1): Tweak recent. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 85acf60d08..769856262b 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2355,12 +2355,11 @@ Otherwise no newline is inserted." (insert "\n"))) (when homepage ;; Prefer https for the homepage of packages on gnu.org. - (let ((gnu (cdr (assoc "gnu" package-archives)))) - (and gnu - (string-match-p "^https" gnu) - (string-match-p "^http://\\(elpa\\|www\\)\\.gnu\\.org/" homepage) - (setq homepage - (replace-regexp-in-string "^http" "https" homepage)))) + (if (string-match-p "^http://\\(elpa\\|www\\)\\.gnu\\.org/" homepage) + (let ((gnu (cdr (assoc "gnu" package-archives)))) + (and gnu (string-match-p "^https" gnu) + (setq homepage + (replace-regexp-in-string "^http" "https" homepage))))) (package--print-help-section "Homepage") (help-insert-xref-button homepage 'help-url homepage) (insert "\n")) commit fe8cf45710af7d09c830a23d40f234cae795ffbe Author: Glenn Morris Date: Tue Apr 4 20:17:54 2017 -0400 * doc/lispref/package.texi (Package Archives): Mention https. diff --git a/doc/lispref/package.texi b/doc/lispref/package.texi index 6066ea9a93..1b37337c15 100644 --- a/doc/lispref/package.texi +++ b/doc/lispref/package.texi @@ -286,9 +286,9 @@ form @code{(@var{id} . @var{location})}, where @var{id} is the name of the archive (a string) and @var{location} is its @dfn{base location} (a string). -If the base location starts with @samp{http:}, it is treated as a HTTP -URL, and packages are downloaded from this archive via HTTP (as is the -case for the default GNU archive). +If the base location starts with @samp{http:} or @samp{https:}, it +is treated as an HTTP(S) URL, and packages are downloaded from this +archive via HTTP(S) (as is the case for the default GNU archive). Otherwise, the base location should be a directory name. In this case, Emacs retrieves packages from this archive via ordinary file commit f981c611e26e906a88ee52806c78e07bbaa2b14b Author: Glenn Morris Date: Tue Apr 4 19:39:57 2017 -0400 Advertise https for homepage of gnu.org packages * lisp/emacs-lisp/package.el (describe-package-1): Use https, if supported, for the homepage of packages on gnu.org. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index fadd869c9d..85acf60d08 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2354,6 +2354,13 @@ Otherwise no newline is inserted." (package-desc-name pkg)))) (insert "\n"))) (when homepage + ;; Prefer https for the homepage of packages on gnu.org. + (let ((gnu (cdr (assoc "gnu" package-archives)))) + (and gnu + (string-match-p "^https" gnu) + (string-match-p "^http://\\(elpa\\|www\\)\\.gnu\\.org/" homepage) + (setq homepage + (replace-regexp-in-string "^http" "https" homepage)))) (package--print-help-section "Homepage") (help-insert-xref-button homepage 'help-url homepage) (insert "\n")) commit 048133d4886d2e7fa547879478127edc9a9243f6 Author: Glenn Morris Date: Tue Apr 4 19:04:52 2017 -0400 Default to https for elpa.gnu.org if gnutls available * lisp/emacs-lisp/package.el (package-archives): Default to https for elpa.gnu.org if gnutls is available. Ref: http://lists.gnu.org/archive/html/emacs-devel/2015-05/msg00130.html diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 8d5fac96cf..fadd869c9d 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -194,14 +194,16 @@ If VERSION is nil, the package is not loaded (it is \"disabled\")." :risky t :version "24.1") -(defcustom package-archives '(("gnu" . "http://elpa.gnu.org/packages/")) +(defcustom package-archives `(("gnu" . + ,(format "http%s://elpa.gnu.org/packages/" + (if (gnutls-available-p) "s" "")))) "An alist of archives from which to fetch. The default value points to the GNU Emacs package repository. Each element has the form (ID . LOCATION). ID is an archive name, as a string. LOCATION specifies the base location for the archive. - If it starts with \"http:\", it is treated as a HTTP URL; + If it starts with \"http(s):\", it is treated as an HTTP(S) URL; otherwise it should be an absolute directory name. (Other types of URL are currently not supported.) @@ -210,7 +212,7 @@ a package can run arbitrary code." :type '(alist :key-type (string :tag "Archive name") :value-type (string :tag "URL or directory name")) :risky t - :version "24.1") + :version "26.1") ; gnutls test (defcustom package-menu-hide-low-priority 'archive "If non-nil, hide low priority packages from the packages menu. commit 82b9efc869dddcbd5677867b84b20ae155b5b9da Author: Paul Eggert Date: Tue Apr 4 14:06:25 2017 -0700 Minor simplifications and doc for records * doc/lispref/records.texi (Records): Mention size limit. * etc/NEWS: Mention records. * src/alloc.c (allocate_pseudovector, allocate_record): Prefer 'PSEUDOVECTOR_SIZE_MASK' to its definiens. (allocate_record): Check arg range here, not in callers, as this simplifies the code. Use allocate_vectorlike instead of allocate_vector, to avoid duplicate runtime tests. (Fmake_record, record): Don't mention PSEUDOVECTOR_SIZE_BITS in the doc string, as it is not visible to the user. (Fmake_record, record, Fcopy_record): Prefer make_lisp_ptr to XSETVECTOR. (record): Broaden memcpy to copy the type, too. diff --git a/doc/lispref/records.texi b/doc/lispref/records.texi index 9a5d900cfc..a6c560cbcb 100644 --- a/doc/lispref/records.texi +++ b/doc/lispref/records.texi @@ -14,8 +14,10 @@ instances. Internally, a record object is much like a vector; its slots can be accessed using @code{aref}. However, the first slot is used to hold -its type as returned by @code{type-of}. Like arrays, records use -zero-origin indexing: the first slot has index 0. +its type as returned by @code{type-of}. Also, in the current +implementation records can have at most 4096 slots, whereas vectors +can be much larger. Like arrays, records use zero-origin indexing: +the first slot has index 0. The printed representation of records is @samp{#s} followed by a list specifying the contents. The first list element must be the diff --git a/etc/NEWS b/etc/NEWS index fc07656986..8b17f1648b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -840,6 +840,12 @@ instead of its first. * Lisp Changes in Emacs 26.1 +++ +** Emacs now supports records for user-defined types, via the new +functions 'copy-record', 'make-record', 'record', and 'recordp'. +Records are now used internally to represent cl-defstruct and defclass +instances, for example. + ++++ ** 'save-some-buffers' now uses 'save-some-buffers-default-predicate' to decide which buffers to ask about, if the PRED argument is nil. The default value of 'save-some-buffers-default-predicate' is nil, diff --git a/src/alloc.c b/src/alloc.c index 5024b1211e..a58824fb0f 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3371,7 +3371,7 @@ allocate_pseudovector (int memlen, int lisplen, eassert (0 <= tag && tag <= PVEC_FONT); eassert (0 <= lisplen && lisplen <= zerolen && zerolen <= memlen); eassert (memlen - lisplen <= (1 << PSEUDOVECTOR_REST_BITS) - 1); - eassert (lisplen <= (1 << PSEUDOVECTOR_SIZE_BITS) - 1); + eassert (lisplen <= PSEUDOVECTOR_SIZE_MASK); /* Only the first LISPLEN slots will be traced normally by the GC. */ memclear (v->contents, zerolen * word_size); @@ -3393,16 +3393,17 @@ allocate_buffer (void) } -/* Allocate a new record with COUNT slots. Return NULL if COUNT is - too large. */ +/* Allocate a record with COUNT slots. COUNT must be positive, and + includes the type slot. */ static struct Lisp_Vector * -allocate_record (int count) +allocate_record (EMACS_INT count) { - if (count >= (1 << PSEUDOVECTOR_SIZE_BITS)) - return NULL; - - struct Lisp_Vector *p = allocate_vector (count); + if (count > PSEUDOVECTOR_SIZE_MASK) + error ("Attempt to allocate a record of %"pI"d slots; max is %d", + count, PSEUDOVECTOR_SIZE_MASK); + struct Lisp_Vector *p = allocate_vectorlike (count); + p->header.size = count; XSETPVECTYPE (p, PVEC_RECORD); return p; } @@ -3411,53 +3412,29 @@ allocate_record (int count) DEFUN ("make-record", Fmake_record, Smake_record, 3, 3, 0, doc: /* Create a new record. TYPE is its type as returned by `type-of'. SLOTS is the number of -slots, each initialized to INIT. The number of slots, including the -type slot, must fit in PSEUDOVECTOR_SIZE_BITS. */) +non-type slots, each initialized to INIT. */) (Lisp_Object type, Lisp_Object slots, Lisp_Object init) { - Lisp_Object record; - ptrdiff_t size, i; - struct Lisp_Vector *p; - CHECK_NATNUM (slots); - - size = XFASTINT (slots) + 1; - p = allocate_record (size); - if (p == NULL) - error ("Attempt to allocate a record of %"pD"d slots; max is %d", - size, (1 << PSEUDOVECTOR_SIZE_BITS) - 1); - + EMACS_INT size = XFASTINT (slots) + 1; + struct Lisp_Vector *p = allocate_record (size); p->contents[0] = type; - for (i = 1; i < size; i++) + for (ptrdiff_t i = 1; i < size; i++) p->contents[i] = init; - - XSETVECTOR (record, p); - return record; + return make_lisp_ptr (p, Lisp_Vectorlike); } DEFUN ("record", Frecord, Srecord, 1, MANY, 0, doc: /* Create a new record. TYPE is its type as returned by `type-of'. SLOTS is used to -initialize the record slots with shallow copies of the arguments. The -number of slots, including the type slot, must fit in -PSEUDOVECTOR_SIZE_BITS. +initialize the record slots with shallow copies of the arguments. usage: (record TYPE &rest SLOTS) */) (ptrdiff_t nargs, Lisp_Object *args) { struct Lisp_Vector *p = allocate_record (nargs); - if (p == NULL) - error ("Attempt to allocate a record of %"pD"d slots; max is %d", - nargs, (1 << PSEUDOVECTOR_SIZE_BITS) - 1); - - Lisp_Object type = args[0]; - Lisp_Object record; - - p->contents[0] = type; - memcpy (p->contents + 1, args + 1, (nargs - 1) * sizeof *args); - - XSETVECTOR (record, p); - return record; + memcpy (p->contents, args, nargs * sizeof *args); + return make_lisp_ptr (p, Lisp_Vectorlike); } @@ -3466,17 +3443,11 @@ DEFUN ("copy-record", Fcopy_record, Scopy_record, 1, 1, 0, (Lisp_Object record) { CHECK_RECORD (record); - struct Lisp_Vector *src = XVECTOR (record); ptrdiff_t size = ASIZE (record) & PSEUDOVECTOR_SIZE_MASK; struct Lisp_Vector *new = allocate_record (size); - if (new == NULL) - error ("Attempt to allocate a record of %"pD"d slots; max is %d", - size, (1 << PSEUDOVECTOR_SIZE_BITS) - 1); - - memcpy (&(new->contents[0]), &(src->contents[0]), + memcpy (new->contents, XVECTOR (record)->contents, size * sizeof (Lisp_Object)); - XSETVECTOR (record, new); - return record; + return make_lisp_ptr (new, Lisp_Vectorlike); } commit 12317ff4fb53f889a69a858a629df6beffacd051 Author: Eli Zaretskii Date: Tue Apr 4 17:56:10 2017 +0300 Fix recent changes in record data type * src/alloc.c (Fmake_record, Frecord, Fcopy_record): Avoid compiler warnings when 'ptrdiff_t' is narrower than 'long int'. diff --git a/src/alloc.c b/src/alloc.c index fe631f2e4d..5024b1211e 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3424,7 +3424,7 @@ type slot, must fit in PSEUDOVECTOR_SIZE_BITS. */) size = XFASTINT (slots) + 1; p = allocate_record (size); if (p == NULL) - error ("Attempt to allocate a record of %ld slots; max is %d", + error ("Attempt to allocate a record of %"pD"d slots; max is %d", size, (1 << PSEUDOVECTOR_SIZE_BITS) - 1); p->contents[0] = type; @@ -3447,7 +3447,7 @@ usage: (record TYPE &rest SLOTS) */) { struct Lisp_Vector *p = allocate_record (nargs); if (p == NULL) - error ("Attempt to allocate a record of %ld slots; max is %d", + error ("Attempt to allocate a record of %"pD"d slots; max is %d", nargs, (1 << PSEUDOVECTOR_SIZE_BITS) - 1); Lisp_Object type = args[0]; @@ -3470,7 +3470,7 @@ DEFUN ("copy-record", Fcopy_record, Scopy_record, 1, 1, 0, ptrdiff_t size = ASIZE (record) & PSEUDOVECTOR_SIZE_MASK; struct Lisp_Vector *new = allocate_record (size); if (new == NULL) - error ("Attempt to allocate a record of %ld slots; max is %d", + error ("Attempt to allocate a record of %"pD"d slots; max is %d", size, (1 << PSEUDOVECTOR_SIZE_BITS) - 1); memcpy (&(new->contents[0]), &(src->contents[0]), commit 604eb02fff061e663e7523f45a72ecb71c2061e1 Author: Philipp Stephani Date: Fri Mar 3 17:56:01 2017 +0100 Make subprocess functions resolve the default directory `call-process' doesn't respect file name handlers in `default-directory', so `file-name-non-special' has to resolve them for `process-file', `start-file-process', and `shell-command' (Bug#25949). * lisp/files.el (file-name-non-special): Also resolve default directory for 'process-file', 'start-file-process', and 'shell-command'. * test/lisp/files-tests.el (files-tests--file-name-non-special--subprocess): Add unit test. diff --git a/lisp/files.el b/lisp/files.el index b4872e46b0..204c26416a 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6915,7 +6915,15 @@ only these files will be asked to be saved." (defun file-name-non-special (operation &rest arguments) (let ((file-name-handler-alist nil) (default-directory - (if (eq operation 'insert-directory) + ;; Some operations respect file name handlers in + ;; `default-directory'. Because core function like + ;; `call-process' don't care about file name handlers in + ;; `default-directory', we here have to resolve the + ;; directory into a local one. For `process-file', + ;; `start-file-process', and `shell-command', this fixes + ;; Bug#25949. + (if (memq operation '(insert-directory process-file start-file-process + shell-command)) (directory-file-name (expand-file-name (unhandled-file-name-directory default-directory))) diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 9d456c512b..80bbeb1bc5 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -243,5 +243,13 @@ be $HOME." (concat "/:/:" subdir))))) (delete-directory dir 'recursive)))) +(ert-deftest files-tests--file-name-non-special--subprocess () + "Check that Bug#25949 is fixed." + (skip-unless (executable-find "true")) + (should (eq (let ((default-directory "/:/")) (process-file "true")) 0)) + (should (processp (let ((default-directory "/:/")) + (start-file-process "foo" nil "true")))) + (should (eq (let ((default-directory "/:/")) (shell-command "true")) 0))) + (provide 'files-tests) ;;; files-tests.el ends here commit f4b50dad8d5eade04f495c693c0bca46060b25cb Author: Philipp Stephani Date: Fri Mar 3 18:36:08 2017 +0100 Make ediff handle remote and quoted file names Quoted file names need to be unquoted before passed to subprocesses (Bug#25950). * lisp/vc/ediff-diff.el (ediff-exec-process): Handle remote and quoted file names. * test/lisp/vc/ediff-diff-tests.el (ediff-diff-tests--ediff-exec-process--quoted-file): Add unit test. diff --git a/lisp/vc/ediff-diff.el b/lisp/vc/ediff-diff.el index 37f22340d7..cfa08ef360 100644 --- a/lisp/vc/ediff-diff.el +++ b/lisp/vc/ediff-diff.el @@ -1149,7 +1149,11 @@ delimiter regions")) ediff-coding-system-for-write ediff-coding-system-for-read)) args) - (setq args (append (split-string options) files)) + (setq args (append (split-string options) + (mapcar (lambda (file) + (file-name-unquote + (or (file-local-copy file) file))) + files))) (setq args (delete "" (delq nil args))) ; delete nil and "" from arguments ;; the --binary option, if present, should be used only for buffer jobs ;; or for refining the differences diff --git a/test/lisp/vc/ediff-diff-tests.el b/test/lisp/vc/ediff-diff-tests.el new file mode 100644 index 0000000000..aacc8bfed2 --- /dev/null +++ b/test/lisp/vc/ediff-diff-tests.el @@ -0,0 +1,44 @@ +;;; ediff-diff-tests.el --- Unit tests for ediff-diff.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2017 Free Software Foundation, Inc. + +;; Author: Philipp Stephani + +;; 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: + +;; Unit tests for lisp/vc/ediff-diff.el. + +;;; Code: + +(require 'ediff-diff) + +(require 'cl-lib) +(require 'ert) + +(ert-deftest ediff-diff-tests--ediff-exec-process--quoted-file () + "Check that Bug#25950 is fixed." + (cl-letf* ((call-process-args ()) + ((symbol-function #'call-process) + (lambda (&rest args) (push args call-process-args) 0))) + (with-temp-buffer + (ediff-exec-process "diff" (current-buffer) :synchronous "" + "/:/a" "/:/b") + (should (equal call-process-args + `(("diff" nil ,(current-buffer) nil "/a" "/b"))))))) + +;;; ediff-diff-tests.el ends here