diff options
| author | Noam Postavsky | 2018-07-09 20:06:27 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2018-07-09 20:06:27 -0400 |
| commit | 6b8349a90274686d9cb67a2ffaac2d930d5f6b46 (patch) | |
| tree | d2fbc56f7a21120951cb0c14bbe349e388b35e62 | |
| parent | 6de90fb41b63d33457c1fa41cbb4bd8b25e4cc7f (diff) | |
| parent | db3f7797809ed9de8dd92ce38bf34f768ddc64ad (diff) | |
| download | emacs-6b8349a90274686d9cb67a2ffaac2d930d5f6b46.tar.gz emacs-6b8349a90274686d9cb67a2ffaac2d930d5f6b46.zip | |
Merge from emacs-26
db3f779780 ; Test for Bug#32014
90d95b000c Explicitly reject :server and :nowait (Bug#31903)
917158f8c9 Fix Bug#32090
# Conflicts:
# src/process.c
| -rw-r--r-- | lisp/files-x.el | 37 | ||||
| -rw-r--r-- | src/process.c | 26 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/lisp-mode-tests.el | 11 | ||||
| -rw-r--r-- | test/lisp/files-x-tests.el | 55 |
4 files changed, 76 insertions, 53 deletions
diff --git a/lisp/files-x.el b/lisp/files-x.el index 74ea77678ec..2a52792222d 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el | |||
| @@ -578,31 +578,33 @@ strings. All properties are optional; if CRITERIA is nil, it | |||
| 578 | always applies. | 578 | always applies. |
| 579 | PROFILES is a list of connection profiles (symbols).") | 579 | PROFILES is a list of connection profiles (symbols).") |
| 580 | 580 | ||
| 581 | (defsubst connection-local-normalize-criteria (criteria &rest properties) | 581 | (defsubst connection-local-normalize-criteria (criteria) |
| 582 | "Normalize plist CRITERIA according to PROPERTIES. | 582 | "Normalize plist CRITERIA according to properties. |
| 583 | Return a new ordered plist list containing only property names from PROPERTIES." | 583 | Return a reordered plist." |
| 584 | (delq | 584 | (apply |
| 585 | nil | 585 | 'append |
| 586 | (mapcar | 586 | (mapcar |
| 587 | (lambda (property) | 587 | (lambda (property) |
| 588 | (when (and (plist-member criteria property) (plist-get criteria property)) | 588 | (when (and (plist-member criteria property) (plist-get criteria property)) |
| 589 | (list property (plist-get criteria property)))) | 589 | (list property (plist-get criteria property)))) |
| 590 | properties))) | 590 | '(:application :protocol :user :machine)))) |
| 591 | 591 | ||
| 592 | (defsubst connection-local-get-profiles (criteria) | 592 | (defsubst connection-local-get-profiles (criteria) |
| 593 | "Return the connection profiles list for CRITERIA. | 593 | "Return the connection profiles list for CRITERIA. |
| 594 | CRITERIA is a plist identifying a connection and the application | 594 | CRITERIA is a plist identifying a connection and the application |
| 595 | using this connection, see `connection-local-criteria-alist'." | 595 | using this connection, see `connection-local-criteria-alist'." |
| 596 | (or (cdr | 596 | (let (profiles) |
| 597 | (assoc | 597 | (dolist (crit-alist connection-local-criteria-alist) |
| 598 | (connection-local-normalize-criteria | 598 | (let ((crit criteria) |
| 599 | criteria :application :protocol :user :machine) | 599 | (match t)) |
| 600 | connection-local-criteria-alist)) | 600 | (while (and crit match) |
| 601 | ;; Try it without :application. | 601 | (when (plist-member (car crit-alist) (car crit)) |
| 602 | (cdr | 602 | (setq match (equal (plist-get (car crit-alist) (car crit)) |
| 603 | (assoc | 603 | (plist-get criteria (car crit))))) |
| 604 | (connection-local-normalize-criteria criteria :protocol :user :machine) | 604 | (setq crit (cddr crit))) |
| 605 | connection-local-criteria-alist)))) | 605 | (when match |
| 606 | (setq profiles (append profiles (cdr crit-alist)))))) | ||
| 607 | (delete-dups profiles))) | ||
| 606 | 608 | ||
| 607 | ;;;###autoload | 609 | ;;;###autoload |
| 608 | (defun connection-local-set-profiles (criteria &rest profiles) | 610 | (defun connection-local-set-profiles (criteria &rest profiles) |
| @@ -621,8 +623,7 @@ variables for a connection profile are defined using | |||
| 621 | (dolist (profile profiles) | 623 | (dolist (profile profiles) |
| 622 | (unless (assq profile connection-local-profile-alist) | 624 | (unless (assq profile connection-local-profile-alist) |
| 623 | (error "No such connection profile `%s'" (symbol-name profile)))) | 625 | (error "No such connection profile `%s'" (symbol-name profile)))) |
| 624 | (let* ((criteria (connection-local-normalize-criteria | 626 | (let* ((criteria (connection-local-normalize-criteria criteria)) |
| 625 | criteria :application :protocol :user :machine)) | ||
| 626 | (slot (assoc criteria connection-local-criteria-alist))) | 627 | (slot (assoc criteria connection-local-criteria-alist))) |
| 627 | (if slot | 628 | (if slot |
| 628 | (setcdr slot (delete-dups (append (cdr slot) profiles))) | 629 | (setcdr slot (delete-dups (append (cdr slot) profiles))) |
diff --git a/src/process.c b/src/process.c index 279b74bc66e..5bd8c255a26 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -3897,12 +3897,15 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3897 | filter = Fplist_get (contact, QCfilter); | 3897 | filter = Fplist_get (contact, QCfilter); |
| 3898 | sentinel = Fplist_get (contact, QCsentinel); | 3898 | sentinel = Fplist_get (contact, QCsentinel); |
| 3899 | use_external_socket_p = Fplist_get (contact, QCuse_external_socket); | 3899 | use_external_socket_p = Fplist_get (contact, QCuse_external_socket); |
| 3900 | Lisp_Object server = Fplist_get (contact, QCserver); | ||
| 3901 | bool nowait = !NILP (Fplist_get (contact, QCnowait)); | ||
| 3900 | 3902 | ||
| 3903 | if (!NILP (server) && nowait) | ||
| 3904 | error ("`:server' is incompatible with `:nowait'"); | ||
| 3901 | CHECK_STRING (name); | 3905 | CHECK_STRING (name); |
| 3902 | 3906 | ||
| 3903 | /* :local ADDRESS or :remote ADDRESS */ | 3907 | /* :local ADDRESS or :remote ADDRESS */ |
| 3904 | tem = Fplist_get (contact, QCserver); | 3908 | if (!NILP (server)) |
| 3905 | if (NILP (tem)) | ||
| 3906 | address = Fplist_get (contact, QCremote); | 3909 | address = Fplist_get (contact, QCremote); |
| 3907 | else | 3910 | else |
| 3908 | address = Fplist_get (contact, QClocal); | 3911 | address = Fplist_get (contact, QClocal); |
| @@ -4017,7 +4020,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 4017 | } | 4020 | } |
| 4018 | 4021 | ||
| 4019 | #ifdef HAVE_GETADDRINFO_A | 4022 | #ifdef HAVE_GETADDRINFO_A |
| 4020 | if (!NILP (Fplist_get (contact, QCnowait))) | 4023 | if (nowait) |
| 4021 | { | 4024 | { |
| 4022 | ptrdiff_t hostlen = SBYTES (host); | 4025 | ptrdiff_t hostlen = SBYTES (host); |
| 4023 | struct req | 4026 | struct req |
| @@ -4164,20 +4167,13 @@ usage: (make-network-process &rest ARGS) */) | |||
| 4164 | 4167 | ||
| 4165 | set_network_socket_coding_system (proc, host, service, name); | 4168 | set_network_socket_coding_system (proc, host, service, name); |
| 4166 | 4169 | ||
| 4167 | /* :server BOOL */ | 4170 | /* :server QLEN */ |
| 4168 | tem = Fplist_get (contact, QCserver); | 4171 | p->is_server = !NILP (server); |
| 4169 | if (!NILP (tem)) | 4172 | if (TYPE_RANGED_INTEGERP (int, server)) |
| 4170 | { | 4173 | p->backlog = XINT (server); |
| 4171 | /* Don't support network sockets when non-blocking mode is | ||
| 4172 | not available, since a blocked Emacs is not useful. */ | ||
| 4173 | p->is_server = true; | ||
| 4174 | if (TYPE_RANGED_INTEGERP (int, tem)) | ||
| 4175 | p->backlog = XINT (tem); | ||
| 4176 | } | ||
| 4177 | 4174 | ||
| 4178 | /* :nowait BOOL */ | 4175 | /* :nowait BOOL */ |
| 4179 | if (!p->is_server && socktype != SOCK_DGRAM | 4176 | if (!p->is_server && socktype != SOCK_DGRAM && nowait) |
| 4180 | && !NILP (Fplist_get (contact, QCnowait))) | ||
| 4181 | p->is_non_blocking_client = true; | 4177 | p->is_non_blocking_client = true; |
| 4182 | 4178 | ||
| 4183 | bool postpone_connection = false; | 4179 | bool postpone_connection = false; |
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el index 0b5b0a40198..2ac0e5ce1d4 100644 --- a/test/lisp/emacs-lisp/lisp-mode-tests.el +++ b/test/lisp/emacs-lisp/lisp-mode-tests.el | |||
| @@ -224,6 +224,17 @@ Expected initialization file: `%s'\" | |||
| 224 | (comment-indent) | 224 | (comment-indent) |
| 225 | (should (equal (buffer-string) correct))))) | 225 | (should (equal (buffer-string) correct))))) |
| 226 | 226 | ||
| 227 | (ert-deftest lisp-indent-with-read-only-field () | ||
| 228 | "Test indentation on line with read-only field (Bug#32014)." | ||
| 229 | :expected-result :failed | ||
| 230 | (with-temp-buffer | ||
| 231 | (insert (propertize "prompt> " 'field 'output 'read-only t | ||
| 232 | 'rear-nonsticky t 'front-sticky '(read-only))) | ||
| 233 | (insert " foo") | ||
| 234 | (lisp-indent-line) | ||
| 235 | (should (equal (buffer-string) "prompt> foo")))) | ||
| 236 | |||
| 237 | |||
| 227 | 238 | ||
| 228 | (provide 'lisp-mode-tests) | 239 | (provide 'lisp-mode-tests) |
| 229 | ;;; lisp-mode-tests.el ends here | 240 | ;;; lisp-mode-tests.el ends here |
diff --git a/test/lisp/files-x-tests.el b/test/lisp/files-x-tests.el index 7bd69bda016..a77c6815fcd 100644 --- a/test/lisp/files-x-tests.el +++ b/test/lisp/files-x-tests.el | |||
| @@ -101,15 +101,19 @@ | |||
| 101 | (setq files-x-test--criteria | 101 | (setq files-x-test--criteria |
| 102 | (append files-x-test--application files-x-test--protocol | 102 | (append files-x-test--application files-x-test--protocol |
| 103 | files-x-test--user files-x-test--machine)) | 103 | files-x-test--user files-x-test--machine)) |
| 104 | |||
| 104 | ;; An empty variable list is accepted (but makes no sense). | 105 | ;; An empty variable list is accepted (but makes no sense). |
| 105 | (connection-local-set-profiles files-x-test--criteria) | 106 | (connection-local-set-profiles files-x-test--criteria) |
| 106 | (should-not (connection-local-get-profiles files-x-test--criteria)) | 107 | (should-not (connection-local-get-profiles files-x-test--criteria)) |
| 108 | |||
| 109 | ;; First test, all declared properties. | ||
| 107 | (connection-local-set-profiles | 110 | (connection-local-set-profiles |
| 108 | files-x-test--criteria 'remote-bash 'remote-ksh) | 111 | files-x-test--criteria 'remote-bash 'remote-ksh) |
| 109 | (should | 112 | (should |
| 110 | (equal | 113 | (equal |
| 111 | (connection-local-get-profiles files-x-test--criteria) | 114 | (connection-local-get-profiles files-x-test--criteria) |
| 112 | '(remote-bash remote-ksh))) | 115 | '(remote-bash remote-ksh))) |
| 116 | |||
| 113 | ;; Changing the order of properties doesn't matter. | 117 | ;; Changing the order of properties doesn't matter. |
| 114 | (setq files-x-test--criteria | 118 | (setq files-x-test--criteria |
| 115 | (append files-x-test--protocol files-x-test--application | 119 | (append files-x-test--protocol files-x-test--application |
| @@ -118,12 +122,14 @@ | |||
| 118 | (equal | 122 | (equal |
| 119 | (connection-local-get-profiles files-x-test--criteria) | 123 | (connection-local-get-profiles files-x-test--criteria) |
| 120 | '(remote-bash remote-ksh))) | 124 | '(remote-bash remote-ksh))) |
| 121 | ;; A further call adds profiles. | 125 | |
| 126 | ;; A further call adds profiles. | ||
| 122 | (connection-local-set-profiles files-x-test--criteria 'remote-nullfile) | 127 | (connection-local-set-profiles files-x-test--criteria 'remote-nullfile) |
| 123 | (should | 128 | (should |
| 124 | (equal | 129 | (equal |
| 125 | (connection-local-get-profiles files-x-test--criteria) | 130 | (connection-local-get-profiles files-x-test--criteria) |
| 126 | '(remote-bash remote-ksh remote-nullfile))) | 131 | '(remote-bash remote-ksh remote-nullfile))) |
| 132 | |||
| 127 | ;; Adding existing profiles doesn't matter. | 133 | ;; Adding existing profiles doesn't matter. |
| 128 | (connection-local-set-profiles | 134 | (connection-local-set-profiles |
| 129 | files-x-test--criteria 'remote-bash 'remote-nullfile) | 135 | files-x-test--criteria 'remote-bash 'remote-nullfile) |
| @@ -132,31 +138,38 @@ | |||
| 132 | (connection-local-get-profiles files-x-test--criteria) | 138 | (connection-local-get-profiles files-x-test--criteria) |
| 133 | '(remote-bash remote-ksh remote-nullfile))) | 139 | '(remote-bash remote-ksh remote-nullfile))) |
| 134 | 140 | ||
| 135 | ;; Use a criteria without application. | 141 | ;; Use different properties. |
| 136 | (setq files-x-test--criteria | 142 | (dolist (criteria |
| 137 | (append files-x-test--protocol | 143 | `(;; All properties. |
| 138 | files-x-test--user files-x-test--machine)) | 144 | ,(append files-x-test--application files-x-test--protocol |
| 139 | (connection-local-set-profiles files-x-test--criteria 'remote-ksh) | 145 | files-x-test--user files-x-test--machine) |
| 140 | (should | 146 | ;; Without :application. |
| 141 | (equal | 147 | ,(append files-x-test--protocol |
| 142 | (connection-local-get-profiles files-x-test--criteria) | 148 | files-x-test--user files-x-test--machine) |
| 143 | '(remote-ksh))) | 149 | ;; Without :protocol. |
| 144 | ;; An application not used in any registered criteria matches also this. | 150 | ,(append files-x-test--application |
| 145 | (setq files-x-test--criteria | 151 | files-x-test--user files-x-test--machine) |
| 146 | (append files-x-test--another-application files-x-test--protocol | 152 | ;; Without :user. |
| 147 | files-x-test--user files-x-test--machine)) | 153 | ,(append files-x-test--application files-x-test--protocol |
| 148 | (should | 154 | files-x-test--machine) |
| 149 | (equal | 155 | ;; Without :machine. |
| 150 | (connection-local-get-profiles files-x-test--criteria) | 156 | ,(append files-x-test--application files-x-test--protocol |
| 151 | '(remote-ksh))) | 157 | files-x-test--user) |
| 158 | ;; No property at all. | ||
| 159 | nil)) | ||
| 160 | (should | ||
| 161 | (equal | ||
| 162 | (connection-local-get-profiles criteria) | ||
| 163 | '(remote-bash remote-ksh remote-nullfile)))) | ||
| 152 | 164 | ||
| 153 | ;; Using a nil criteria also works. Duplicate profiles are trashed. | 165 | ;; Using a nil criteria also works. Duplicate profiles are trashed. |
| 154 | (connection-local-set-profiles | 166 | (connection-local-set-profiles |
| 155 | nil 'remote-bash 'remote-ksh 'remote-ksh 'remote-bash) | 167 | nil 'remote-bash 'remote-ksh 'remote-ksh 'remote-bash) |
| 168 | ;; This matches also the existing profiles from other criteria. | ||
| 156 | (should | 169 | (should |
| 157 | (equal | 170 | (equal |
| 158 | (connection-local-get-profiles nil) | 171 | (connection-local-get-profiles nil) |
| 159 | '(remote-bash remote-ksh))) | 172 | '(remote-bash remote-ksh remote-nullfile))) |
| 160 | 173 | ||
| 161 | ;; A criteria other than plist is wrong. | 174 | ;; A criteria other than plist is wrong. |
| 162 | (should-error (connection-local-set-profiles 'dummy)))) | 175 | (should-error (connection-local-set-profiles 'dummy)))) |
| @@ -235,7 +248,9 @@ | |||
| 235 | ;; declare same variables as in `remote-bash'. | 248 | ;; declare same variables as in `remote-bash'. |
| 236 | (should | 249 | (should |
| 237 | (equal connection-local-variables-alist | 250 | (equal connection-local-variables-alist |
| 238 | (nreverse (copy-tree files-x-test--variables1)))) | 251 | (append |
| 252 | (nreverse (copy-tree files-x-test--variables3)) | ||
| 253 | (nreverse (copy-tree files-x-test--variables1))))) | ||
| 239 | ;; The variables exist also as local variables. | 254 | ;; The variables exist also as local variables. |
| 240 | (should (local-variable-p 'remote-shell-file-name)) | 255 | (should (local-variable-p 'remote-shell-file-name)) |
| 241 | ;; The proper variable value is set. | 256 | ;; The proper variable value is set. |