all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Dmitry Antipov <dmantipov@yandex.ru>,
	Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: #2 [Was: Re: Function attributes for make-docfile]
Date: Tue, 13 Jan 2015 15:26:09 -0800	[thread overview]
Message-ID: <54B5A991.8010509@cs.ucla.edu> (raw)
In-Reply-To: <jwv387e4g9b.fsf-monnier+emacs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 354 bytes --]

On 01/13/2015 11:45 AM, Stefan Monnier wrote:
> IOW it is*not*  a const function.

To fix this I installed the attached patch as master commit 
785adfcc8dee02ac544f80e4f7f8d3d5b2965981 
<http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=785adfcc8dee02ac544f80e4f7f8d3d5b2965981>. 
It's not pretty, but at least we're no longer lying to the compiler.

[-- Attachment #2: 0001-Don-t-say-Fnext_read_file_uses_dialog_p-is-const.patch --]
[-- Type: text/x-patch, Size: 4621 bytes --]

From c020d2f7eee565616dff21e9d22b3200a4d5debf Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
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 969aac8..e9205fd 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,9 @@
+2015-01-13  Paul Eggert  <eggert@cs.ucla.edu>
+
+	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  <dmantipov@yandex.ru>
 
 	Support DEFUN attributes.
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index 79d421a..741fa4b 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 7ec6980..8d05ec1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,16 @@
 2015-01-13  Paul Eggert  <eggert@cs.ucla.edu>
 
+	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 45a31c0..6c443c9 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.1.0


  reply	other threads:[~2015-01-13 23:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12  4:09 Function attributes for make-docfile Dmitry Antipov
2015-01-12  5:33 ` Stefan Monnier
2015-01-12  5:49 ` Paul Eggert
2015-01-12 12:28   ` #2 [Was: Re: Function attributes for make-docfile] Dmitry Antipov
2015-01-13  7:29     ` Paul Eggert
2015-01-13 10:21       ` Dmitry Antipov
2015-01-13 17:43         ` Paul Eggert
2015-01-13 19:45       ` Stefan Monnier
2015-01-13 23:26         ` Paul Eggert [this message]
2015-01-14 17:49           ` Stefan Monnier
2015-01-14 19:44             ` Paul Eggert
2015-01-15  3:27               ` Dmitry Antipov
2015-01-15  3:54                 ` Dmitry Antipov
2015-01-15  5:33               ` Stefan Monnier
2015-01-16  4:50                 ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54B5A991.8010509@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=dmantipov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.