From a2d92b0dfcc6f38362b611987969d33d02f3ff2e Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 17 Jan 2025 18:17:35 +0100 Subject: [PATCH] Turn macros into enums in keyboard.h * src/keyboard.h (item_property_idx, menu_item_pane_idx): Turn macros into enums. (ITEM_PROPERTY_MAX): New constant. * src/keyboard.c (parse_menu_item): Use above new constant. (cherry picked from commit 91b2b3654f2dcf79c15a11cfe1130df6638b4a4e) --- src/keyboard.c | 4 ++-- src/keyboard.h | 60 ++++++++++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/keyboard.c b/src/keyboard.c index 1846245ec9b..5e18758f013 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -8713,10 +8713,10 @@ parse_menu_item (Lisp_Object item, int inmenubar) /* Create item_properties vector if necessary. */ if (NILP (item_properties)) - item_properties = make_nil_vector (ITEM_PROPERTY_ENABLE + 1); + item_properties = make_nil_vector (ITEM_PROPERTY_MAX + 1); /* Initialize optional entries. */ - for (i = ITEM_PROPERTY_DEF; i < ITEM_PROPERTY_ENABLE; i++) + for (i = ITEM_PROPERTY_DEF; i < ITEM_PROPERTY_MAX; i++) ASET (item_properties, i, Qnil); ASET (item_properties, ITEM_PROPERTY_ENABLE, Qt); diff --git a/src/keyboard.h b/src/keyboard.h index c1bb966d485..5e04b54eb74 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -294,26 +294,31 @@ extern Lisp_Object item_properties; /* This describes the elements of item_properties. The first element is not a property, it is a pointer to the item properties that is saved for GC protection. */ -#define ITEM_PROPERTY_ITEM 0 -/* The item string. */ -#define ITEM_PROPERTY_NAME 1 -/* Start of initialize to nil */ -/* The binding: nil, a command or a keymap. */ -#define ITEM_PROPERTY_DEF 2 -/* The keymap if the binding is a keymap, otherwise nil. */ -#define ITEM_PROPERTY_MAP 3 -/* Nil, :radio or :toggle. */ -#define ITEM_PROPERTY_TYPE 4 -/* Nil or a string describing an equivalent key binding. */ -#define ITEM_PROPERTY_KEYEQ 5 -/* Not nil if a selected toggle box or radio button, otherwise nil. */ -#define ITEM_PROPERTY_SELECTED 6 -/* Place for a help string. Not yet used. */ -#define ITEM_PROPERTY_HELP 7 -/* Start of initialize to t */ -/* Last property. */ -/* Not nil if item is enabled. */ -#define ITEM_PROPERTY_ENABLE 8 +enum item_property_idx +{ + ITEM_PROPERTY_ITEM, + /* The item string. */ + ITEM_PROPERTY_NAME, + /* Start of initialize to nil */ + /* The binding: nil, a command or a keymap. */ + ITEM_PROPERTY_DEF, + /* The keymap if the binding is a keymap, otherwise nil. */ + ITEM_PROPERTY_MAP, + /* Nil, :radio or :toggle. */ + ITEM_PROPERTY_TYPE, + /* Nil or a string describing an equivalent key binding. */ + ITEM_PROPERTY_KEYEQ, + /* Not nil if a selected toggle box or radio button, otherwise nil. */ + ITEM_PROPERTY_SELECTED, + /* Place for a help string. Not yet used. */ + ITEM_PROPERTY_HELP, + /* Start of initialize to t */ + /* Last property. */ + /* Not nil if item is enabled. */ + ITEM_PROPERTY_ENABLE, + /* Keep this equal to the highest member. */ + ITEM_PROPERTY_MAX = ITEM_PROPERTY_ENABLE +}; /* This holds a Lisp vector that holds the results of decoding the keymaps or alist-of-alists that specify a menu. @@ -352,9 +357,12 @@ extern int menu_items_used; excluding those within submenus. */ extern int menu_items_n_panes; -#define MENU_ITEMS_PANE_NAME 1 -#define MENU_ITEMS_PANE_PREFIX 2 -#define MENU_ITEMS_PANE_LENGTH 3 +enum menu_item_pane_idx +{ + MENU_ITEMS_PANE_NAME = 1, + MENU_ITEMS_PANE_PREFIX = 2, + MENU_ITEMS_PANE_LENGTH = 3, +}; enum menu_item_idx { @@ -370,9 +378,9 @@ enum menu_item_idx }; enum - { - KBD_BUFFER_SIZE = 4096 - }; +{ + KBD_BUFFER_SIZE = 4096 +}; extern void unuse_menu_items (void); -- 2.39.5