aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2022-03-19 17:19:19 +0200
committerEli Zaretskii2022-03-19 17:19:19 +0200
commit6887bf555f12e2059f237862159e19deddf596e1 (patch)
tree465582b2ac45db1de297a6a80fa13b7bc2f9ea16
parent9c68894399e928220192fd44efbd71a1ca116028 (diff)
parent71b8f1fc635d9bbe00ca89457065e0c83456ac43 (diff)
downloademacs-6887bf555f12e2059f237862159e19deddf596e1.tar.gz
emacs-6887bf555f12e2059f237862159e19deddf596e1.zip
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
-rw-r--r--lisp/emacs-lisp/comp.el12
-rw-r--r--lisp/erc/erc.el7
-rw-r--r--src/alloc.c1
-rw-r--r--src/comp.c16
-rw-r--r--src/data.c6
-rw-r--r--src/lisp.h1
-rw-r--r--src/pdumper.c4
-rw-r--r--src/xterm.c8
-rw-r--r--test/lisp/erc/erc-tests.el59
9 files changed, 100 insertions, 14 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 122638077ce..00efedd71f3 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -898,6 +898,8 @@ non local exit (ends with an `unreachable' insn)."))
898 :documentation "Doc string.") 898 :documentation "Doc string.")
899 (int-spec nil :type list 899 (int-spec nil :type list
900 :documentation "Interactive form.") 900 :documentation "Interactive form.")
901 (command-modes nil :type list
902 :documentation "Command modes.")
901 (lap () :type list 903 (lap () :type list
902 :documentation "LAP assembly representation.") 904 :documentation "LAP assembly representation.")
903 (ssa-status nil :type symbol 905 (ssa-status nil :type symbol
@@ -1243,6 +1245,7 @@ clashes."
1243 :c-name c-name 1245 :c-name c-name
1244 :doc (documentation f t) 1246 :doc (documentation f t)
1245 :int-spec (interactive-form f) 1247 :int-spec (interactive-form f)
1248 :command-modes (command-modes f)
1246 :speed (comp-spill-speed function-name) 1249 :speed (comp-spill-speed function-name)
1247 :pure (comp-spill-decl-spec function-name 1250 :pure (comp-spill-decl-spec function-name
1248 'pure)))) 1251 'pure))))
@@ -1282,10 +1285,12 @@ clashes."
1282 (make-comp-func-l :c-name c-name 1285 (make-comp-func-l :c-name c-name
1283 :doc (documentation form t) 1286 :doc (documentation form t)
1284 :int-spec (interactive-form form) 1287 :int-spec (interactive-form form)
1288 :command-modes (command-modes form)
1285 :speed (comp-ctxt-speed comp-ctxt)) 1289 :speed (comp-ctxt-speed comp-ctxt))
1286 (make-comp-func-d :c-name c-name 1290 (make-comp-func-d :c-name c-name
1287 :doc (documentation form t) 1291 :doc (documentation form t)
1288 :int-spec (interactive-form form) 1292 :int-spec (interactive-form form)
1293 :command-modes (command-modes form)
1289 :speed (comp-ctxt-speed comp-ctxt))))) 1294 :speed (comp-ctxt-speed comp-ctxt)))))
1290 (let ((lap (byte-to-native-lambda-lap 1295 (let ((lap (byte-to-native-lambda-lap
1291 (gethash (aref byte-code 1) 1296 (gethash (aref byte-code 1)
@@ -1327,6 +1332,7 @@ clashes."
1327 (comp-func-byte-func func) byte-func 1332 (comp-func-byte-func func) byte-func
1328 (comp-func-doc func) (documentation byte-func t) 1333 (comp-func-doc func) (documentation byte-func t)
1329 (comp-func-int-spec func) (interactive-form byte-func) 1334 (comp-func-int-spec func) (interactive-form byte-func)
1335 (comp-func-command-modes func) (command-modes byte-func)
1330 (comp-func-c-name func) c-name 1336 (comp-func-c-name func) c-name
1331 (comp-func-lap func) lap 1337 (comp-func-lap func) lap
1332 (comp-func-frame-size func) (comp-byte-frame-size byte-func) 1338 (comp-func-frame-size func) (comp-byte-frame-size byte-func)
@@ -2079,7 +2085,8 @@ and the annotation emission."
2079 (i (hash-table-count h))) 2085 (i (hash-table-count h)))
2080 (puthash i (comp-func-doc f) h) 2086 (puthash i (comp-func-doc f) h)
2081 i) 2087 i)
2082 (comp-func-int-spec f))) 2088 (comp-func-int-spec f)
2089 (comp-func-command-modes f)))
2083 ;; This is the compilation unit it-self passed as 2090 ;; This is the compilation unit it-self passed as
2084 ;; parameter. 2091 ;; parameter.
2085 (make-comp-mvar :slot 0)))))) 2092 (make-comp-mvar :slot 0))))))
@@ -2122,7 +2129,8 @@ These are stored in the reloc data array."
2122 (i (hash-table-count h))) 2129 (i (hash-table-count h)))
2123 (puthash i (comp-func-doc func) h) 2130 (puthash i (comp-func-doc func) h)
2124 i) 2131 i)
2125 (comp-func-int-spec func))) 2132 (comp-func-int-spec func)
2133 (comp-func-command-modes func)))
2126 ;; This is the compilation unit it-self passed as 2134 ;; This is the compilation unit it-self passed as
2127 ;; parameter. 2135 ;; parameter.
2128 (make-comp-mvar :slot 0))))) 2136 (make-comp-mvar :slot 0)))))
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 9ee8d38b026..52fe106f2d1 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1761,12 +1761,7 @@ nil."
1761 (lambda (bufname) 1761 (lambda (bufname)
1762 (let ((buf (if (consp bufname) 1762 (let ((buf (if (consp bufname)
1763 (cdr bufname) (get-buffer bufname)))) 1763 (cdr bufname) (get-buffer bufname))))
1764 (when buf 1764 (and buf (erc--buffer-p buf (lambda () t) proc)))))))
1765 (erc--buffer-p buf (lambda () t) proc)
1766 (with-current-buffer buf
1767 (and (derived-mode-p 'erc-mode)
1768 (or (null proc)
1769 (eq proc erc-server-process))))))))))
1770(defun erc-switch-to-buffer (&optional arg) 1765(defun erc-switch-to-buffer (&optional arg)
1771 "Prompt for an ERC buffer to switch to. 1766 "Prompt for an ERC buffer to switch to.
1772When invoked with prefix argument, use all ERC buffers. Without 1767When invoked with prefix argument, use all ERC buffers. Without
diff --git a/src/alloc.c b/src/alloc.c
index c19e3dabb6e..b0fbc91fe50 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6844,6 +6844,7 @@ mark_object (Lisp_Object arg)
6844 set_vector_marked (ptr); 6844 set_vector_marked (ptr);
6845 struct Lisp_Subr *subr = XSUBR (obj); 6845 struct Lisp_Subr *subr = XSUBR (obj);
6846 mark_object (subr->native_intspec); 6846 mark_object (subr->native_intspec);
6847 mark_object (subr->command_modes);
6847 mark_object (subr->native_comp_u); 6848 mark_object (subr->native_comp_u);
6848 mark_object (subr->lambda_list); 6849 mark_object (subr->lambda_list);
6849 mark_object (subr->type); 6850 mark_object (subr->type);
diff --git a/src/comp.c b/src/comp.c
index 6449eedb278..499eee7e709 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -5411,7 +5411,7 @@ native_function_doc (Lisp_Object function)
5411static Lisp_Object 5411static Lisp_Object
5412make_subr (Lisp_Object symbol_name, Lisp_Object minarg, Lisp_Object maxarg, 5412make_subr (Lisp_Object symbol_name, Lisp_Object minarg, Lisp_Object maxarg,
5413 Lisp_Object c_name, Lisp_Object type, Lisp_Object doc_idx, 5413 Lisp_Object c_name, Lisp_Object type, Lisp_Object doc_idx,
5414 Lisp_Object intspec, Lisp_Object comp_u) 5414 Lisp_Object intspec, Lisp_Object command_modes, Lisp_Object comp_u)
5415{ 5415{
5416 struct Lisp_Native_Comp_Unit *cu = XNATIVE_COMP_UNIT (comp_u); 5416 struct Lisp_Native_Comp_Unit *cu = XNATIVE_COMP_UNIT (comp_u);
5417 dynlib_handle_ptr handle = cu->handle; 5417 dynlib_handle_ptr handle = cu->handle;
@@ -5445,6 +5445,7 @@ make_subr (Lisp_Object symbol_name, Lisp_Object minarg, Lisp_Object maxarg,
5445 x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY; 5445 x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY;
5446 x->s.symbol_name = xstrdup (SSDATA (symbol_name)); 5446 x->s.symbol_name = xstrdup (SSDATA (symbol_name));
5447 x->s.native_intspec = intspec; 5447 x->s.native_intspec = intspec;
5448 x->s.command_modes = command_modes;
5448 x->s.doc = XFIXNUM (doc_idx); 5449 x->s.doc = XFIXNUM (doc_idx);
5449#ifdef HAVE_NATIVE_COMP 5450#ifdef HAVE_NATIVE_COMP
5450 x->s.native_comp_u = comp_u; 5451 x->s.native_comp_u = comp_u;
@@ -5467,12 +5468,17 @@ This gets called by top_level_run during the load phase. */)
5467{ 5468{
5468 Lisp_Object doc_idx = FIRST (rest); 5469 Lisp_Object doc_idx = FIRST (rest);
5469 Lisp_Object intspec = SECOND (rest); 5470 Lisp_Object intspec = SECOND (rest);
5471 Lisp_Object command_modes = Qnil;
5472 if (!NILP (XCDR (XCDR (rest))))
5473 command_modes = THIRD (rest);
5474
5470 struct Lisp_Native_Comp_Unit *cu = XNATIVE_COMP_UNIT (comp_u); 5475 struct Lisp_Native_Comp_Unit *cu = XNATIVE_COMP_UNIT (comp_u);
5471 if (cu->loaded_once) 5476 if (cu->loaded_once)
5472 return Qnil; 5477 return Qnil;
5473 5478
5474 Lisp_Object tem = 5479 Lisp_Object tem =
5475 make_subr (c_name, minarg, maxarg, c_name, type, doc_idx, intspec, comp_u); 5480 make_subr (c_name, minarg, maxarg, c_name, type, doc_idx, intspec,
5481 command_modes, comp_u);
5476 5482
5477 /* We must protect it against GC because the function is not 5483 /* We must protect it against GC because the function is not
5478 reachable through symbols. */ 5484 reachable through symbols. */
@@ -5497,9 +5503,13 @@ This gets called by top_level_run during the load phase. */)
5497{ 5503{
5498 Lisp_Object doc_idx = FIRST (rest); 5504 Lisp_Object doc_idx = FIRST (rest);
5499 Lisp_Object intspec = SECOND (rest); 5505 Lisp_Object intspec = SECOND (rest);
5506 Lisp_Object command_modes = Qnil;
5507 if (!NILP (XCDR (XCDR (rest))))
5508 command_modes = THIRD (rest);
5509
5500 Lisp_Object tem = 5510 Lisp_Object tem =
5501 make_subr (SYMBOL_NAME (name), minarg, maxarg, c_name, type, doc_idx, 5511 make_subr (SYMBOL_NAME (name), minarg, maxarg, c_name, type, doc_idx,
5502 intspec, comp_u); 5512 intspec, command_modes, comp_u);
5503 5513
5504 defalias (name, tem); 5514 defalias (name, tem);
5505 5515
diff --git a/src/data.c b/src/data.c
index 23b0e7c29d9..5894340aba3 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1167,7 +1167,11 @@ The value, if non-nil, is a list of mode name symbols. */)
1167 fun = Fsymbol_function (fun); 1167 fun = Fsymbol_function (fun);
1168 } 1168 }
1169 1169
1170 if (COMPILEDP (fun)) 1170 if (SUBRP (fun))
1171 {
1172 return XSUBR (fun)->command_modes;
1173 }
1174 else if (COMPILEDP (fun))
1171 { 1175 {
1172 if (PVSIZE (fun) <= COMPILED_INTERACTIVE) 1176 if (PVSIZE (fun) <= COMPILED_INTERACTIVE)
1173 return Qnil; 1177 return Qnil;
diff --git a/src/lisp.h b/src/lisp.h
index e4d156c0f45..b558d311a80 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2154,6 +2154,7 @@ struct Lisp_Subr
2154 const char *intspec; 2154 const char *intspec;
2155 Lisp_Object native_intspec; 2155 Lisp_Object native_intspec;
2156 }; 2156 };
2157 Lisp_Object command_modes;
2157 EMACS_INT doc; 2158 EMACS_INT doc;
2158#ifdef HAVE_NATIVE_COMP 2159#ifdef HAVE_NATIVE_COMP
2159 Lisp_Object native_comp_u; 2160 Lisp_Object native_comp_u;
diff --git a/src/pdumper.c b/src/pdumper.c
index f14239f863a..11831023622 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2854,7 +2854,7 @@ dump_bool_vector (struct dump_context *ctx, const struct Lisp_Vector *v)
2854static dump_off 2854static dump_off
2855dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr) 2855dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr)
2856{ 2856{
2857#if CHECK_STRUCTS && !defined (HASH_Lisp_Subr_F09D8E8E19) 2857#if CHECK_STRUCTS && !defined (HASH_Lisp_Subr_A212A8F82A)
2858# error "Lisp_Subr changed. See CHECK_STRUCTS comment in config.h." 2858# error "Lisp_Subr changed. See CHECK_STRUCTS comment in config.h."
2859#endif 2859#endif
2860 struct Lisp_Subr out; 2860 struct Lisp_Subr out;
@@ -2878,11 +2878,13 @@ dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr)
2878 COLD_OP_NATIVE_SUBR, 2878 COLD_OP_NATIVE_SUBR,
2879 make_lisp_ptr ((void *) subr, Lisp_Vectorlike)); 2879 make_lisp_ptr ((void *) subr, Lisp_Vectorlike));
2880 dump_field_lv (ctx, &out, subr, &subr->native_intspec, WEIGHT_NORMAL); 2880 dump_field_lv (ctx, &out, subr, &subr->native_intspec, WEIGHT_NORMAL);
2881 dump_field_lv (ctx, &out, subr, &subr->command_modes, WEIGHT_NORMAL);
2881 } 2882 }
2882 else 2883 else
2883 { 2884 {
2884 dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name); 2885 dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name);
2885 dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec); 2886 dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec);
2887 dump_field_emacs_ptr (ctx, &out, subr, &subr->command_modes);
2886 } 2888 }
2887 DUMP_FIELD_COPY (&out, subr, doc); 2889 DUMP_FIELD_COPY (&out, subr, doc);
2888#ifdef HAVE_NATIVE_COMP 2890#ifdef HAVE_NATIVE_COMP
diff --git a/src/xterm.c b/src/xterm.c
index b820c102f1b..fb0fc66ae59 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1035,7 +1035,9 @@ x_dnd_send_enter (struct frame *f, Window target, int supported)
1035 PropModeReplace, (unsigned char *) x_dnd_targets, 1035 PropModeReplace, (unsigned char *) x_dnd_targets,
1036 x_dnd_n_targets); 1036 x_dnd_n_targets);
1037 1037
1038 x_catch_errors (dpyinfo->display);
1038 XSendEvent (FRAME_X_DISPLAY (f), target, False, 0, &msg); 1039 XSendEvent (FRAME_X_DISPLAY (f), target, False, 0, &msg);
1040 x_uncatch_errors ();
1039} 1041}
1040 1042
1041static void 1043static void
@@ -1075,7 +1077,9 @@ x_dnd_send_position (struct frame *f, Window target, int supported,
1075 if (supported >= 4) 1077 if (supported >= 4)
1076 msg.xclient.data.l[4] = action; 1078 msg.xclient.data.l[4] = action;
1077 1079
1080 x_catch_errors (dpyinfo->display);
1078 XSendEvent (FRAME_X_DISPLAY (f), target, False, 0, &msg); 1081 XSendEvent (FRAME_X_DISPLAY (f), target, False, 0, &msg);
1082 x_uncatch_errors ();
1079} 1083}
1080 1084
1081static void 1085static void
@@ -1094,7 +1098,9 @@ x_dnd_send_leave (struct frame *f, Window target)
1094 msg.xclient.data.l[3] = 0; 1098 msg.xclient.data.l[3] = 0;
1095 msg.xclient.data.l[4] = 0; 1099 msg.xclient.data.l[4] = 0;
1096 1100
1101 x_catch_errors (dpyinfo->display);
1097 XSendEvent (FRAME_X_DISPLAY (f), target, False, 0, &msg); 1102 XSendEvent (FRAME_X_DISPLAY (f), target, False, 0, &msg);
1103 x_uncatch_errors ();
1098} 1104}
1099 1105
1100static void 1106static void
@@ -1117,7 +1123,9 @@ x_dnd_send_drop (struct frame *f, Window target, Time timestamp,
1117 if (supported >= 1) 1123 if (supported >= 1)
1118 msg.xclient.data.l[2] = timestamp; 1124 msg.xclient.data.l[2] = timestamp;
1119 1125
1126 x_catch_errors (dpyinfo->display);
1120 XSendEvent (FRAME_X_DISPLAY (f), target, False, 0, &msg); 1127 XSendEvent (FRAME_X_DISPLAY (f), target, False, 0, &msg);
1128 x_uncatch_errors ();
1121} 1129}
1122 1130
1123void 1131void
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 5603e764547..520f10dd4e6 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -21,7 +21,7 @@
21 21
22;;; Code: 22;;; Code:
23 23
24(require 'ert) 24(require 'ert-x)
25(require 'erc) 25(require 'erc)
26(require 'erc-ring) 26(require 'erc-ring)
27(require 'erc-networks) 27(require 'erc-networks)
@@ -114,6 +114,63 @@
114 (should (get-buffer "#spam")) 114 (should (get-buffer "#spam"))
115 (kill-buffer "#spam"))) 115 (kill-buffer "#spam")))
116 116
117(ert-deftest erc--switch-to-buffer ()
118 (defvar erc-modified-channels-alist) ; lisp/erc/erc-track.el
119
120 (let ((proc (start-process "aNet" (current-buffer) "true"))
121 (erc-modified-channels-alist `(("fake") (,(messages-buffer))))
122 (inhibit-message noninteractive)
123 (completion-fail-discreetly t) ; otherwise ^G^G printed to .log file
124 ;;
125 erc-kill-channel-hook erc-kill-server-hook erc-kill-buffer-hook)
126
127 (with-current-buffer (get-buffer-create "server")
128 (erc-mode)
129 (set-process-buffer (setq erc-server-process proc) (current-buffer))
130 (set-process-query-on-exit-flag erc-server-process nil)
131 (with-current-buffer (get-buffer-create "#chan")
132 (erc-mode)
133 (setq erc-server-process proc))
134 (with-current-buffer (get-buffer-create "#foo")
135 (erc-mode)
136 (setq erc-server-process proc))
137
138 (ert-info ("Channel #chan selectable from server buffer")
139 (ert-simulate-keys (list ?# ?c ?h ?a ?n ?\C-m)
140 (should (string= "#chan" (erc--switch-to-buffer))))))
141
142 (ert-info ("Channel #foo selectable from non-ERC buffer")
143 (ert-simulate-keys (list ?# ?f ?o ?o ?\C-m)
144 (should (string= "#foo" (erc--switch-to-buffer)))))
145
146 (ert-info ("Default selectable")
147 (ert-simulate-keys (list ?\C-m)
148 (should (string= "*Messages*" (erc--switch-to-buffer)))))
149
150 (ert-info ("Extant but non-ERC buffer not selectable")
151 (get-buffer-create "#fake") ; not ours
152 (ert-simulate-keys (kbd "#fake C-m C-a C-k C-m")
153 ;; Initial query fails ~~~~~~^; clearing input accepts default
154 (should (string= "*Messages*" (erc--switch-to-buffer)))))
155
156 (with-current-buffer (get-buffer-create "other")
157 (erc-mode)
158 (setq erc-server-process (start-process "bNet" (current-buffer) "true"))
159 (set-process-query-on-exit-flag erc-server-process nil))
160
161 (ert-info ("Foreign ERC buffer not selectable")
162 (ert-simulate-keys (kbd "other C-m C-a C-k C-m")
163 (with-current-buffer "server"
164 (should (string= "*Messages*" (erc--switch-to-buffer))))))
165
166 (ert-info ("Any ERC-buffer selectable from non-ERC buffer")
167 (should-not (eq major-mode 'erc-mode))
168 (ert-simulate-keys (list ?o ?t ?h ?e ?r ?\C-m)
169 (should (string= "other" (erc--switch-to-buffer)))))
170
171 (dolist (b '("server" "other" "#chan" "#foo" "#fake"))
172 (kill-buffer b))))
173
117(ert-deftest erc-lurker-maybe-trim () 174(ert-deftest erc-lurker-maybe-trim ()
118 (let (erc-lurker-trim-nicks 175 (let (erc-lurker-trim-nicks
119 (erc-lurker-ignore-chars "_`")) 176 (erc-lurker-ignore-chars "_`"))