From 785adfcc8dee02ac544f80e4f7f8d3d5b2965981 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 13 Jan 2015 15:22:19 -0800 Subject: [PATCH] Don't say Fnext_read_file_uses_dialog_p is const It's const only if a windowing system is not used; don't say it's const otherwise. See: http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00310.html * lib-src/make-docfile.c (write_globals): Add a special hack for Fnext_read_file_uses_dialog_p. * src/fileio.c (next_read_file_uses_dialog_p): Remove. Move guts back to ... (Fnext_read_file_uses_dialog_p): ... here. Don't declare as const, as make-docfile.c now has a special case for this function. This is an ugly hack, but it's better than lying to the compiler. --- lib-src/ChangeLog | 6 ++++++ lib-src/make-docfile.c | 12 ++++++++++++ src/ChangeLog | 11 +++++++++++ src/fileio.c | 30 ++++++++++-------------------- 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 969aac80124..e9205fdd12a 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,9 @@ +2015-01-13 Paul Eggert + + Don't say Fnext_read_file_uses_dialog_p is const + * make-docfile.c (write_globals): + Add a special hack for Fnext_read_file_uses_dialog_p. + 2015-01-13 Dmitry Antipov Support DEFUN attributes. diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 79d421a0a8e..741fa4bfa42 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c @@ -729,6 +729,18 @@ write_globals (void) if (globals[i].flags & DEFUN_const) fputs (" ATTRIBUTE_CONST", stdout); + else if (strcmp (globals[i].name, "Fnext_read_file_uses_dialog_p") + == 0) + { + /* It would be nice to have a cleaner way to deal with this + special hack. */ + fputs (("\n" + "#if ! (defined USE_GTK || defined USE_MOTIF \\\n" + " || defined HAVE_NS || defined HAVE_NTGUI)\n" + "\tATTRIBUTE_CONST\n" + "#endif\n"), + stdout); + } puts (";"); } diff --git a/src/ChangeLog b/src/ChangeLog index 7ec6980bd08..8d05ec13295 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,16 @@ 2015-01-13 Paul Eggert + Don't say Fnext_read_file_uses_dialog_p is const + It's const only if a windowing system is not used; don't say it's + const otherwise. See: + http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00310.html + * fileio.c (next_read_file_uses_dialog_p): Remove. + Move guts back to ... + (Fnext_read_file_uses_dialog_p): ... here. + Don't declare as const, as make-docfile.c now has a special case + for this function. This is an ugly hack, but it's better than + lying to the compiler. + Remove now-unnecessary forward XTYPE decl * lisp.h (XTYPE): Remove forward declaration. The recent merge from emacs-24 fixed the problem in a better way, by moving XPNTR's diff --git a/src/fileio.c b/src/fileio.c index 45a31c0e573..6c443c91db7 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -5734,34 +5734,24 @@ then any auto-save counts as "recent". */) return (SAVE_MODIFF < BUF_AUTOSAVE_MODIFF (current_buffer) ? Qt : Qnil); } -/* We want Fnext_read_file_uses_dialog_p to have ATTRIBUTE_CONST - regardless of #ifdefs, so there is a trivial workaround. See - http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00289.html. */ - -static bool -next_read_file_uses_dialog_p (void) -{ -#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) \ - || defined (HAVE_NS) - return ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) - && use_dialog_box - && use_file_dialog - && window_system_available (SELECTED_FRAME ())); -#endif - return false; -} - /* Reading and completing file names. */ DEFUN ("next-read-file-uses-dialog-p", Fnext_read_file_uses_dialog_p, Snext_read_file_uses_dialog_p, 0, 0, 0, doc: /* Return t if a call to `read-file-name' will use a dialog. The return value is only relevant for a call to `read-file-name' that happens -before any other event (mouse or keypress) is handled. */ - attributes: const) +before any other event (mouse or keypress) is handled. */) (void) { - return next_read_file_uses_dialog_p () ? Qt : Qnil; +#if (defined USE_GTK || defined USE_MOTIF \ + || defined HAVE_NS || defined HAVE_NTGUI) + if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) + && use_dialog_box + && use_file_dialog + && window_system_available (SELECTED_FRAME ())) + return Qt; +#endif + return Qnil; } void -- 2.39.2