From 644c90b1a58979417323881afb2c54ce1af94d87 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Tue, 16 Jul 2024 04:53:38 +0200 Subject: [PATCH] Make error messages adhere to our standards * src/cygw32.c (chdir_to_default_directory): * src/fns.c (secure_hash): * src/keyboard.c (Finternal_handle_focus_in): * src/keymap.c (store_in_keymap): * src/pgtkfns.c (pgtk_set_scroll_bar_foreground) (pgtk_set_scroll_bar_background, Fx_export_frames) (Fpgtk_set_monitor_scale_factor, pgtk_get_defaults_value) (pgtk_set_defaults_value, Fpgtk_print_frames_dialog) (pgtk_get_monitor_scale_factor): * src/pgtkterm.c (pgtk_set_parent_frame): * src/process.c (network_interface_info, send_process): * src/w32.c (w32_read_registry): * src/w32fns.c (Fw32_read_registry): * src/window.c (Frecenter): * src/xfns.c (Fx_export_frames, Fx_print_frames_dialog) (x_set_mouse_color): Make 'error' message strings follow our guidelines. More specifically, they should not end in a period, and normally also be capitalized. See '(elisp) Programming Tips'. (cherry picked from commit 970409916e0dff9cd4d542f16f7d570149bdeeb1) --- src/cygw32.c | 4 ++-- src/fns.c | 2 +- src/keyboard.c | 2 +- src/keymap.c | 2 +- src/pgtkfns.c | 32 ++++++++++++++++---------------- src/pgtkterm.c | 2 +- src/process.c | 4 ++-- src/w32.c | 2 +- src/w32fns.c | 2 +- src/window.c | 2 +- src/xfns.c | 12 ++++++------ 11 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/cygw32.c b/src/cygw32.c index 7658e9a24a0..8415e0eab8e 100644 --- a/src/cygw32.c +++ b/src/cygw32.c @@ -37,7 +37,7 @@ chdir_to_default_directory (void) int old_cwd_fd = emacs_open (".", O_RDONLY | O_DIRECTORY, 0); if (old_cwd_fd == -1) - error ("could not open current directory: %s", strerror (errno)); + error ("Could not open current directory: %s", strerror (errno)); record_unwind_protect_int (fchdir_unwind, old_cwd_fd); @@ -47,7 +47,7 @@ chdir_to_default_directory (void) new_cwd = build_string ("/"); if (chdir (SSDATA (ENCODE_FILE (new_cwd)))) - error ("could not chdir: %s", strerror (errno)); + error ("Could not chdir: %s", strerror (errno)); } static Lisp_Object diff --git a/src/fns.c b/src/fns.c index 0f4d8e90789..a6addccb56e 100644 --- a/src/fns.c +++ b/src/fns.c @@ -6317,7 +6317,7 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, const char *input = extract_data_from_object (spec, &start_byte, &end_byte); if (input == NULL) - error ("secure_hash: failed to extract data from object, aborting!"); + error ("secure_hash: Failed to extract data from object, aborting!"); if (EQ (algorithm, Qmd5)) { diff --git a/src/keyboard.c b/src/keyboard.c index 13e899b7ad5..8f65378a850 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -7714,7 +7714,7 @@ This function potentially generates an artificial switch-frame event. */) if (!EQ (CAR_SAFE (event), Qfocus_in) || !CONSP (XCDR (event)) || !FRAMEP ((frame = XCAR (XCDR (event))))) - error ("invalid focus-in event"); + error ("Invalid focus-in event"); /* Conceptually, the concept of window manager focus on a particular frame and the Emacs selected frame shouldn't be related, but for diff --git a/src/keymap.c b/src/keymap.c index 0f50d804dff..f2a7e4006c3 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -749,7 +749,7 @@ store_in_keymap (Lisp_Object keymap, register Lisp_Object idx, def = Fcons (XCAR (def), XCDR (def)); if (!CONSP (keymap) || !EQ (XCAR (keymap), Qkeymap)) - error ("attempt to define a key in a non-keymap"); + error ("Attempt to define a key in a non-keymap"); /* If idx is a cons, and the car part is a character, idx must be of the form (FROM-CHAR . TO-CHAR). */ diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 49467988cae..b8e65f4c052 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -71,7 +71,7 @@ pgtk_get_monitor_scale_factor (const char *model) else if (FLOATP (cdr)) return XFLOAT_DATA (cdr); else - error ("unknown type of scale-factor"); + error ("Unknown type of scale-factor"); } struct pgtk_display_info * @@ -826,7 +826,7 @@ pgtk_set_scroll_bar_foreground (struct frame *f, Lisp_Object new_value, Emacs_Color rgb; if (!pgtk_parse_color (f, SSDATA (new_value), &rgb)) - error ("Unknown color."); + error ("Unknown color"); char css[64]; sprintf (css, "scrollbar slider { background-color: #%06x; }", @@ -836,7 +836,7 @@ pgtk_set_scroll_bar_foreground (struct frame *f, Lisp_Object new_value, } else - error ("Invalid scroll-bar-foreground."); + error ("Invalid scroll-bar-foreground"); } static void @@ -856,7 +856,7 @@ pgtk_set_scroll_bar_background (struct frame *f, Lisp_Object new_value, Emacs_Color rgb; if (!pgtk_parse_color (f, SSDATA (new_value), &rgb)) - error ("Unknown color."); + error ("Unknown color"); /* On pgtk, this frame parameter should be ignored, and honor gtk theme. (It honors the GTK theme if not explicitly set, so @@ -869,7 +869,7 @@ pgtk_set_scroll_bar_background (struct frame *f, Lisp_Object new_value, } else - error ("Invalid scroll-bar-background."); + error ("Invalid scroll-bar-background"); } @@ -904,7 +904,7 @@ unless TYPE is `png'. */) XSETFRAME (frame, f); if (!FRAME_VISIBLE_P (f)) - error ("Frames to be exported must be visible."); + error ("Frames to be exported must be visible"); tmp = Fcons (frame, tmp); } frames = Fnreverse (tmp); @@ -918,7 +918,7 @@ unless TYPE is `png'. */) if (EQ (type, Qpng)) { if (!NILP (XCDR (frames))) - error ("PNG export cannot handle multiple frames."); + error ("PNG export cannot handle multiple frames"); surface_type = CAIRO_SURFACE_TYPE_IMAGE; } else @@ -933,7 +933,7 @@ unless TYPE is `png'. */) { /* For now, we stick to SVG 1.1. */ if (!NILP (XCDR (frames))) - error ("SVG export cannot handle multiple frames."); + error ("SVG export cannot handle multiple frames"); surface_type = CAIRO_SURFACE_TYPE_SVG; } else @@ -1153,15 +1153,15 @@ scale factor. */) if (FIXNUMP (scale_factor)) { if (XFIXNUM (scale_factor) <= 0) - error ("scale factor must be > 0."); + error ("Scale factor must be > 0"); } else if (FLOATP (scale_factor)) { if (XFLOAT_DATA (scale_factor) <= 0.0) - error ("scale factor must be > 0."); + error ("Scale factor must be > 0"); } else - error ("unknown type of scale-factor"); + error ("Unknown type of scale-factor"); } Lisp_Object tem = Fassoc (monitor_model, monitor_scale_factor_alist, Qnil); @@ -1907,7 +1907,7 @@ pgtk_get_defaults_value (const char *key) char skey[(RESOURCE_KEY_MAX_LEN + 1) * 2]; if (strlen (key) >= RESOURCE_KEY_MAX_LEN) - error ("resource key too long."); + error ("Resource key too long"); GSettings *gs = parse_resource_key (key, skey); if (gs == NULL) @@ -1937,11 +1937,11 @@ pgtk_set_defaults_value (const char *key, const char *value) char skey[(RESOURCE_KEY_MAX_LEN + 1) * 2]; if (strlen (key) >= RESOURCE_KEY_MAX_LEN) - error ("resource key too long."); + error ("Resource key too long"); GSettings *gs = parse_resource_key (key, skey); if (gs == NULL) - error ("unknown resource key."); + error ("Unknown resource key"); if (value != NULL) { @@ -1971,7 +1971,7 @@ pgtk_get_defaults_value (const char *key) static void pgtk_set_defaults_value (const char *key, const char *value) { - error ("gsettings not supported."); + error ("gsettings not supported"); } #endif @@ -3659,7 +3659,7 @@ visible. */) XSETFRAME (frame, f); if (!FRAME_VISIBLE_P (f)) - error ("Frames to be printed must be visible."); + error ("Frames to be printed must be visible"); tmp = Fcons (frame, tmp); } frames = Fnreverse (tmp); diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 839bfdce988..079945126e0 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -928,7 +928,7 @@ pgtk_set_parent_frame (struct frame *f, Lisp_Object new_value, if (p != NULL) { if (FRAME_DISPLAY_INFO (f) != FRAME_DISPLAY_INFO (p)) - error ("Cross display reparent."); + error ("Cross display reparent"); } GtkWidget *fixed = FRAME_GTK_WIDGET (f); diff --git a/src/process.c b/src/process.c index 0167ceff7e0..93178eb241f 100644 --- a/src/process.c +++ b/src/process.c @@ -4471,7 +4471,7 @@ network_interface_info (Lisp_Object ifname) CHECK_STRING (ifname); if (sizeof rq.ifr_name <= SBYTES (ifname)) - error ("interface name too long"); + error ("Interface name too long"); lispstpcpy (rq.ifr_name, ifname); s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); @@ -6853,7 +6853,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len, pset_status (p, list2 (Qexit, make_fixnum (256))); p->tick = ++process_tick; deactivate_process (proc); - error ("process %s no longer connected to pipe; closed it", + error ("Process %s no longer connected to pipe; closed it", SDATA (p->name)); } else diff --git a/src/w32.c b/src/w32.c index 6dcbbbcc61b..31ffa301c2f 100644 --- a/src/w32.c +++ b/src/w32.c @@ -10221,7 +10221,7 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, Lisp_Object lname) retval = Fnreverse (val); break; default: - error ("unsupported registry data type: %d", (int)vtype); + error ("Unsupported registry data type: %d", (int)vtype); } xfree (pvalue); diff --git a/src/w32fns.c b/src/w32fns.c index e5798fdd84f..cd89745e9fa 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -10583,7 +10583,7 @@ to be converted to forward slashes by the caller. */) else if (EQ (root, QHKCC)) rootkey = HKEY_CURRENT_CONFIG; else if (!NILP (root)) - error ("unknown root key: %s", SDATA (SYMBOL_NAME (root))); + error ("Unknown root key: %s", SDATA (SYMBOL_NAME (root))); Lisp_Object val = w32_read_registry (rootkey, key, name); if (NILP (val) && NILP (root)) diff --git a/src/window.c b/src/window.c index ff28bac5306..4bb36b6733a 100644 --- a/src/window.c +++ b/src/window.c @@ -6711,7 +6711,7 @@ and redisplay normally--don't erase and redraw the frame. */) https://lists.gnu.org/r/emacs-devel/2014-06/msg00053.html, https://lists.gnu.org/r/emacs-devel/2014-06/msg00094.html. */ if (buf != current_buffer) - error ("`recenter'ing a window that does not display current-buffer."); + error ("`recenter'ing a window that does not display current-buffer"); /* If redisplay is suppressed due to an error, try again. */ buf->display_error_modiff = 0; diff --git a/src/xfns.c b/src/xfns.c index 9bc2f794849..917b82ff8da 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -1406,9 +1406,9 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) if (cursor_data.error_cursor >= 0) bad_cursor_name = mouse_cursor_types[cursor_data.error_cursor].name; if (bad_cursor_name) - error ("bad %s pointer cursor: %s", bad_cursor_name, xmessage); + error ("Bad %s pointer cursor: %s", bad_cursor_name, xmessage); else - error ("can't set cursor shape: %s", xmessage); + error ("Can't set cursor shape: %s", xmessage); } x_uncatch_errors_after_check (); @@ -9854,7 +9854,7 @@ unless TYPE is `png'. */) XSETFRAME (frame, f); if (!FRAME_VISIBLE_P (f)) - error ("Frames to be exported must be visible."); + error ("Frames to be exported must be visible"); tmp = Fcons (frame, tmp); } frames = Fnreverse (tmp); @@ -9868,7 +9868,7 @@ unless TYPE is `png'. */) if (EQ (type, Qpng)) { if (!NILP (XCDR (frames))) - error ("PNG export cannot handle multiple frames."); + error ("PNG export cannot handle multiple frames"); surface_type = CAIRO_SURFACE_TYPE_IMAGE; } else @@ -9883,7 +9883,7 @@ unless TYPE is `png'. */) { /* For now, we stick to SVG 1.1. */ if (!NILP (XCDR (frames))) - error ("SVG export cannot handle multiple frames."); + error ("SVG export cannot handle multiple frames"); surface_type = CAIRO_SURFACE_TYPE_SVG; } else @@ -9957,7 +9957,7 @@ Note: Text drawn with the `x' font backend is shown with hollow boxes. */) XSETFRAME (frame, f); if (!FRAME_VISIBLE_P (f)) - error ("Frames to be printed must be visible."); + error ("Frames to be printed must be visible"); tmp = Fcons (frame, tmp); } frames = Fnreverse (tmp); -- 2.39.5