commit f5e3c2cc9820a4f7f536a29836cdde6f65230bd3 (HEAD, refs/remotes/origin/master) Author: Philipp Stephani Date: Fri Apr 12 14:23:01 2019 +0200 Add a new user option 'ido-big-directories'. This provides an alternative to 'ido-max-directory-size', for directories that are statically known to be too big for Ido completion. * lisp/ido.el (ido-big-directories): New user option. (ido-directory-too-big-p): Use it. * test/lisp/ido-tests.el (ido-directory-too-big-p): New unit test. diff --git a/etc/NEWS b/etc/NEWS index 5e5d942d89..3e3454bd93 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -410,6 +410,11 @@ current and the previous or the next line, as before. *** New commands doc-view-presentation and doc-view-fit-window-to-page *** Added support for password-protected PDF files +** Ido +*** New user option 'ido-big-directories' to mark directories whose +names match certain regular expressions as big. Ido won't attempt to +list the contents of such directories when completing file names. + ** map.el *** Now also understands plists. *** Now defined via generic functions that can be extended via 'cl-defmethod'. diff --git a/lisp/ido.el b/lisp/ido.el index 0854014581..1a3a384ae6 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -735,6 +735,14 @@ not provide the normal completion. To show the completions, use \\[ido-toggle-i (integer :tag "Size in bytes" 30000)) :group 'ido) +(defcustom ido-big-directories nil + "List of directory pattern strings that should be considered big. +Ido won't attempt to list the contents of directories matching +any of these regular expressions when completing file names." + :type '(repeat regexp) + :group 'ido + :version "27.1") + (defcustom ido-rotate-file-list-default nil "Non-nil means that Ido will always rotate file list to get default in front." :type 'boolean @@ -1743,13 +1751,16 @@ is enabled then some keybindings are changed in the keymap." ;; Return t if dir is a directory, but too big to show ;; Do not check for non-readable directories via tramp, as this causes a premature ;; connect on incomplete tramp paths (after entering just method:). - (let ((ido-enable-tramp-completion nil)) - (and (numberp ido-max-directory-size) - (ido-final-slash dir) - (not (ido-is-unc-host dir)) - (file-directory-p dir) - (> (file-attribute-size (file-attributes (file-truename dir))) - ido-max-directory-size)))) + (let ((ido-enable-tramp-completion nil) + (case-fold-search nil)) + (or (seq-some (lambda (regexp) (string-match-p regexp dir)) + ido-big-directories) + (and (numberp ido-max-directory-size) + (ido-final-slash dir) + (not (ido-is-unc-host dir)) + (file-directory-p dir) + (> (file-attribute-size (file-attributes (file-truename dir))) + ido-max-directory-size))))) (defun ido-set-current-directory (dir &optional subdir no-merge) ;; Set ido's current directory to DIR or DIR/SUBDIR diff --git a/test/lisp/ido-tests.el b/test/lisp/ido-tests.el index cb8f1d6306..c9736eb3ec 100644 --- a/test/lisp/ido-tests.el +++ b/test/lisp/ido-tests.el @@ -25,6 +25,8 @@ ;;; Code: +(require 'ido) + (ert-deftest ido-tests--other-window-frame () "Verifies that Bug#26360 is fixed." (should-not ido-mode) @@ -44,4 +46,9 @@ (should (commandp #'ido-display-buffer-other-frame))) (ido-mode 0))) +(ert-deftest ido-directory-too-big-p () + (should-not (ido-directory-too-big-p "/some/dir/")) + (let ((ido-big-directories (cons (rx "me/di") ido-big-directories))) + (should (ido-directory-too-big-p "/some/dir/")))) + ;;; ido-tests.el ends here commit 74f54af2b9048cb1ea7a051c9efe079eaaeb4697 Author: Philipp Stephani Date: Fri Apr 19 10:26:32 2019 +0200 Use eassume (false) for branch that's never taken. * src/json.c (json_handle_nonlocal_exit): Use eassume (false) since this branch is never taken. diff --git a/src/json.c b/src/json.c index 6ddf5100e8..928825e034 100644 --- a/src/json.c +++ b/src/json.c @@ -675,7 +675,7 @@ json_handle_nonlocal_exit (enum nonlocal_exit type, Lisp_Object data) case NONLOCAL_EXIT_THROW: return Fcons (Qno_catch, data); default: - return Qnil; + eassume (false); } } commit d9d9c32329cb17f96cb1690228b30702b5a4c772 Author: Eli Zaretskii Date: Fri Apr 19 11:04:17 2019 +0300 Fix compilation warning due to a recent change * src/json.c (json_handle_nonlocal_exit): Always return a value. diff --git a/src/json.c b/src/json.c index 014ac3e316..6ddf5100e8 100644 --- a/src/json.c +++ b/src/json.c @@ -674,6 +674,8 @@ json_handle_nonlocal_exit (enum nonlocal_exit type, Lisp_Object data) return data; case NONLOCAL_EXIT_THROW: return Fcons (Qno_catch, data); + default: + return Qnil; } } commit 5ada97cfcd4c331876d80cabbf4d5a5e762bf581 Author: YAMAMOTO Mitsuharu Date: Fri Apr 19 09:55:53 2019 +0900 * src/ftcrfont.c (ftcrfont_glyph_extents): Activate ft_size_draw. diff --git a/src/ftcrfont.c b/src/ftcrfont.c index 5d81b39d81..4845ee4cf3 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c @@ -78,6 +78,7 @@ ftcrfont_glyph_extents (struct font *font, cairo_glyph_t cr_glyph = {.index = glyph}; cairo_text_extents_t extents; + FT_Activate_Size (ftcrfont_info->ft_size_draw); cairo_scaled_font_glyph_extents (ftcrfont_info->cr_scaled_font, &cr_glyph, 1, &extents); cache->lbearing = floor (extents.x_bearing); commit 0a453ee7e4452a8848a71272efa14550fc7d95eb Author: YAMAMOTO Mitsuharu Date: Fri Apr 19 09:54:59 2019 +0900 * src/ftcrfont.c (ftcrfont_open): Avoid returning while blocking input. diff --git a/src/ftcrfont.c b/src/ftcrfont.c index 18f9c2dd31..5d81b39d81 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c @@ -117,39 +117,37 @@ static Lisp_Object ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) { Lisp_Object font_object; - struct font *font; - struct font_info *ftcrfont_info; - FT_Face ft_face; - FT_UInt size; - block_input (); - size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX)); + FT_UInt size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX)); if (size == 0) size = pixel_size; font_object = font_build_object (VECSIZE (struct font_info), Qftcr, entity, size); + block_input (); font_object = ftfont_open2 (f, entity, pixel_size, font_object); - if (NILP (font_object)) return Qnil; - - font = XFONT_OBJECT (font_object); - font->driver = &ftcrfont_driver; - ftcrfont_info = (struct font_info *) font; - ft_face = ftcrfont_info->ft_size->face; - FT_New_Size (ft_face, &ftcrfont_info->ft_size_draw); - FT_Activate_Size (ftcrfont_info->ft_size_draw); - FT_Set_Pixel_Sizes (ft_face, 0, font->pixel_size); - cairo_font_face_t *font_face = - cairo_ft_font_face_create_for_ft_face (ft_face, 0); - cairo_matrix_t font_matrix, ctm; - cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size); - cairo_matrix_init_identity (&ctm); - cairo_font_options_t *options = cairo_font_options_create (); - ftcrfont_info->cr_scaled_font = - cairo_scaled_font_create (font_face, &font_matrix, &ctm, options); - cairo_font_face_destroy (font_face); - cairo_font_options_destroy (options); - ftcrfont_info->metrics = NULL; - ftcrfont_info->metrics_nrows = 0; + if (FONT_OBJECT_P (font_object)) + { + struct font *font = XFONT_OBJECT (font_object); + struct font_info *ftcrfont_info = (struct font_info *) font; + FT_Face ft_face = ftcrfont_info->ft_size->face; + + font->driver = &ftcrfont_driver; + FT_New_Size (ft_face, &ftcrfont_info->ft_size_draw); + FT_Activate_Size (ftcrfont_info->ft_size_draw); + FT_Set_Pixel_Sizes (ft_face, 0, font->pixel_size); + cairo_font_face_t *font_face = + cairo_ft_font_face_create_for_ft_face (ft_face, 0); + cairo_matrix_t font_matrix, ctm; + cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size); + cairo_matrix_init_identity (&ctm); + cairo_font_options_t *options = cairo_font_options_create (); + ftcrfont_info->cr_scaled_font = + cairo_scaled_font_create (font_face, &font_matrix, &ctm, options); + cairo_font_face_destroy (font_face); + cairo_font_options_destroy (options); + ftcrfont_info->metrics = NULL; + ftcrfont_info->metrics_nrows = 0; + } unblock_input (); return font_object; commit 23a82cba12380b0905670c34395dc460a4bc9984 Author: Philipp Stephani Date: Fri Apr 19 01:04:55 2019 +0200 Refactoring: have CATCHER_ALL also catch signals. In all cases where we use a CATCHER_ALL handler we also want to catch signals. Therefore have 'signal' respect CATCHER_ALL. Adapt internal interfaces so that handlers can distinguish among the two types of nonlocal exits in CATCHER_ALL handlers. * src/lisp.h (enum nonlocal_exit): New enum. (struct handler): Add member 'nonlocal_exit' to hold the type of nonlocal exit during stack unwinding. * src/eval.c (signal_or_quit): Also respect CATCHER_ALL handlers. (unwind_to_catch): Store nonlocal exit type in catch structure. (Fthrow, signal_or_quit): Adapt callers. (internal_catch_all): Install only one handler. Give handler a nonlocal exit type argument. (internal_catch_all_1): Remove, no longer needed. * src/emacs-module.c (MODULE_SETJMP): Install only one handler. (module_handle_nonlocal_exit): New function to handle all nonlocal exits. (MODULE_SETJMP_1): Pass nonlocal exit type to handler function. (module_handle_signal, module_handle_throw): Remove, no longer needed. * src/json.c (json_handle_nonlocal_exit): New helper function. (json_insert_callback): Adapt to change in 'internal_catch_all'. diff --git a/src/emacs-module.c b/src/emacs-module.c index fd033e8044..393a4354b8 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -201,8 +201,8 @@ static emacs_env *initialize_environment (emacs_env *, static void finalize_environment (emacs_env *); static void finalize_environment_unwind (void *); static void finalize_runtime_unwind (void *); -static void module_handle_signal (emacs_env *, Lisp_Object); -static void module_handle_throw (emacs_env *, Lisp_Object); +static void module_handle_nonlocal_exit (emacs_env *, enum nonlocal_exit, + Lisp_Object); static void module_non_local_exit_signal_1 (emacs_env *, Lisp_Object, Lisp_Object); static void module_non_local_exit_throw_1 (emacs_env *, @@ -231,11 +231,8 @@ static bool module_assertions = false; or a pointer to handle non-local exits. The function must have an ENV parameter. The function will return the specified value if a signal or throw is caught. */ -/* TODO: Have Fsignal check for CATCHER_ALL so we only have to install - one handler. */ #define MODULE_HANDLE_NONLOCAL_EXIT(retval) \ - MODULE_SETJMP (CONDITION_CASE, module_handle_signal, retval); \ - MODULE_SETJMP (CATCHER_ALL, module_handle_throw, retval) + MODULE_SETJMP (CATCHER_ALL, module_handle_nonlocal_exit, retval) #define MODULE_SETJMP(handlertype, handlerfunc, retval) \ MODULE_SETJMP_1 (handlertype, handlerfunc, retval, \ @@ -271,7 +268,7 @@ static bool module_assertions = false; = c0; \ if (sys_setjmp (c->jmp)) \ { \ - (handlerfunc) (env, c->val); \ + (handlerfunc) (env, c->nonlocal_exit, c->val); \ return retval; \ } \ do { } while (false) @@ -1183,20 +1180,22 @@ module_reset_handlerlist (struct handler **phandlerlist) handlerlist = handlerlist->next; } -/* Called on `signal'. ERR is a pair (SYMBOL . DATA), which gets - stored in the environment. Set the pending non-local exit flag. */ +/* Called on `signal' and `throw'. DATA is a pair + (ERROR-SYMBOL . ERROR-DATA) or (TAG . VALUE), which gets stored in + the environment. Set the pending non-local exit flag. */ static void -module_handle_signal (emacs_env *env, Lisp_Object err) +module_handle_nonlocal_exit (emacs_env *env, enum nonlocal_exit type, + Lisp_Object data) { - module_non_local_exit_signal_1 (env, XCAR (err), XCDR (err)); -} - -/* Called on `throw'. TAG_VAL is a pair (TAG . VALUE), which gets - stored in the environment. Set the pending non-local exit flag. */ -static void -module_handle_throw (emacs_env *env, Lisp_Object tag_val) -{ - module_non_local_exit_throw_1 (env, XCAR (tag_val), XCDR (tag_val)); + switch (type) + { + case NONLOCAL_EXIT_SIGNAL: + module_non_local_exit_signal_1 (env, XCAR (data), XCDR (data)); + break; + case NONLOCAL_EXIT_THROW: + module_non_local_exit_throw_1 (env, XCAR (data), XCDR (data)); + break; + } } diff --git a/src/eval.c b/src/eval.c index c2e996a947..23fd0efd54 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1134,13 +1134,15 @@ internal_catch (Lisp_Object tag, This is used for correct unwinding in Fthrow and Fsignal. */ static AVOID -unwind_to_catch (struct handler *catch, Lisp_Object value) +unwind_to_catch (struct handler *catch, enum nonlocal_exit type, + Lisp_Object value) { bool last_time; eassert (catch->next); /* Save the value in the tag. */ + catch->nonlocal_exit = type; catch->val = value; /* Restore certain special C variables. */ @@ -1177,9 +1179,9 @@ Both TAG and VALUE are evalled. */ for (c = handlerlist; c; c = c->next) { if (c->type == CATCHER_ALL) - unwind_to_catch (c, Fcons (tag, value)); - if (c->type == CATCHER && EQ (c->tag_or_ch, tag)) - unwind_to_catch (c, value); + unwind_to_catch (c, NONLOCAL_EXIT_THROW, Fcons (tag, value)); + if (c->type == CATCHER && EQ (c->tag_or_ch, tag)) + unwind_to_catch (c, NONLOCAL_EXIT_THROW, value); } xsignal2 (Qno_catch, tag, value); } @@ -1427,44 +1429,21 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *), } } -static Lisp_Object -internal_catch_all_1 (Lisp_Object (*function) (void *), void *argument) -{ - struct handler *c = push_handler_nosignal (Qt, CATCHER_ALL); - if (c == NULL) - return Qcatch_all_memory_full; - - if (sys_setjmp (c->jmp) == 0) - { - Lisp_Object val = function (argument); - eassert (handlerlist == c); - handlerlist = c->next; - return val; - } - else - { - eassert (handlerlist == c); - Lisp_Object val = c->val; - handlerlist = c->next; - Fsignal (Qno_catch, val); - } -} - /* Like a combination of internal_condition_case_1 and internal_catch. Catches all signals and throws. Never exits nonlocally; returns Qcatch_all_memory_full if no handler could be allocated. */ Lisp_Object internal_catch_all (Lisp_Object (*function) (void *), void *argument, - Lisp_Object (*handler) (Lisp_Object)) + Lisp_Object (*handler) (enum nonlocal_exit, Lisp_Object)) { - struct handler *c = push_handler_nosignal (Qt, CONDITION_CASE); + struct handler *c = push_handler_nosignal (Qt, CATCHER_ALL); if (c == NULL) return Qcatch_all_memory_full; if (sys_setjmp (c->jmp) == 0) { - Lisp_Object val = internal_catch_all_1 (function, argument); + Lisp_Object val = function (argument); eassert (handlerlist == c); handlerlist = c->next; return val; @@ -1472,9 +1451,10 @@ internal_catch_all (Lisp_Object (*function) (void *), void *argument, else { eassert (handlerlist == c); + enum nonlocal_exit type = c->nonlocal_exit; Lisp_Object val = c->val; handlerlist = c->next; - return handler (val); + return handler (type, val); } } @@ -1645,6 +1625,11 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit) for (h = handlerlist; h; h = h->next) { + if (h->type == CATCHER_ALL) + { + clause = Qt; + break; + } if (h->type != CONDITION_CASE) continue; clause = find_handler_clause (h->tag_or_ch, conditions); @@ -1678,7 +1663,7 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit) Lisp_Object unwind_data = (NILP (error_symbol) ? data : Fcons (error_symbol, data)); - unwind_to_catch (h, unwind_data); + unwind_to_catch (h, NONLOCAL_EXIT_SIGNAL, unwind_data); } else { diff --git a/src/json.c b/src/json.c index 5917212899..014ac3e316 100644 --- a/src/json.c +++ b/src/json.c @@ -665,6 +665,18 @@ json_insert (void *data) return Qnil; } +static Lisp_Object +json_handle_nonlocal_exit (enum nonlocal_exit type, Lisp_Object data) +{ + switch (type) + { + case NONLOCAL_EXIT_SIGNAL: + return data; + case NONLOCAL_EXIT_THROW: + return Fcons (Qno_catch, data); + } +} + struct json_insert_data { /* This tracks how many bytes were inserted by the callback since @@ -687,7 +699,8 @@ json_insert_callback (const char *buffer, size_t size, void *data) struct json_insert_data *d = data; struct json_buffer_and_size buffer_and_size = {.buffer = buffer, .size = size, .inserted_bytes = d->inserted_bytes}; - d->error = internal_catch_all (json_insert, &buffer_and_size, Fidentity); + d->error = internal_catch_all (json_insert, &buffer_and_size, + json_handle_nonlocal_exit); d->inserted_bytes = buffer_and_size.inserted_bytes; return NILP (d->error) ? 0 : -1; } diff --git a/src/lisp.h b/src/lisp.h index 0da2037522..2aa767b86c 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3262,8 +3262,10 @@ SPECPDL_INDEX (void) member is TAG, and then unbinds to it. The `val' member is used to hold VAL while the stack is unwound; `val' is returned as the value of the catch form. If there is a handler of type CATCHER_ALL, it will - be treated as a handler for all invocations of `throw'; in this case - `val' will be set to (TAG . VAL). + be treated as a handler for all invocations of `signal' and `throw'; + in this case `val' will be set to (ERROR-SYMBOL . DATA) or (TAG . VAL), + respectively. During stack unwinding, `nonlocal_exit' is set to + specify the type of nonlocal exit that caused the stack unwinding. All the other members are concerned with restoring the interpreter state. @@ -3273,11 +3275,21 @@ SPECPDL_INDEX (void) enum handlertype { CATCHER, CONDITION_CASE, CATCHER_ALL }; +enum nonlocal_exit +{ + NONLOCAL_EXIT_SIGNAL, + NONLOCAL_EXIT_THROW, +}; + struct handler { enum handlertype type; Lisp_Object tag_or_ch; + + /* The next two are set by unwind_to_catch. */ + enum nonlocal_exit nonlocal_exit; Lisp_Object val; + struct handler *next; struct handler *nextfree; @@ -4129,7 +4141,7 @@ extern Lisp_Object internal_condition_case_2 (Lisp_Object (*) (Lisp_Object, Lisp extern Lisp_Object internal_condition_case_n (Lisp_Object (*) (ptrdiff_t, Lisp_Object *), ptrdiff_t, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object, ptrdiff_t, Lisp_Object *)); -extern Lisp_Object internal_catch_all (Lisp_Object (*) (void *), void *, Lisp_Object (*) (Lisp_Object)); +extern Lisp_Object internal_catch_all (Lisp_Object (*) (void *), void *, Lisp_Object (*) (enum nonlocal_exit, Lisp_Object)); extern struct handler *push_handler (Lisp_Object, enum handlertype); extern struct handler *push_handler_nosignal (Lisp_Object, enum handlertype); extern void specbind (Lisp_Object, Lisp_Object); commit e712a8fe0929a18eaf3f4ec83b023f475afdc4d4 Author: Philipp Stephani Date: Thu Apr 18 23:31:00 2019 +0200 Update module documentation for bignum support. * doc/lispref/internals.texi (Module Values): Update documentation for 'make_integer' and 'extract_integer' for bignum support. diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 8ebe47d9ad..fc5ce594e6 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi @@ -1378,7 +1378,9 @@ can be used to obtain the type of a @code{emacs_value} object. This function returns the value of a Lisp integer specified by @var{arg}. The C data type of the return value, @code{intmax_t}, is the widest integral data type supported by the C compiler, typically -@w{@code{long long}}. +@w{@code{long long}}. If the value of @var{arg} doesn't fit into an +@code{intmax_t}, the function signals an error using the error symbol +@code{overflow-error}. @end deftypefn @deftypefn Function double extract_float (emacs_env *@var{env}, emacs_value @var{arg}) @@ -1440,11 +1442,10 @@ objects from basic C data types. They all return the created @deftypefn Function emacs_value make_integer (emacs_env *@var{env}, intmax_t @var{n}) This function takes an integer argument @var{n} and returns the -corresponding @code{emacs_value} object. It raises the -@code{overflow-error} error condition if the value of @var{n} cannot -be represented as an Emacs integer, i.e.@: is not inside the limits -set by @code{most-negative-fixnum} and @code{most-positive-fixnum} -(@pxref{Integer Basics}). +corresponding @code{emacs_value} object. It returns either a fixnum +or a bignum depending on whether the value of @var{n} is inside the +limits set by @code{most-negative-fixnum} and +@code{most-positive-fixnum} (@pxref{Integer Basics}). @end deftypefn @deftypefn Function emacs_value make_float (emacs_env *@var{env}, double @var{d}) commit ee4ba5c8fe42311f676f4553504c3f61a3eb0168 Author: Philipp Stephani Date: Thu Apr 18 23:29:20 2019 +0200 ; * src/lisp.h (integer_to_intmax): Fix typo. diff --git a/src/lisp.h b/src/lisp.h index 25d0a3d6ac..0da2037522 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3475,7 +3475,7 @@ extern Lisp_Object make_bignum_str (char const *, int); extern Lisp_Object make_neg_biguint (uintmax_t); extern Lisp_Object double_to_integer (double); -/* Converthe integer NUM to *N. Return true if successful, false +/* Convert the integer NUM to *N. Return true if successful, false (possibly setting *N) otherwise. */ INLINE bool integer_to_intmax (Lisp_Object num, intmax_t *n) commit 856806d30fb16dbe695633a2dbe35a8fb4348998 Author: Philipp Stephani Date: Thu Apr 18 23:19:05 2019 +0200 * lib-src/make-fingerprint.c (main): Properly initialize 'prog' diff --git a/lib-src/make-fingerprint.c b/lib-src/make-fingerprint.c index b0a51abf29..38a3357614 100644 --- a/lib-src/make-fingerprint.c +++ b/lib-src/make-fingerprint.c @@ -80,7 +80,7 @@ main (int argc, char **argv) struct sha256_ctx ctx; sha256_init_ctx (&ctx); - char *prog = prog; + char *prog = argv[0]; char *file = argv[optind]; if (argc - optind != 1) { commit e7caf9c744118910163ec452a05a5b90d6398755 Author: Philipp Stephani Date: Thu Apr 18 23:18:06 2019 +0200 * src/emacs-module.c: Add instructions how to change the module API diff --git a/src/emacs-module.c b/src/emacs-module.c index 09a768e18e..fd033e8044 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -17,6 +17,54 @@ 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 . */ +/* +The public module API is defined in the header emacs-module.h. The +configure script generates emacs-module.h from emacs-module.h.in and +the version-specific environment fragments in module-env-*.h. + +If you want to change the module API, please abide to the following +rules: + +- Don't remove publicly documented declarations from the headers. + +- Don't remove, reorder, or rename structure fields, as such changes + break ABI compatibility. + +- Don't change the types of structure fields. + +- Add structure fields only at the end of structures. + +- For every Emacs major version there is a new fragment file + module-env-VER.h. Add functions solely at the end of the fragment + file for the next (not yet released) major version of Emacs. For + example, if the current Emacs release is 26.2, add functions only to + emacs-env-27.h. + +- emacs-module.h should only depend on standard C headers. In + particular, don't include config.h or lisp.h from emacs-module.h. + +- Prefix all names in emacs-module.h with "emacs_" or "EMACS_". + +To add a new module function, proceed as follows: + +1. Add a new function pointer field at the end of the emacs-env-*.h + file for the next major version of Emacs. + +2. Run config.status or configure to regenerate emacs-module.h. + +3. Create a corresponding implementation function in this file. See + "Implementation of runtime and environment functions" below for + further rules. + +4. Assign the new field in the initialize_environment function. + +5. Add a test function that calls your new function to + test/data/emacs-module/mod-test.c. Add a unit test that invokes + your new test function to test/src/emacs-module-tests.el. + +6. Document your new function in the manual and in etc/NEWS. +*/ + #include #include "emacs-module.h" commit df5ca4f7e66fe075d1ad12a0e2831c4ed91fd186 Author: Paul Eggert Date: Thu Apr 18 12:56:23 2019 -0700 Fix make-fingerprint off-by-one bug Problem reported by Alex Gramiak in: https://lists.gnu.org/r/emacs-devel/2019-04/msg00784.html * lib-src/make-fingerprint.c (main): Fix recently-introduced off-by-one bug when accessing args after -r. diff --git a/lib-src/make-fingerprint.c b/lib-src/make-fingerprint.c index 535e575132..b0a51abf29 100644 --- a/lib-src/make-fingerprint.c +++ b/lib-src/make-fingerprint.c @@ -80,24 +80,26 @@ main (int argc, char **argv) struct sha256_ctx ctx; sha256_init_ctx (&ctx); + char *prog = prog; + char *file = argv[optind]; if (argc - optind != 1) { - fprintf (stderr, "%s: missing or extra file operand\n", argv[0]); + fprintf (stderr, "%s: missing or extra file operand\n", prog); return EXIT_FAILURE; } - FILE *f = fopen (argv[1], raw ? "r" FOPEN_BINARY : "r+" FOPEN_BINARY); + FILE *f = fopen (file, raw ? "r" FOPEN_BINARY : "r+" FOPEN_BINARY); struct stat st; if (!f || fstat (fileno (f), &st) != 0) { - perror (argv[1]); + perror (file); return EXIT_FAILURE; } if (!S_ISREG (st.st_mode)) { fprintf (stderr, "%s: Error: %s is not a regular file\n", - argv[0], argv[1]); + prog, file); return EXIT_FAILURE; } @@ -105,7 +107,7 @@ main (int argc, char **argv) min (SIZE_MAX, SSIZE_MAX)); if (maxlen <= st.st_size) { - fprintf (stderr, "%s: %s: file too big\n", argv[0], argv[1]); + fprintf (stderr, "%s: %s: file too big\n", prog, file); return EXIT_FAILURE; } @@ -119,8 +121,7 @@ main (int argc, char **argv) size_t chunksz = fread (buf, 1, st.st_size + 1, f); if (ferror (f) || chunksz != st.st_size) { - fprintf (stderr, "%s: Error: could not read %s\n", - argv[0], argv[1]); + fprintf (stderr, "%s: Error: could not read %s\n", prog, file); return EXIT_FAILURE; } @@ -139,33 +140,33 @@ main (int argc, char **argv) char *finger = memmem (buf, chunksz, fingerprint, sizeof fingerprint); if (!finger) { - fprintf (stderr, "%s: %s: missing fingerprint\n", argv[0], argv[1]); + fprintf (stderr, "%s: %s: missing fingerprint\n", prog, file); return EXIT_FAILURE; } else if (memmem (finger + 1, buf + chunksz - (finger + 1), fingerprint, sizeof fingerprint)) { fprintf (stderr, "%s: %s: two occurrences of fingerprint\n", - argv[0], argv[1]); + prog, file); return EXIT_FAILURE; } if (fseeko (f, finger - buf, SEEK_SET) != 0) { - perror (argv[1]); + perror (file); return EXIT_FAILURE; } if (fwrite (digest, 1, sizeof digest, f) != sizeof digest) { - perror (argv[1]); + perror (file); return EXIT_FAILURE; } } if (fclose (f) != 0) { - perror (argv[1]); + perror (file); return EXIT_FAILURE; } commit a99a3542f3ae6c17af033c17f03a45a1def75e8f Author: Michael Albinus Date: Thu Apr 18 21:47:21 2019 +0200 ; Instrument `tramp--test-shell-command-to-string-asynchronously' diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 926bf3371c..f228c5c5a8 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -4085,11 +4085,15 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (defun tramp--test-shell-command-to-string-asynchronously (command) "Like `shell-command-to-string', but for asynchronous processes." (with-temp-buffer - (async-shell-command command (current-buffer)) - (with-timeout - ((if (getenv "EMACS_EMBA_CI") 30 10) (tramp--test-timeout-handler)) - (while (accept-process-output - (get-buffer-process (current-buffer)) nil nil t))) + (unwind-protect + (async-shell-command command (current-buffer)) + (with-timeout + ((if (getenv "EMACS_EMBA_CI") 30 10) (tramp--test-timeout-handler)) + (while (accept-process-output + (get-buffer-process (current-buffer)) nil nil t))) + (tramp--test-message + "# %s\n%s" + command (buffer-substring-no-properties (point-min) (point-max)))) (buffer-substring-no-properties (point-min) (point-max)))) (ert-deftest tramp-test32-shell-command () @@ -4189,7 +4193,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (ignore-errors (delete-file tmp-name))) ;; Test `shell-command-width' of `async-shell-command'. - ;; `executable-find' has changed the number of parameters in ;; Emacs 27.1, so we use `apply' for older Emacsen. (when (and (executable-find "tput") commit a18336a8dc754fa1c68e16dd8009466cf409271b Author: Eric Abrahamsen Date: Thu Apr 18 09:06:09 2019 -0700 Only encode Gnus group names if they come from symbol-name * lisp/gnus/gnus-start.el (gnus-active-to-gnus-format): Names that were strings to begin with should already be properly encoded. diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el index 2beb685822..606155d741 100644 --- a/lisp/gnus/gnus-start.el +++ b/lisp/gnus/gnus-start.el @@ -2146,14 +2146,14 @@ The info element is shared with the same element of (if (and (stringp (progn (setq group (read cur) group - (encode-coding-string - (cond ((numberp group) - (number-to-string group)) - ((symbolp group) - (symbol-name group)) - ((stringp group) - group)) - 'latin-1)))) + (cond ((numberp group) + (number-to-string group)) + ((symbolp group) + (encode-coding-string + (symbol-name group) + 'latin-1)) + ((stringp group) + group))))) (numberp (setq max (read cur))) (numberp (setq min (read cur))) (null (progn