* Latest EMACS on BZR trunk does not compile with MinGW @ 2014-06-03 20:00 Vincent Belaïche 2014-06-03 20:22 ` Paul Eggert 2014-06-03 21:14 ` Latest EMACS on BZR trunk does not compile with MinGW Eli Zaretskii 0 siblings, 2 replies; 38+ messages in thread From: Vincent Belaïche @ 2014-06-03 20:00 UTC (permalink / raw) To: EMACS devel list Here is what I get: dup2.c:35:0: warning: "WIN32_LEAN_AND_MEAN" redefined [enabled by default] c:/Programme/GNU/installation/emacs-install/emacs/trunk/nt/inc/ms-w32.h:148:0: note: this is the location of the previous definition dup2.c:38:26: fatal error: msvc-inval.h: No such file or directory compilation terminated. msvc-inval.h, given its naming, is probably a file from the MS Visual C compiler suite, it seems that it is not available with MinGW --- at least with the version of the gcc suite installed on my machine. Here is the problematic piece of code from dup2.c: ----------------------------------------------------------------------- # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Get declarations of the native Windows API functions. */ # define WIN32_LEAN_AND_MEAN # include <windows.h> # include "msvc-inval.h" /* Get _get_osfhandle. */ # include "msvc-nothrow.h" static int ms_windows_dup2 (int fd, int desired_fd) { int result; /* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open, dup2 (fd, fd) returns 0, but all further attempts to use fd in future dup2 calls will hang. */ if (fd == desired_fd) { if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE) { errno = EBADF; return -1; } return fd; } /* Wine 1.0.1 return 0 when desired_fd is negative but not -1: http://bugs.winehq.org/show_bug.cgi?id=21289 */ if (desired_fd < 0) { errno = EBADF; return -1; } TRY_MSVC_INVAL { result = dup2 (fd, desired_fd); } CATCH_MSVC_INVAL { errno = EBADF; result = -1; } DONE_MSVC_INVAL; if (result == 0) result = desired_fd; return result; } # define dup2 ms_windows_dup2 # endif ----------------------------------------------------------------------- Maybe the `&& ! defined __CYGWIN__' wherever used in this file for this topic should be replaced by `&& defined _MSC_VER' or something like that --- I cannot remember exactly the #definition that one can use to detect MSVC compiler. An alternative would be to use `&& ! defined __CYGWIN__ && ! defined __MINGW32__' but well, if the msvc_xxx.h file are MSVC specific, I would prefer the other one. VBR, Vincent. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-03 20:00 Latest EMACS on BZR trunk does not compile with MinGW Vincent Belaïche @ 2014-06-03 20:22 ` Paul Eggert 2014-06-03 20:56 ` Óscar Fuentes 2014-06-03 21:15 ` Eli Zaretskii 2014-06-03 21:14 ` Latest EMACS on BZR trunk does not compile with MinGW Eli Zaretskii 1 sibling, 2 replies; 38+ messages in thread From: Paul Eggert @ 2014-06-03 20:22 UTC (permalink / raw) To: Vincent Belaïche, EMACS devel list [-- Attachment #1: Type: text/plain, Size: 516 bytes --] On 06/03/2014 01:00 PM, Vincent Belaïche wrote: > dup2.c:35:0: warning: "WIN32_LEAN_AND_MEAN" redefined [enabled by default] Why is your build trying to compile lib/dup2.c? That appears to be the real bug here. Emacs is supposed to supply its own dup2 on Microsoft Windows, and the build shouldn't try to compile the Gnulib dup2.c there. > msvc-inval.h, given its naming, is probably a file from the MS Visual C > compiler suite No, it's from Gnulib. It's a part of Gnulib that Emacs is not using. [-- Attachment #2: ms.diff --] [-- Type: text/x-patch, Size: 281 bytes --] === modified file 'nt/inc/ms-w32.h' --- nt/inc/ms-w32.h 2014-05-27 17:31:17 +0000 +++ nt/inc/ms-w32.h 2014-06-03 20:13:15 +0000 @@ -145,7 +145,7 @@ #endif /* Make a leaner executable. */ -#define WIN32_LEAN_AND_MEAN 1 +#define WIN32_LEAN_AND_MEAN #include <sys/types.h> ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-03 20:22 ` Paul Eggert @ 2014-06-03 20:56 ` Óscar Fuentes 2014-06-03 21:15 ` Eli Zaretskii 1 sibling, 0 replies; 38+ messages in thread From: Óscar Fuentes @ 2014-06-03 20:56 UTC (permalink / raw) To: Paul Eggert; +Cc: Vincent Belaïche, EMACS devel list Paul Eggert <eggert@cs.ucla.edu> writes: > On 06/03/2014 01:00 PM, Vincent Belaïche wrote: >> dup2.c:35:0: warning: "WIN32_LEAN_AND_MEAN" redefined [enabled by default] > Why is your build trying to compile lib/dup2.c? That appears to be > the real bug here. Emacs is supposed to supply its own dup2 on > Microsoft Windows, and the build shouldn't try to compile the Gnulib > dup2.c there. Maybe it is related to this: http://lists.gnu.org/archive/html/emacs-devel/2014-05/msg00083.html Check that the MSYSTEM environment variable has the value "MINGW32" on the shell you run the configure script. [snip] ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-03 20:22 ` Paul Eggert 2014-06-03 20:56 ` Óscar Fuentes @ 2014-06-03 21:15 ` Eli Zaretskii 2014-06-03 21:21 ` Vincent Belaïche 2014-06-04 12:22 ` Using Qunsupported__w32_dialog Dmitry Antipov 1 sibling, 2 replies; 38+ messages in thread From: Eli Zaretskii @ 2014-06-03 21:15 UTC (permalink / raw) To: Paul Eggert; +Cc: vincent.b.1, emacs-devel > Date: Tue, 03 Jun 2014 13:22:40 -0700 > From: Paul Eggert <eggert@cs.ucla.edu> > > On 06/03/2014 01:00 PM, Vincent Belaïche wrote: > > dup2.c:35:0: warning: "WIN32_LEAN_AND_MEAN" redefined [enabled by default] > Why is your build trying to compile lib/dup2.c? That appears to be the > real bug here. Emacs is supposed to supply its own dup2 on Microsoft > Windows, and the build shouldn't try to compile the Gnulib dup2.c there. Right. ^ permalink raw reply [flat|nested] 38+ messages in thread
* RE: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-03 21:15 ` Eli Zaretskii @ 2014-06-03 21:21 ` Vincent Belaïche 2014-06-04 6:47 ` Eli Zaretskii 2014-06-04 12:22 ` Using Qunsupported__w32_dialog Dmitry Antipov 1 sibling, 1 reply; 38+ messages in thread From: Vincent Belaïche @ 2014-06-03 21:21 UTC (permalink / raw) To: Eli Zaretskii, Paul Eggert; +Cc: emacs-devel Yep, MSYSTEM was simply not defined under my MSYS shell, I will add that. Thanks. Vincent. ---------------------------------------- > Date: Wed, 4 Jun 2014 00:15:11 +0300 > From: eliz@gnu.org > Subject: Re: Latest EMACS on BZR trunk does not compile with MinGW > To: eggert@cs.ucla.edu > CC: vincent.b.1@hotmail.fr; emacs-devel@gnu.org > >> Date: Tue, 03 Jun 2014 13:22:40 -0700 >> From: Paul Eggert <eggert@cs.ucla.edu> >> >> On 06/03/2014 01:00 PM, Vincent Belaïche wrote: >>> dup2.c:35:0: warning: "WIN32_LEAN_AND_MEAN" redefined [enabled by default] >> Why is your build trying to compile lib/dup2.c? That appears to be the >> real bug here. Emacs is supposed to supply its own dup2 on Microsoft >> Windows, and the build shouldn't try to compile the Gnulib dup2.c there. > > Right. > > ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-03 21:21 ` Vincent Belaïche @ 2014-06-04 6:47 ` Eli Zaretskii 2014-06-04 13:17 ` Vincent Belaïche 0 siblings, 1 reply; 38+ messages in thread From: Eli Zaretskii @ 2014-06-04 6:47 UTC (permalink / raw) To: Vincent Belaïche; +Cc: eggert, emacs-devel > From: Vincent Belaïche <vincent.b.1@hotmail.fr> > CC: emacs-devel <emacs-devel@gnu.org> > Date: Tue, 3 Jun 2014 23:21:19 +0200 > > Yep, MSYSTEM was simply not defined under my MSYS shell How did that happen? Did you edit your MSYS etc/profile file? ^ permalink raw reply [flat|nested] 38+ messages in thread
* RE: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-04 6:47 ` Eli Zaretskii @ 2014-06-04 13:17 ` Vincent Belaïche 2014-06-04 13:31 ` Eli Zaretskii 0 siblings, 1 reply; 38+ messages in thread From: Vincent Belaïche @ 2014-06-04 13:17 UTC (permalink / raw) To: Eli Zaretskii; +Cc: eggert@cs.ucla.edu, emacs-devel No, not to my recollection. Please not that I have also a ~/.bash_profile file. It seems that neither it, nor /etc/profile are loaded by rxvt or sh on my machine. Also in the /etc/profile, the relevant code is if [ -z "$MSYSTEM" ]; then MSYSTEM=MINGW32 fi shouldn't it be with export, ie if [ -z "$MSYSTEM" ]; then export MSYSTEM=MINGW32 fi Or maybe somewhere MSYSTEM variable is already tagged as exported. Anyway, although my build is not yet complete, it seems that already it went beyond what has happened. Vincent. ---------------------------------------- > Date: Wed, 4 Jun 2014 09:47:34 +0300 > From: eliz@gnu.org > Subject: Re: Latest EMACS on BZR trunk does not compile with MinGW > To: vincent.b.1@hotmail.fr > CC: eggert@cs.ucla.edu; emacs-devel@gnu.org > >> From: Vincent Belaïche <vincent.b.1@hotmail.fr> >> CC: emacs-devel <emacs-devel@gnu.org> >> Date: Tue, 3 Jun 2014 23:21:19 +0200 >> >> Yep, MSYSTEM was simply not defined under my MSYS shell > > How did that happen? Did you edit your MSYS etc/profile file? > > > ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-04 13:17 ` Vincent Belaïche @ 2014-06-04 13:31 ` Eli Zaretskii 2014-06-04 15:28 ` Vincent Belaïche 0 siblings, 1 reply; 38+ messages in thread From: Eli Zaretskii @ 2014-06-04 13:31 UTC (permalink / raw) To: Vincent Belaïche; +Cc: eggert, emacs-devel > From: Vincent Belaïche <vincent.b.1@hotmail.fr> > CC: "eggert@cs.ucla.edu" <eggert@cs.ucla.edu>, emacs-devel > <emacs-devel@gnu.org> > Date: Wed, 4 Jun 2014 15:17:38 +0200 > > Please not that I have also a ~/.bash_profile file. It seems that neither it, nor /etc/profile are loaded by rxvt or sh on my machine. How do you invoke the MSYS Bash? If you use a desktop shortcut to start a Bash window, then what do you have in the "Target" field of that shortcut's Properties/Shortcut tab? > Also in the /etc/profile, the relevant code is > > if [ -z "$MSYSTEM" ]; then > MSYSTEM=MINGW32 > fi > > > shouldn't it be with export, ie > > if [ -z "$MSYSTEM" ]; then > export MSYSTEM=MINGW32 > fi > > Or maybe somewhere MSYSTEM variable is already tagged as exported. It is, right at the end of etc/profile: export HOME LOGNAME MSYSTEM HISTFILE ^ permalink raw reply [flat|nested] 38+ messages in thread
* RE: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-04 13:31 ` Eli Zaretskii @ 2014-06-04 15:28 ` Vincent Belaïche 2014-06-04 15:44 ` Eli Zaretskii 0 siblings, 1 reply; 38+ messages in thread From: Vincent Belaïche @ 2014-06-04 15:28 UTC (permalink / raw) To: Eli Zaretskii; +Cc: eggert@cs.ucla.edu, emacs-devel [-- Attachment #1: Type: text/plain, Size: 2110 bytes --] Hello, In fact what I have is that /etc/profile is not sourced, but ~/.bash_profile is sourced. Well, it is certainly a standard bash behaviour that when you have a ~/.bash_profile then /etc/profile is ignored, my mistake is that there should have been a source /etc/profile at the beginning of my ~/.bash_profile. FYI I invoke bash by the `M-x bash' command defined in the attached w32utils.el package. Variable w32utils-shell-file-name is set to C:/msys/1.0/bin/bash In a nutshell, I just use the standard `shell' function, but instead of calling it interactively it is called by 'M-x bash' where the shell-file-name variable is (let (...)) to be "C:/msys/1.0/bin/bash". That allows me to use bash with 'Mx bash' in a *bash* buffer under MSWindows just like people use bash with 'Mx shell' in a *shell* buffer under *nix. So I can enjoy all the fine EMACS shell buffer features for bash. Vincent. ---------------------------------------- > Date: Wed, 4 Jun 2014 16:31:22 +0300 > From: eliz@gnu.org > Subject: Re: Latest EMACS on BZR trunk does not compile with MinGW > To: vincent.b.1@hotmail.fr > CC: eggert@cs.ucla.edu; emacs-devel@gnu.org > >> From: Vincent Belaïche <vincent.b.1@hotmail.fr> >> CC: "eggert@cs.ucla.edu" <eggert@cs.ucla.edu>, emacs-devel >> <emacs-devel@gnu.org> >> Date: Wed, 4 Jun 2014 15:17:38 +0200 >> >> Please not that I have also a ~/.bash_profile file. It seems that neither it, nor /etc/profile are loaded by rxvt or sh on my machine. > > How do you invoke the MSYS Bash? If you use a desktop shortcut to > start a Bash window, then what do you have in the "Target" field of > that shortcut's Properties/Shortcut tab? > >> Also in the /etc/profile, the relevant code is >> >> if [ -z "$MSYSTEM" ]; then >> MSYSTEM=MINGW32 >> fi >> >> >> shouldn't it be with export, ie >> >> if [ -z "$MSYSTEM" ]; then >> export MSYSTEM=MINGW32 >> fi >> >> Or maybe somewhere MSYSTEM variable is already tagged as exported. > > It is, right at the end of etc/profile: > > export HOME LOGNAME MSYSTEM HISTFILE > > [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: w32utils.el --] [-- Type: text/x-script.elisp, Size: 42734 bytes --] ;; w32utils.el --- -*- coding: iso-8859-1-unix -*- ;; Copyright 2009 Vincent Belaïche ;; ;; Author: Vincent Belaïche <vincent.b.1@hotmail.fr> ;; Version: $Id: w32utils.el,v 0.0 2009/03/22 10:39:33 Vincent Exp $ ;; Keywords: ;; X-URL: not distributed yet ;; ;; This software is governed by the CeCILL license under French law and ;; abiding by the rules of distribution of free software. You can use, ;; modify and/ or redistribute the software under the terms of the CeCILL ;; license as circulated by CEA, CNRS and INRIA at the following URL ;; "http://www.cecill.info". ;; ;; As a counterpart to the access to the source code and rights to copy, ;; modify and redistribute granted by the license, users are provided only ;; with a limited warranty and the software's author, the holder of the ;; economic rights, and the successive licensors have only limited ;; liability. ;; ;; In this respect, the user's attention is drawn to the risks associated ;; with loading, using, modifying and/or developing or reproducing the ;; software by the user in light of its specific status of free software, ;; that may mean that it is complicated to manipulate, and that also ;; therefore means that it is reserved for developers and experienced ;; professionals having in-depth computer knowledge. Users are therefore ;; encouraged to load and test the software's suitability as regards their ;; requirements in conditions enabling the security of their systems and/or ;; data to be ensured and, more generally, to use and operate it in the ;; same conditions as regards security. ;; ;; The fact that you are presently reading this means that you have had ;; knowledge of the CeCILL license and that you accept its terms. ;; ;;; Commentary: ;; ;; Put this file into your load-path and the following into your ~/.emacs: ;; (require 'w32utils) ;;; Code: (provide 'w32utils) (declare-function message-fetch-field "message" (header &optional not-all)) (declare-function mml-parse "mml" ) \f ;;;;########################################################################## ;;;; User Options, Variables ;;;;########################################################################## (defgroup w32utils nil "Customization of w32utils package" :group 'emacs) (defgroup w32utils-paths nil "Customization of w32utils package for manipulating paths" :group 'w32utils) (defgroup w32utils-urls nil "Customization of w32utils package for manipulating URL" :group 'w32utils) (defgroup w32utils-bash nil "Customization of w32utils package for using MSYS bash under MSWindows." :group 'w32utils) (defgroup w32utils-ms-outlook-send nil "Personnalistion du paquet w32utils pour envoyer des courrier avec MS-Outlook." :group 'w32utils) (defcustom w32utils-bash-home (concat "C:/msys/1.0/home/" (user-login-name) "/") "Répertoire de domiciliation de bash." :type 'directory :group 'w32utils-bash :set (lambda (var val) (set-default var val) (setenv "ENV" (concat val ".bash_profile"))) ) (defcustom w32utils-shell-file-name "C:/msys/1.0/bin/bash" "File that holds the bash shell program." :type 'file :group 'w32utils-bash ) (defcustom w32utils-shell-buffer-name "*bash*" "Name of buffers for bash shell mode." :type 'string :group 'w32utils-bash ) (defcustom w32utils-process-coding-system 'windows-1252-unix "Coding system used to communicate with bash." :type '(choice (const :tag "Disable `w32utils-process-coding-scheme',\ coding scheme will be based on\ `process-coding-system-alist'" nil) (coding-system :tag "Specify coding system for\ encoding to and decoding from bash") (cons :tag "Specify coding system for decoding from\ bash" coding-system :tag "Specify coding system for encoding to bash" coding-system)) :group 'w32utils-bash ) (defcustom w32utils-drives nil "List of association of drive letter to drive path" :type '(repeat (cons (character :tag "Drive letter: ") (directory :tag "Drive network path: ")) ) :group 'w32utils-paths ) (defcustom w32utils-add-suffix nil "Surcharche la variable `comint-completion-addsuffix'" :type '(choice (const :tag "Utiliser la variable `comint-completion-addsuffix'" nil) (const :tag "Ajouter /" t) (cons :tag "Paire de suffixe" (string :tag "Suffixe pour Répertoire") (string :tag "Suffixe pour Fichier")) ) :group 'w32utils-path ) (defcustom w32utils-ms-outlook-temp-dir (let ((fn (or (getenv "TEMP") (getenv "TMP")))) (and (stringp fn) (file-name-as-directory fn))) "Chemin du répertoire où sont stockés les script VBScript servant à l'envoi des courriels via MSOutlook." :type 'directory :group 'w32utils-ms-outlook-send) (defvar w32utilis-ms-outlook-send-nb -1 "Numéro détrompeur entre plusieurs script VBScript") (defcustom w32utils-ms-outlook-action :display "Sélectionne l'action à faire sur les messages Outlook: afficher et laisser l'utilisateur cliquer sur envoi, ou bien envoyer directement." :type '(choice (const :tag "Afficher sans envoyer" :display) (const :tag "Envoyer" :display)) :group 'w32utils-ms-outlook-send) (defcustom w32utils-ms-outlook-format :plain "Selectionne le format du courrier envoyé. Note: ceci n'entraine pas d'exportation au format HTML du corps du message." :type '(choice (const :tag "Texte brut" :plain) (const :tag "HTML" :html)) :group 'w32utils-ms-outlook-send) ;; settings for MinGW (setenv "ENV" (concat w32utils-bash-home ".bash_profile")) (defun w32utils-get-os-type (&optional force-os) (cond ((natnump force-os) (cond ((= force-os 0) 'dos) ((= force-os 1) 'bash) (t nil))) ((string-match "\\(/sh\\|/bash\\)" cur-proc-n) 'bash) ((string-match "\\(/cmdproxy.exe\\)" cur-proc-n) 'dos) (t nil))) (defun w32utils-refresh-default-directory (&optional force-os) "Resynchronise the variable `default-directory' when it is not longer in line with the current directory, so that completion works well again. Maybe invoked by `\\[w32utils-refresh-default-directory]'. Current OS (bash or dos) is detected automatically based on the process command associated to the buffer. This works in most cases, unless you start a subshell explicitely (e.g. type sh.exe in a dos console). In such a case the argument FORCE-OS can be used to force the os detection as follows: 0 => DOS 1 => BASH " (interactive "P") (let* (cmd-pwd-send-point ; point du tampon où la commande pwd est envoyée ;(p (point)) (cur-proc (get-buffer-process (current-buffer))) (cur-filter (process-filter cur-proc)) (cur-proc-n (car (process-command cur-proc))) proc-output-string; to save the the output of command providing current directory (os-type (w32utils-get-os-type force-os)) cur-cmd (msg (concat (symbol-name os-type) " refresh default directory ...")) cmd-start cmd-point-offset (cmd-pwd (cond ((eq os-type 'bash) "pwd -W\n") ((eq os-type 'dos) "echo \"%CD%\"\n") (t nil))); ) (unless cur-proc (error "Current buffer has no process")) (unless os-type (error "Can't detect OS type")) ;; get start of cmd under edition, if any (save-excursion (cond ((and (boundp 'comint-last-prompt-overlay) (overlayp comint-last-prompt-overlay)) (setq cmd-start (overlay-end comint-last-prompt-overlay))) (t (beginning-of-line) (setq cmd-start (point))))) ;; save command under edition (when cmd-start (setq cmd-pwd-send-point (point)) (let ((pm (point-max))) (goto-char pm) (setq cmd-point-offset (- pm cmd-pwd-send-point)) (setq cur-cmd (buffer-substring cmd-start pm)) (delete-region cmd-start pm))) ;; run pwd | sed to get actual current directory (message msg) (message "sending >%s" cmd-pwd) (set-process-filter cur-proc (lambda (proc output-str) (message "coucou!=>%s<=" output-str) ;; cas du DOS, le processus renvoie trois lignes ;; ligne 1 : l'écho de la commande ;; ligne 2 : la réponse (ce qu'on veut) ;; ligne 3 : l'invite (prompt) ;; cas de BASH, le processus ne renvoie que les lignes 2 et 3 (setq proc-output-string (nth (cond ((eq os-type 'dos) 1) ((eq os-type 'bash) 0)) (split-string output-str "[\n\r]+"))) (and cur-filter (funcall cur-filter proc output-str)))) (comint-send-string cur-proc cmd-pwd) ;; get output and evaluate expression if any (cond ((accept-process-output cur-proc 1) (set-process-filter cur-proc cur-filter); restore filter. (if (and proc-output-string (progn ;; élimine les guillemets anglais, s'il y en a. (when (and (eq os-type 'dos) (string-match "\\`\"\\(.+\\)\"\\'" proc-output-string)) (setq proc-output-string (match-string 1 proc-output-string))) (null (string= proc-output-string "")))) (progn (cd (file-name-as-directory proc-output-string)) (message "%s done" msg)) (message "%s failed" msg))) (t (message "%s timed out" msg))) ;; restore command under edition if any (when cur-cmd (insert cur-cmd) (goto-char (- (point) cmd-point-offset))))) (defun bash (&optional buffer) "Create a new bash buffer or activate any existing one. A prefix argument forces creation of a new buffer." (interactive (list (and current-prefix-arg (read-buffer "Shell buffer: " (generate-new-buffer-name w32utils-shell-buffer-name))))) (let ((shell-file-name w32utils-shell-file-name)) (shell (or buffer w32utils-shell-buffer-name))) (when w32utils-add-suffix (set (make-local-variable 'comint-completion-addsuffix) w32utils-add-suffix)) (when w32utils-process-coding-system (set-buffer-process-coding-system (cond ((symbolp w32utils-process-coding-system) w32utils-process-coding-system) ((consp w32utils-process-coding-system) (car w32utils-process-coding-system))) (cond ((symbolp w32utils-process-coding-system) w32utils-process-coding-system) ((consp w32utils-process-coding-system) (cdr w32utils-process-coding-system)))))) (defun w32utils-shell-mode-hook () (define-key shell-mode-map (kbd "C-x g") 'w32utils-refresh-default-directory ) ) (add-hook 'shell-mode-hook 'w32utils-shell-mode-hook) ;;;============================================================================ ;;; Filename conversion ;;;============================================================================ (defun w32utils-latex-url-text-type-quote (x) (let ((pos0 0) pos) (while (setq pos (string-match "[#\\_%]" x pos0)) (setq x (replace-match (concat "\\" (match-string 0 x)) t t x) pos0 (+ 2 pos)))) x) (defcustom w32utils-latex-url-text-quote-function 'w32utils-latex-url-text-type-quote "Function for quoting text of LaTeX URLs." :type 'function :group 'w32utils-urls) (defun w32utils-org-url-text-type-quote (x) (let ((pos0 0) pos) (while (setq pos (string-match "[*\\_]" x pos0)) (setq x (replace-match (concat "\\" (match-string 0 x)) t t x) pos0 (+ 2 pos)))) x) (defcustom w32utils-org-url-text-quote-function 'w32utils-org-url-text-type-quote "Function for quoting text of Org mode URLs." :type 'function :group 'w32utils-urls) (defun w32utils-html-url-text-type-quote (x) (save-match-data (let ((pos0 0) pos (replace-al '((?& . "amp") (?< . "lt") (?> . "gt"))) replacement ) (while (setq pos (string-match "[&<>]" x pos0)) (setq replacement (assq (aref (match-string 0 x) 0) replace-al) x (replace-match (concat "&" replacement ";" ) t t x) pos0 (+ pos 2 (length replacement)))))) x) (defcustom w32utils-html-url-text-quote-function 'w32utils-html-url-text-type-quote "Function for quoting text of HTML mode URLs." :type 'function :group 'w32utils-urls) (defcustom w32utils-link-prefix-overload nil "List of cons cells (PREFIX . OVERLOAD), where PREFIX and OVERLOAD are strings such that any URL generated by function `w32utils-/-to-\\' prefixed by PREFIX has PREFIX replaced by OVERLOAD." :type '(repeat (cons (string :tag "Prefix") (string :tag "Overload"))) :group 'w32utils-paths) (defvar w32utils-old-expand-file-name nil) (unless (functionp 'w32utils-old-expand-file-name) (fset 'w32utils-old-expand-file-name (symbol-function 'expand-file-name))) (defcustom w32utils-msys-base-directory (let ((msys (getenv "MSYS"))) (and msys (file-name-as-directory (w32utils-old-expand-file-name msys)))) "Répertoire de base de MSYS, sous lequel on trouve `bin' et `etc'. Défini par défaut au contenu de la variable d'environnement MSYS." :group 'w32utils-paths) (defvar w32utils-msys-fstab-cache [ nil nil] "Résultat de l'analyse du fichier fstab de MSYS. L'élément 0 est la date de dernière modification du fichier. L'élément 1 est un liste d'élément E où \(car E) est un entier N donnant une longueur de chemin, et \(cdr E) est une liste d'association dont chaque élement est de la forme (K . V), ou K est un chemin au format Linux de longueur N, et V est le chemin correspondant dans MSWindows.") (defun w32utils-refresh-msys-fstab-cache (&optional force-refresh ignore-errors) ;; quelque vérification (let (fstab (line-nb 0) cell-list by-len-list (l 0) next-by-len cell) (cond ((null w32utils-msys-base-directory) (unless ignore-errors (error "L'analyse de MSYS fstab est impossible car `w32utils-msys-base-directory' n'est pas défini."))) ((null (file-directory-p w32utils-msys-base-directory)) (unless ignore-errors (error "L'analyse de MSYS fstab est impossible car `w32utils-msys-base-directory' ne pointe pas sur sur un répertoire."))) ((null (file-exists-p (setq fstab (concat w32utils-msys-base-directory "etc/fstab")))) (unless ignore-errors (error "L'analyse de MSYS fstab est impossible car `w32utils-msys-base-directory' ne pointe pas sur sur un répertoire."))) ((and (null force-refresh) (equal (aref w32utils-msys-fstab-cache 0) (nth 5 (file-attributes fstab))))) (t (with-temp-buffer (insert-file-contents fstab) (goto-char (point-min)) (while (null (eobp)) (setq line-nb (1+ line-nb)) (cond ((looking-at "^\\s-*#")) ((looking-at "^\\s-*$")) (t (looking-at "\\s-*") (goto-char (match-end 0)) (cl-flet ((read-string () (let (ret) (while (progn (cond ((looking-at "\"\\([^\"]*\\)\"") (push (match-string-no-properties 1) ret) (goto-char (match-end 0))) ((looking-at "'\\([^']*\\)'") (push (match-string-no-properties 1) ret) (goto-char (match-end 0))) ((looking-at "[^ \t\n\r]+") (push (match-string-no-properties 0) ret) (goto-char (match-end 0))) (t nil)))) (apply 'concat (nreverse ret))))) (let (s1 s2) (if (and (setq s1 (read-string)) (> (length s1) 0) (looking-at "\\s-+") (setq s2 (progn (goto-char (match-end 0)) (read-string))) (> (length s2) 0)) (push (cons s2 s1) cell-list) (or ignore-errors (error "%s:%d: Ligne incorrecte %s" fstab line-nb (progn (beginning-of-line) (buffer-substring (point) (progn (end-of-line) (point))))))))))) (beginning-of-line 2))) ;; Ajout des associations prédéfinies (let ((builtin-fstab '(("/bin" . "bin") ("/usr/bin" . "bin") ("/temp" . "temp") ("/etc" . "etc"))) builtin-fstab-cell temp) (setq builtin-fstab (mapcar (lambda (x) (cons (car x) (concat w32utils-msys-base-directory (cdr x)))) builtin-fstab)) (when (setq tmp (getenv "TEMP")) (push (cons "/tmp" (substring (file-name-as-directory tmp) 0 -1)) builtin-fstab)) (while builtin-fstab (setq builtin-fstab-cell (pop builtin-fstab)) (unless (setq cell (assoc-string (car builtin-fstab-cell) cell-list)) (push builtin-fstab-cell cell-list))) ) ;; tri par longueur de chaîne (setq cell-list (sort cell-list (lambda (x y) (< (length (car x)) (length (car y)))))) (while cell-list (setq cell (pop cell-list)) (when (> (length (car cell)) l) (and next-by-len (push (cons l next-by-len) by-len-list)) (setq next-by-len nil l (length (car cell)))) (push cell next-by-len)) (and next-by-len (push (cons l next-by-len) by-len-list)) (aset w32utils-msys-fstab-cache 0 (nth 5 (file-attributes fstab))) (aset w32utils-msys-fstab-cache 1 (nreverse by-len-list)))))) (w32utils-refresh-msys-fstab-cache) (defun w32utils-new-expand-file-name (name &optional default-directory) (save-match-data (cl-flet ((msys-expand-file-name (name) (let (new-name by-len-list alist l cell) (if (string-match "\\`\\(/\\([a-z]\\)\\)\\(/\\|\\'\\)" name) (setq new-name (replace-match (concat (match-string-no-properties 2 name) ":") t t name 1))) (setq by-len-list (aref w32utils-msys-fstab-cache 1)) (while (and by-len-list (null new-name)) (setq alist (pop by-len-list)) (if (> (setq l (pop alist)) (length name)) (setq by-len-list nil) ; casse la boucle (and (or (= l (length name)) (= ?/ (aref name l))) (setq cell (assoc-string (substring name 0 l) alist)) (setq new-name (concat (cdr cell) (substring name l)) by-len-list nil)))) new-name))) (or (msys-expand-file-name name) (and (stringp default-directory) (msys-expand-file-name (concat (file-name-as-directory default-directory) name))) (w32utils-old-expand-file-name name default-directory))))) (defcustom w32utils-overload-expand-file-name nil "Booléen, mettre à `t' pour que `expand-file-name' soit surchargé pour prendre en charge les chemin MSYS. Voir la fonction `w32utils-new-expand-file-name'." :type 'boolean :set (lambda (var val) (set-default var val) (fset 'expand-file-name (symbol-function (if val 'w32utils-new-expand-file-name 'w32utils-old-expand-file-name)))) :group 'w32utils) (defconst w32utils-url-presentation-text-type-customization-type '(radio (const basename) (const basename-sans-extension) (const dirname+basename) (list (const user-defined) string)) "Customization time for url presentation text type.") (defcustom w32utils-latex-url-presentation-text-type '(user-defined "link") "Defines how a link is presented. " :type w32utils-url-presentation-text-type-customization-type :group 'w32utils-urls) (defcustom w32utils-org-url-presentation-text-type '(user-defined "link") "Defines how a link is presented in Org mode. " :type w32utils-url-presentation-text-type-customization-type :group 'w32utils-urls) (defcustom w32utils-html-url-presentation-text-type '(user-defined "link") "Defines how a link is presented in HTML. " :type w32utils-url-presentation-text-type-customization-type :group 'w32utils-urls) (defvar w32utils-dired-buffer nil "Variable to dired buffer from which w32utils-filename-org is to be provided." ) (defvar w32utils-filename-org nil "Variable set to to filename to be converted locally to a w32utils filename conversion buffer." ) (defvar w32utils-filename-dest nil "Variable set to filename to be converted locally to a w32utils filename conversion buffer." ) (defvar w32utils-filename-conv-display-end-mark nil "Variable set to a mark that is end of display zone in w32bask filename conversion buffer." ) (defvar w32utils-quit-handler nil "Action performed when the filename conversion buffer is quitted" ) (defvar w32utils-filename-concat-comma nil "Comma separator, to be redefined locally to filename conversion buffer." ) (defun w32utils-get-drive (drive) (cdr-safe (assq drive w32utils-drives))) (defun w32utils-filename-conv-check-buffer (arg &optional ignore-dired-is-dead) (cond ((null arg) (setq arg 0)) ((eq arg '-) (setq arg nil))) (cond ((bufferp w32utils-dired-buffer) (unless (or ignore-dired-is-dead (buffer-live-p w32utils-dired-buffer)) (error "Pointed at Dired buffer is no longer alive.")) (unless w32utils-filename-dest (set (make-local-variable 'w32utils-filename-dest) nil)) (set (make-local-variable 'w32utils-filename-org) (with-current-buffer w32utils-dired-buffer (if arg (cond ((zerop (prefix-numeric-value arg)) (dired-get-marked-files)) ((consp arg) (dired-get-marked-files t)) (t (dired-get-marked-files 'no-dir (prefix-numeric-value arg)))) (dired-get-marked-files 'no-dir))))) ((consp w32utils-filename-org) ;; do nothing ) (t (error "Not in filename conversion buffer")))) (defun w32utils-filename-to-string (&optional arg) "Convert a filename to a \\ separated string, add a final `\\' if the filename is a directory." (interactive "P") (w32utils-filename-conv-check-buffer arg) (dolist (v w32utils-filename-org) (when (file-directory-p v) (setq v (concat v "/"))) (push (mapconcat 'identity (split-string v "/") "\\") w32utils-filename-dest)) (setq w32utils-filename-dest (nreverse w32utils-filename-dest))) (defun w32utils-filename-to-c-string (&optional arg) "Convert a filename a \\\\ separated string" (interactive "P") (w32utils-filename-conv-check-buffer arg) (dolist (v w32utils-filename-org) (push (mapconcat 'identity (split-string v "/") "\\\\") w32utils-filename-dest)) (setq w32utils-filename-dest (nreverse w32utils-filename-dest))) (defun w32utils-filename-to-url (&optional arg) "Convert a filename to an URL." (interactive "P") (w32utils-filename-conv-check-buffer arg) (let* ((to-xdigit (lambda (x) (if (< x 10) (+ ?0 x) (+ 55 x) ))) host) (dolist (v w32utils-filename-org) (let (w) (setq w (apply 'string (apply 'append (mapcar (lambda (x) (if (or (<= x 31) (>= x 128) (memq x '( 32 34 35 36 37 38 43 44 ;47 58 59 60 61 62 63 64 91 92 93 94 96 123 124 125 126 ))) (list ?% (funcall to-xdigit (logand (/ (mod x 256) 16) 15)) (funcall to-xdigit (logand x 15))) (list x))) v)))) (if (and (string-match "\\`\\([A-Z]\\):/" v) (setq host (w32utils-get-drive (aref (match-string 1 v) 0)))) (setq w (substring w 5)) (setq host "//localhost/")) (setq w (concat "file:" host w)) (let ((l w32utils-link-prefix-overload) x prefix lenpfx (lenw (length w)) overload) (while l (setq x (car l) l (cdr l) prefix (car x) lenpfx (length prefix)) (when (and (>= lenw lenpfx) (string= (substring w 0 lenpfx) prefix)) (setq w (concat (cdr x) (substring w lenpfx)) l nil)))) (push w w32utils-filename-dest))) (setq w32utils-filename-dest (nreverse w32utils-filename-dest)))) (defun w32utils-filename-to-latex-url (&optional arg) "Convert filenames to a LaTeX URL based on hyperref package." (interactive "P") (w32utils-filename-to-url arg) (let ((ld w32utils-filename-dest) (lo w32utils-filename-org) e o (p 0) np) (while ld (setq e (car ld) o (car lo)) (while (setq p (string-match "\\([%#~]\\)" e p)) (setq e (replace-match "\\\\\\1" t nil e)) (setq p (+ 2 p))) (setq e (concat "\\href {" e "}{" (w32utils-make-url-text o w32utils-latex-url-presentation-text-type w32utils-latex-url-text-quote-function) "}")) (setcar ld e) (setq ld (cdr ld) lo (cdr lo)) ))) (defun w32utils-make-url-text (text text-type quotation-function) (cond ((eq text-type 'basename) (funcall quotation-function (file-name-nondirectory text))) ((eq text-type 'basename-sans-extension) (funcall quotation-function (file-name-sans-extension (file-name-nondirectory text)))) ((eq text-type 'dirname+basename) (funcall quotation-function text)) ((eq (car-safe text-type) 'user-defined) (cadr text-type)) (t ""))) (defun w32utils-filename-to-html-url (&optional arg) "Convert filenames to a HTML URL based." (interactive "P") (w32utils-filename-to-url arg) (let ((ld w32utils-filename-dest) (lo w32utils-filename-org) e o (p 0) np) (while ld (setq e (car ld) o (car lo)) (setq e (concat "<a href=\"" e "\">" (w32utils-make-url-text o w32utils-html-url-presentation-text-type w32utils-html-url-text-quote-function) "</a>")) (setcar ld e) (setq ld (cdr ld) lo (cdr lo)) ))) (defun w32utils-filename-to-org-url (&optional arg) "Convert filenames to a Org URL based on hyperref package." (interactive "P") (w32utils-filename-to-url arg) (let ((ld w32utils-filename-dest) (lo w32utils-filename-org) e o (p 0) np) (while ld (setq e (car ld) o (car lo)) (setq e (concat "[[" e "][" (w32utils-make-url-text o w32utils-org-url-presentation-text-type w32utils-org-url-text-quote-function) "]]")) (setcar ld e) (setq ld (cdr ld) lo (cdr lo)) ))) (defun w32utils-customize-url-text (symbol) "Customize the presentation text part for some mode URL (like LaTeX, Org, or HTML). symbol is the customization variable corresponding to the concerned mode." (customize-variable symbol) ) (defun w32utils-filename-quit-action () ) (defun w32utils-filename-quit-\; () (interactive) (setq w32utils-filename-concat-comma ";") (funcall w32utils-quit-handler)) (defun w32utils-filename-quit () "Convert a filename a \\\\ separated string" (interactive) (funcall w32utils-quit-handler)) (defconst w32utils-filename-conv-keymap (let ((km (make-sparse-keymap))) (define-key km [?C] 'w32utils-filename-to-c-string) (define-key km [?h] 'w32utils-filename-to-html-url) (define-key km [?l] 'w32utils-filename-to-latex-url) (define-key km [?o] 'w32utils-filename-to-org-url) (define-key km [?q] 'w32utils-filename-quit) (define-key km [?\;] 'w32utils-filename-quit-\;) (define-key km [?s] 'w32utils-filename-to-string) (define-key km [?u] 'w32utils-filename-to-url) (define-key km [?c] (let ((km (make-sparse-keymap))) (define-key km [?h] (lambda () (interactive) (w32utils-customize-url-text 'w32utils-html-url-presentation-text-type))) (define-key km [?l] (lambda () (interactive) (w32utils-customize-url-text 'w32utils-latex-url-presentation-text-type))) (define-key km [?o] (lambda () (interactive) (w32utils-customize-url-text 'w32utils-org-url-presentation-text-type))) km)) (define-key km [?g] (let ((km (make-sparse-keymap))) (define-key km [?h] 'w32utils-rotate-html-presentation-text-type) (define-key km [?l] 'w32utils-rotate-latex-presentation-text-type) (define-key km [?o] 'w32utils-rotate-org-presentation-text-type) km)) km) "Keymap local to the w32utils filename conversion buffer") (defun w32utils-filename-open-conv-buffer () "" ) (defun w32utils-kill-filename-conv-buffer () (let* ((b (current-buffer)) (w (get-buffer-window b)) (dired-buffer w32utils-dired-buffer)) (when w (delete-window w)) (when (buffer-live-p dired-buffer) (set-buffer dired-buffer) (unless (get-buffer-window dired-buffer) (switch-to-buffer dired-buffer)) (bury-buffer b) (kill-buffer b)))) (defun w32utils-display-current-text-type (current-presentation-text-type beg-mark end-mark) (let ((save-buffer-read-only buffer-read-only)) (setq buffer-read-only nil) (delete-region beg-mark end-mark) (cond ((symbolp current-presentation-text-type) (save-excursion (goto-char beg-mark) (insert (symbol-name current-presentation-text-type)))) ((consp current-presentation-text-type) (save-excursion (goto-char beg-mark) (insert (symbol-name (car current-presentation-text-type)) " " (prin1-to-string (cadr current-presentation-text-type)))))) (setq buffer-read-only save-buffer-read-only))) (defun w32utils-rotate-presentation-text-type (current-presentation-text-type beg-mark end-mark) (let ((l (cdr w32utils-url-presentation-text-type-customization-type)) lelt elt elt-id elt-is-const (val (symbol-value current-presentation-text-type)) val-id) (while l (setq lelt l elt (car lelt) elt-id (cond ((eq (car elt) 'const) (setq elt-is-const t) (cadr elt)) ((and (eq (car elt) 'list) (eq (caadr elt) 'const)) (setq elt-is-const nil) (cadadr elt)) (t nil)) val-id (cond ((symbolp val) val) ((consp val) (car val)) (t t)) l (cdr l)) (if (eq elt-id val-id) (setq l nil) (setq elt-id nil))) (when elt-id (setq elt (if (cdr lelt) (cadr lelt) (cadr w32utils-url-presentation-text-type-customization-type)) elt-id (cond ((eq (car elt) 'const) (setq elt-is-const t) (cadr elt)) ((and (eq (car elt) 'list) (eq (caadr elt) 'const)) (setq elt-is-const nil) (cadadr elt)) (t nil))) (set current-presentation-text-type (if elt-is-const elt-id (let* ((default "link") (prompt "Enter user-defined (link): ")) (list 'user-defined (read-from-minibuffer prompt nil nil nil nil default))))))) (w32utils-display-current-text-type (symbol-value current-presentation-text-type) beg-mark end-mark)) (defun w32utils-rotate-latex-presentation-text-type () (interactive) (w32utils-rotate-presentation-text-type 'w32utils-latex-url-presentation-text-type w32utils-latex-presentation-text-type-beg-mark w32utils-latex-presentation-text-type-end-mark)) (defun w32utils-rotate-org-presentation-text-type () (interactive) (w32utils-rotate-presentation-text-type 'w32utils-org-url-presentation-text-type w32utils-org-presentation-text-type-beg-mark w32utils-org-presentation-text-type-end-mark)) (defun w32utils-rotate-html-presentation-text-type () (interactive) (w32utils-rotate-presentation-text-type 'w32utils-html-url-presentation-text-type w32utils-html-presentation-text-type-beg-mark w32utils-html-presentation-text-type-end-mark)) (defun w32utils-concat-as-killed () "Action to be performed when the filename conversion buffer is quitted" (w32utils-filename-conv-check-buffer nil t) (when w32utils-filename-dest (kill-new (mapconcat 'identity w32utils-filename-dest (or w32utils-filename-concat-comma " ")) t)) (w32utils-kill-filename-conv-buffer)) (defvar w32utils-html-presentation-text-type-beg-mark nil) (defvar w32utils-html-presentation-text-type-end-mark nil) (defvar w32utils-latex-presentation-text-type-beg-mark nil) (defvar w32utils-latex-presentation-text-type-end-mark nil) (defvar w32utils-org-presentation-text-type-beg-mark nil) (defvar w32utils-org-presentation-text-type-end-mark nil) (defun w32utils-insert-url-keybinding-text-and-presentation-text-type (keybinding-text current-presentation-text-type beg-mark end-mark) (insert keybinding-text " [") (set (make-local-variable beg-mark) (point-marker)) (set (make-local-variable end-mark) (point-marker)) (insert "]\n") (set-marker-insertion-type (symbol-value end-mark) t) (w32utils-display-current-text-type current-presentation-text-type (symbol-value beg-mark) (symbol-value end-mark))) (defun w32utils-/-to-\\ (&optional conversion-type) "Replace all the / character in the scratchpad into \\ characters. When CONVERSION-TYPE is omitted or 0 just do this. When CONVERSION-TYPE is non-nil and is not an integer or is 1, / characters are replaced by \\\\, so that the result can be pasted into a string Lisp or C code. When CONVERSION-TYPE is 2, then pre-pend the string \"file://localhost/\" Otherwise do nothing. " (interactive "P") (let ((current-kill (current-kill 0 t))) (cl-flet ((wrap-converter (current-kill converter) (let ((w32utils-filename-org (list current-kill)) w32utils-filename-dest) (funcall converter) (car w32utils-filename-dest)))) (cond ;; ((and (null conversion-type) (derived-mode-p 'dired-mode)) (setq current-kill nil) (let ((dired-buffer (current-buffer)) (conversion-buffer (generate-new-buffer "*Filename conversion*"))) (switch-to-buffer-other-window conversion-buffer t) (insert "\ \[C] c-string: / -> \\\\\n") (w32utils-insert-url-keybinding-text-and-presentation-text-type "[h] HTML URL" w32utils-html-url-presentation-text-type 'w32utils-html-presentation-text-type-beg-mark 'w32utils-html-presentation-text-type-end-mark) (w32utils-insert-url-keybinding-text-and-presentation-text-type "[l] Latex URL" w32utils-latex-url-presentation-text-type 'w32utils-latex-presentation-text-type-beg-mark 'w32utils-latex-presentation-text-type-end-mark) (insert "[q] quit \[;] quit forcing separator to ; \[s] string: / -> \\\n") (w32utils-insert-url-keybinding-text-and-presentation-text-type "[o] Org URL" w32utils-org-url-presentation-text-type 'w32utils-org-presentation-text-type-beg-mark 'w32utils-org-presentation-text-type-end-mark) (insert "[u] URL \[c h] customize HTML URL text \[c l] customize LaTeX URL text \[c o] customize Org URL text\n" ) (set (make-local-variable 'w32utils-dired-buffer) dired-buffer) (set (make-local-variable 'w32utils-quit-handler) 'w32utils-concat-as-killed) (set (make-local-variable 'w32utils-filename-concat-comma) nil) (use-local-map w32utils-filename-conv-keymap) (setq buffer-read-only t); )) ;; ((null (stringp current-kill)) (setq current-kill nil)) ;; ((eq conversion-type 0) (setq current-kill (wrap-converter current-kill 'w32utils-filename-to-string))) ;; ((or (and conversion-type (null (integerp conversion-type))) (eq conversion-type 1)) (setq current-kill (wrap-converter current-kill 'w32utils-filename-to-c-string))); ;; ((eq conversion-type 2) (setq current-kill (wrap-converter current-kill 'w32utils-filename-to-url))); ;; (t (setq current-kill nil))) (when current-kill (kill-new current-kill t))))) (defun w32utils-vb-stringize (str) (concat "\"" (mapconcat 'identity (split-string str "\"") "\"\"") "\"")) (defun w32utils-send-it () "Mail sending function to send emails via MSOutlook" (with-current-buffer mailbuf (let ((header-boundary (save-excursion (goto-char (point-min)) (or (re-search-forward "--text follows this line--" nil t) (point-max))))) (cl-flet ((fetch-field (field-id) (save-restriction (narrow-to-region (point-min) header-boundary) (message-fetch-field field-id))) (get-field (field-descriptor) (cdr (assoc-string (or (fetch-field (pop field-descriptor)) (pop field-descriptor)) field-descriptor))) (set-text-field (x) (let ((field (mapcar (lambda (x) (concat (w32utils-vb-stringize x) " & sCR_LF")) (split-string (or x "") "\n"))) i) (while field (insert "\nsField = " (if i "sField & " "")) (setq i 0) (while (and (< i 3) field) (insert (if (= 0 i) "" " _\n\t& ") (pop field)) (setq i (1+ i)))))); (html-escape (x) (let ((p1 0) p2 (len (length x)) l) (while (and (< p1 len) (setq p2 (string-match "[&<>]" x p1))) (and (> p2 p1) (push (substring x p1 p2) l)) (push (cdr (assoc-string (match-string 0 x) '( ( "&" . "&") ( ">" . ">") ( "<" . "<")))) l) (setq p1 (1+ p2))) (and (< p1 len) (push (substring x p1) l)) (apply 'concat (nreverse l)))); ) (let* ((vbscript-file (concat w32utils-ms-outlook-temp-dir (format-time-string "W32utils-%Y%m%dT%H%M%S") (format "-%04d.vbs" (setq w32utilis-ms-outlook-send-nb (1+ w32utilis-ms-outlook-send-nb))))) (vbscript (save-excursion (find-file vbscript-file)))) (with-current-buffer vbscript (insert "Dim oOutlookApp, oMailItem Dim lPos Const iOL_MAIL_ITEM = 0 Const iOL_FORMAT_HTML = 2 Const iOL_FORMAT_PLAIN = 1 Const iOL_IMPORTANCE_HIGH = 2 Const iOL_IMPORTANCE_NORMAL = 1 Const iOL_IMPORTANCE_LOW = 0 Const iOL_BY_VALUE = 1 Set oOutlookApp = CreateObject(\"Outlook.Application\") Set oMailItem = oOutlookApp.CreateItem(iOL_MAIL_ITEM) Const sLIST_SEPARATOR = \";\" Dim sCR_LF sCR_LF = Chr(13) & Chr(10) Dim sField" ) (save-excursion (insert " ' Local Variables: ' coding: windows-1252-dos ' End: " ))) (dolist (header '( ["to" "To" :comma-separated-list fetch-field 1] ["cc" "Cc" :comma-separated-list fetch-field 1] ["subject" "Subject" :plain fetch-field 1] [("importance" "normal" ("high" . "iOL_IMPORTANCE_HIGH") ("normal" . "iOL_IMPORTANCE_NORMAL")) "Importance" :direct get-field 1] )) (let ((header-field (funcall (aref header 3) (aref header 0))) i) (when header-field (setq header-field (case (aref header 2) ((:comma-separated-list) (let ((hf (mapcar (lambda (x) (concat (w32utils-vb-stringize x) " & sLIST_SEPARATOR")) (nreverse (split-string header-field "\\s-*,\\s-*" t))))) (when hf ;; enlève le séparateur de liste sur le dernier élement (setcar hf (substring (car hf) 0 -18)) ;; remet tout à l'endroit (nreverse hf)))) ((:plain) (list (w32utils-vb-stringize header-field))) ((:direct) (list header-field)) (t (mapcar 'w32utils-vb-stringize (split-string header-field "\n")))))) ;; on reteste header field, des fois que pendant son traitement on se soit ;; aperçu qu'il faut l'omettre (when header-field (with-current-buffer vbscript (setq i nil) (while header-field (insert "\nsField = " (if i "sField & " "")) (setq i 0) (while (and (< i 3) header-field) (insert (if (= 0 i) "" " _\n\t& ") (pop header-field)) (setq i (1+ i)))) (insert "\noMailItem." (aref header 1) " = sField"))))) ;; body and parts (let (has-body field-name force-attach part (parts (mml-parse))) (setq part (car parts)) (let* ((contents-cell (assq 'contents part)) (contents (cdr contents-cell)) (separator "--text follows this line--\n")) (setq contents (substring contents (let ((from (string-match (regexp-quote separator) contents 0))) (if from (+ from (length separator)) 0)))) (if (string-match "\\`\\(?:\n\\|\\s-\\)*\\'" contents) (setq parts (cdr-safe parts)) (setcdr contents-cell contents) (setcdr part (cons (cons 'disposition "inline") (cdr part))))) (while parts (setq part (car parts)) (if (eq (car part) 'part) (setq part (cdr part))) ;; HTML encode when part format is "text/org-mode" (let* ((type-cell (assq 'type part)) (type (cdr type-cell))) (when (string= type "text/org-mode") (let* ((contents-cell (assq 'contents part)) (contents (cdr contents-cell))) (setcdr type-cell "text/html") (with-temp-buffer (insert contents) (org-mode) (cl-flet ((region-beginning () (point-min)) (region-end () (point-max)) (org-region-active-p () t)) (setq contents (org-export-as-html 3 nil '(:body-only t) 'string) ) (setcdr contents-cell contents)))))) (with-current-buffer vbscript (cond ;; Body ((and (null (or has-body force-attach (assq 'filename part))) (string= (cdr (assq 'disposition part)) "inline")) (case (intern (cdr (assq 'type part))) ((text/plain) (setq has-body :plain) (insert "\noMailItem.BodyFormat = iOL_FORMAT_PLAIN") (setq field-name "Body")) ((text/html) (setq has-body :html) (insert "\noMailItem.BodyFormat = iOL_FORMAT_HTML") (setq field-name "HTMLBody")) (t (setq force-attach t))) (unless force-attach (setq parts (cdr parts)) (set-text-field (cdr-safe (assq 'contents part))) (insert "\noMailItem." field-name " = sField"))) ;; file attachment ((assq 'filename part) (let ((filename (cdr (assq 'filename part)))) (if (file-exists-p filename) (progn (setq filename (w32utils-vb-stringize (convert-standard-filename (expand-file-name filename)))) (insert "\nCall oMailItem.Attachments.Add( _\n" filename ", _\niOL_BY_VALUE, _\n1, _\n" filename ")")) (error "Can't find file %s" filename))) (setq parts (cdr parts))) ;; subsequent text attachment ((and (null (or force-attach (assq 'filename part))) (string= (cdr (assq 'disposition part)) "inline")) (case (intern (cdr (assq 'type part))) ((text/plain) (if (eq has-body :plain) (progn (set-text-field (cdr-safe (assq 'contents part))) (insert "\noMailItem.Body = oMailItem.Body & sCR_LF _ & \"-----------------------------------------------------------------------\" & sCR_LF _ & sField")) (set-text-field (html-escape (or "" (cdr-safe (assq 'contents part))))) (insert " lPos = InStr(oMailItem.Body,\"</BODY>\") oMailItem.HTMLBody = Left(oMailItem.HTMLBody,lPos) _ & \"<p><hr/></p><div>\" & sField & \"</div>\" & Mid(oMailItem.HTMLBody,lPos+1,10000)" ))) ((text/html) (set-text-field (cdr-safe (assq 'contents part))) (when (eq has-body :plain) (setq has-body :html) (insert "\noMailItem.BodyFormat = iOL_FORMAT_HTML")) (insert "lPos = InStr(oMailItem.Body,\"</BODY>\") oMailItem.HTMLBody = Left(oMailItem.HTMLBody,lPos) _ & \"<p><hr/></p><div>\" & sField & \"</div>\" & Mid(oMailItem.HTMLBody,lPos+1,10000)")) (t (setq force-attach t))) (setq parts (cdr parts))) (t (error "Can't interpret part %S" part)))))) ;; display or send (with-current-buffer vbscript (case w32utils-ms-outlook-action ((:display) (insert "\noMailItem.Display")) ((:send (insert "\noMailItem.Send")))) (insert "\n'----------- Fin du Script ----------------\n") (save-buffer)) (call-process "cscript.exe" nil nil nil vbscript-file) (kill-buffer vbscript)))))) ;;; w32utils.el ends here ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-04 15:28 ` Vincent Belaïche @ 2014-06-04 15:44 ` Eli Zaretskii 2014-06-04 15:54 ` Dani Moncayo 0 siblings, 1 reply; 38+ messages in thread From: Eli Zaretskii @ 2014-06-04 15:44 UTC (permalink / raw) To: Vincent Belaïche; +Cc: eggert, emacs-devel > From: Vincent Belaïche <vincent.b.1@hotmail.fr> > CC: "eggert@cs.ucla.edu" <eggert@cs.ucla.edu>, emacs-devel > <emacs-devel@gnu.org> > Date: Wed, 4 Jun 2014 17:28:44 +0200 > > In fact what I have is that /etc/profile is not sourced, but ~/.bash_profile is sourced. Well, it is certainly a standard bash behaviour that when you have a ~/.bash_profile then /etc/profile is ignored, my mistake is that there should have been a source /etc/profile at the beginning of my ~/.bash_profile. You need to invoke the shell with the --login switch, then it will read /etc/profile. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-04 15:44 ` Eli Zaretskii @ 2014-06-04 15:54 ` Dani Moncayo 2014-06-04 16:05 ` Eli Zaretskii 0 siblings, 1 reply; 38+ messages in thread From: Dani Moncayo @ 2014-06-04 15:54 UTC (permalink / raw) To: Eli Zaretskii Cc: Vincent Belaïche, Paul Eggert, Emacs development discussions > You need to invoke the shell with the --login switch, then it will > read /etc/profile. It would be nice to have a more reliable way of checking for an MSYS environment. For example, wouldn't it be possible to check the output of 'uname'? -- Dani Moncayo ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-04 15:54 ` Dani Moncayo @ 2014-06-04 16:05 ` Eli Zaretskii 2014-06-04 21:50 ` Dani Moncayo 0 siblings, 1 reply; 38+ messages in thread From: Eli Zaretskii @ 2014-06-04 16:05 UTC (permalink / raw) To: Dani Moncayo; +Cc: vincent.b.1, eggert, emacs-devel > Date: Wed, 4 Jun 2014 17:54:33 +0200 > From: Dani Moncayo <dmoncayo@gmail.com> > Cc: Vincent Belaïche <vincent.b.1@hotmail.fr>, > Paul Eggert <eggert@cs.ucla.edu>, Emacs development discussions <emacs-devel@gnu.org> > > > You need to invoke the shell with the --login switch, then it will > > read /etc/profile. > > It would be nice to have a more reliable way of checking for an MSYS > environment. Patches are welcome. > For example, wouldn't it be possible to check the output of 'uname'? Maybe, but it's not simple, because there's more than one kind available out there. I have 3 on my system, and they report, respectively: MINGW32_NT-5.1 HOME-C4E4A596F7 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys MINGW32_NT-5.1 HOME-C4E4A596F7 1.0.12(0.46/3/2) 2012-07-05 14:56 i686 unknown windows32 home-c4e4a596f7 2.5.1 2600 i686-pc Intel unknown MinGW In a nutshell, most of what a ported 'uname' reports is hard-wired into it when it is built, because there's no such OS as "MinGW". That's hardly a good way of reliably identifying MinGW. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-04 16:05 ` Eli Zaretskii @ 2014-06-04 21:50 ` Dani Moncayo 2014-06-05 0:42 ` Stefan Monnier 2014-06-05 2:47 ` Eli Zaretskii 0 siblings, 2 replies; 38+ messages in thread From: Dani Moncayo @ 2014-06-04 21:50 UTC (permalink / raw) To: Eli Zaretskii Cc: Vincent Belaïche, Paul Eggert, Emacs development discussions >> For example, wouldn't it be possible to check the output of 'uname'? > > Maybe, but it's not simple, because there's more than one kind > available out there. I have 3 on my system, and they report, > respectively: > > MINGW32_NT-5.1 HOME-C4E4A596F7 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys > MINGW32_NT-5.1 HOME-C4E4A596F7 1.0.12(0.46/3/2) 2012-07-05 14:56 i686 unknown > windows32 home-c4e4a596f7 2.5.1 2600 i686-pc Intel unknown MinGW > > In a nutshell, most of what a ported 'uname' reports is hard-wired > into it when it is built, because there's no such OS as "MinGW". > That's hardly a good way of reliably identifying MinGW. I see. Too bad that different MSYS flavors are not consistent wrt the output of 'uname'. Another option would be, perphaps, to check the environment variable $OSTYPE (instead of $MSYSTEM). I've just done a quick test on my system: if I invoke "bash.exe" (without "--login"), I see that $OSTYPE holds "msys", while $MSYSTEM is undefined. (But I don't know if this is also true in other MSYS flavors). -- Dani Moncayo ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-04 21:50 ` Dani Moncayo @ 2014-06-05 0:42 ` Stefan Monnier 2014-06-05 2:51 ` Eli Zaretskii 2014-06-05 2:47 ` Eli Zaretskii 1 sibling, 1 reply; 38+ messages in thread From: Stefan Monnier @ 2014-06-05 0:42 UTC (permalink / raw) To: Dani Moncayo Cc: Eli Zaretskii, Paul Eggert, Vincent Belaïche, Emacs development discussions > Another option would be, perphaps, to check the environment > variable $OSTYPE (instead of $MSYSTEM). I've just done a quick > test on my system: if I invoke "bash.exe" (without "--login"), I > see that $OSTYPE holds "msys", while $MSYSTEM is undefined. (But > I don't know if this is also true in other MSYS flavors). How 'bout testing a functionality on which we rely during the build, rather than looking for some indirect evidence? Stefan ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 0:42 ` Stefan Monnier @ 2014-06-05 2:51 ` Eli Zaretskii 2014-06-05 3:40 ` Óscar Fuentes 2014-06-05 13:31 ` Stefan Monnier 0 siblings, 2 replies; 38+ messages in thread From: Eli Zaretskii @ 2014-06-05 2:51 UTC (permalink / raw) To: Stefan Monnier; +Cc: vincent.b.1, eggert, emacs-devel, dmoncayo > From: Stefan Monnier <monnier@iro.umontreal.ca> > Cc: Eli Zaretskii <eliz@gnu.org>, Vincent Belaïche > <vincent.b.1@hotmail.fr>, Paul Eggert <eggert@cs.ucla.edu>, Emacs > development discussions <emacs-devel@gnu.org> > Date: Wed, 04 Jun 2014 20:42:24 -0400 > > > Another option would be, perphaps, to check the environment > > variable $OSTYPE (instead of $MSYSTEM). I've just done a quick > > test on my system: if I invoke "bash.exe" (without "--login"), I > > see that $OSTYPE holds "msys", while $MSYSTEM is undefined. (But > > I don't know if this is also true in other MSYS flavors). > > How 'bout testing a functionality on which we rely during the build, > rather than looking for some indirect evidence? Chicken-and-egg problem: that test is there so that we could source nt/mingw-cfg.site file, which does what you want. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 2:51 ` Eli Zaretskii @ 2014-06-05 3:40 ` Óscar Fuentes 2014-06-05 7:03 ` Dani Moncayo 2014-06-05 14:51 ` Eli Zaretskii 2014-06-05 13:31 ` Stefan Monnier 1 sibling, 2 replies; 38+ messages in thread From: Óscar Fuentes @ 2014-06-05 3:40 UTC (permalink / raw) To: emacs-devel Eli Zaretskii <eliz@gnu.org> writes: >> > Another option would be, perphaps, to check the environment >> > variable $OSTYPE (instead of $MSYSTEM). I've just done a quick >> > test on my system: if I invoke "bash.exe" (without "--login"), I >> > see that $OSTYPE holds "msys", while $MSYSTEM is undefined. (But >> > I don't know if this is also true in other MSYS flavors). >> >> How 'bout testing a functionality on which we rely during the build, >> rather than looking for some indirect evidence? > > Chicken-and-egg problem: that test is there so that we could source > nt/mingw-cfg.site file, which does what you want. Why not test if the preprocessor defines __MINGW32__? ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 3:40 ` Óscar Fuentes @ 2014-06-05 7:03 ` Dani Moncayo 2014-06-05 9:03 ` Vincent Belaïche 2014-06-05 14:51 ` Eli Zaretskii 1 sibling, 1 reply; 38+ messages in thread From: Dani Moncayo @ 2014-06-05 7:03 UTC (permalink / raw) To: Óscar Fuentes; +Cc: Emacs development discussions >>> How 'bout testing a functionality on which we rely during the build, >>> rather than looking for some indirect evidence? >> >> Chicken-and-egg problem: that test is there so that we could source >> nt/mingw-cfg.site file, which does what you want. > > Why not test if the preprocessor defines __MINGW32__? Another alternative, just for the record: AFAIK, only the MSYS bash supports a "-W" switch for its "pwd" command. So, we could do something like: if pwd -W 1>/dev/null 2>&1 then echo This is MSYS else echo This is not MSYS fi -- Dani Moncayo ^ permalink raw reply [flat|nested] 38+ messages in thread
* RE: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 7:03 ` Dani Moncayo @ 2014-06-05 9:03 ` Vincent Belaïche 2014-06-05 15:09 ` Eli Zaretskii 0 siblings, 1 reply; 38+ messages in thread From: Vincent Belaïche @ 2014-06-05 9:03 UTC (permalink / raw) To: Dani Moncayo, Óscar Fuentes; +Cc: emacs-devel Er, I feel a bit awkward that I have caused such a long discussion. After adding a source /etc/profile line at the top of my ~/.bash_profile, everything went ok. I think that MSYS users should simply keep the definition from the /etc/profile, I simply did not realize when I created my ~/.bash_profile that the /etc/profile would no longer be sourced. Anyway, shouldn't it be delegated to autotools to do that job of detecting the environement and whether the user is a naughty boy/girl that did not sourced his/her /etc/profile... In the EMACS source code you would then just use some #ifdef HAVE_WIN32_LEAN_AND_MEAN ... #endif Where HAVE_WIN32_LEAN_AND_MEAN would be from the config.h file generated by autotools. That would be wiser as other programs than EMACS could have the same case, so it is not worth re-inventing the wheel every time. So the way forward should be to ask autotools people whether any such thing as HAVE_WIN32_LEAN_AND_MEAN already exists, and if not make some contribution, eg based on the pwd -W suggestion made, or on making some C test program + try and compile it, as autotools often do. VBR, Vincent. ---------------------------------------- > Date: Thu, 5 Jun 2014 09:03:03 +0200 > Subject: Re: Latest EMACS on BZR trunk does not compile with MinGW > From: dmoncayo@gmail.com > To: ofv@wanadoo.es > CC: emacs-devel@gnu.org > >>>> How 'bout testing a functionality on which we rely during the build, >>>> rather than looking for some indirect evidence? >>> >>> Chicken-and-egg problem: that test is there so that we could source >>> nt/mingw-cfg.site file, which does what you want. >> >> Why not test if the preprocessor defines __MINGW32__? > > Another alternative, just for the record: AFAIK, only the MSYS bash > supports a "-W" switch for its "pwd" command. > > So, we could do something like: > > if pwd -W 1>/dev/null 2>&1 > then > echo This is MSYS > else > echo This is not MSYS > fi > > -- > Dani Moncayo > ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 9:03 ` Vincent Belaïche @ 2014-06-05 15:09 ` Eli Zaretskii 0 siblings, 0 replies; 38+ messages in thread From: Eli Zaretskii @ 2014-06-05 15:09 UTC (permalink / raw) To: Vincent Belaïche; +Cc: ofv, emacs-devel, dmoncayo > From: Vincent Belaïche <vincent.b.1@hotmail.fr> > Date: Thu, 5 Jun 2014 11:03:57 +0200 > Cc: emacs-devel <emacs-devel@gnu.org> > > After adding a > > source /etc/profile > > line at the top of my ~/.bash_profile, everything went ok. Again, this is not TRT. You should invoke the shell with the --login switch, then it will behave as you expect. > Anyway, shouldn't it be delegated to autotools to do that job of detecting the environement and whether the user is a naughty boy/girl that did not sourced his/her /etc/profile... Please take a look at configure.ac: we do delegate this to autotools, but in this specific case we need to know we are on a MinGW system very early in the script, so that we read a MinGW-specific file that makes sure some autoconf tests produce results we want. IOW, the issue is to use the general scripts with as little MinGW-specific stuff as possible. > In the EMACS source code you would then just use some > > #ifdef HAVE_WIN32_LEAN_AND_MEAN > ... > #endif > > Where HAVE_WIN32_LEAN_AND_MEAN would be from the config.h file generated by autotools. > > That would be wiser as other programs than EMACS could have the same case, so it is not worth re-inventing the wheel every time. We already do all that. Again, please look at configure.ac and see how the MSYSTEM variable's value is used. It is not used to set HAVE_* macros. We are not inventing the wheel. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 3:40 ` Óscar Fuentes 2014-06-05 7:03 ` Dani Moncayo @ 2014-06-05 14:51 ` Eli Zaretskii 2014-06-05 16:19 ` Óscar Fuentes 1 sibling, 1 reply; 38+ messages in thread From: Eli Zaretskii @ 2014-06-05 14:51 UTC (permalink / raw) To: Óscar Fuentes; +Cc: emacs-devel > From: Óscar Fuentes <ofv@wanadoo.es> > Date: Thu, 05 Jun 2014 05:40:46 +0200 > > Why not test if the preprocessor defines __MINGW32__? How will you call the compiler? Its exact name and directory isn't known until much later in the script. Perhaps we should only worry about detecting that MSYSTEM isn't set when it should be. For that, we can wait until the script figures out how to invoke the compiler, and _then_ see if the preprocessor defines __MINGW32__. If it does, but MSYSTEM is not set, we display an error message and exit. I think this should be enough; valid MSYS installation should read /etc/profile and then they will have MSYSTEM defined. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 14:51 ` Eli Zaretskii @ 2014-06-05 16:19 ` Óscar Fuentes 2014-06-05 17:52 ` Eli Zaretskii 0 siblings, 1 reply; 38+ messages in thread From: Óscar Fuentes @ 2014-06-05 16:19 UTC (permalink / raw) To: emacs-devel Eli Zaretskii <eliz@gnu.org> writes: >> Why not test if the preprocessor defines __MINGW32__? > > How will you call the compiler? Its exact name and directory isn't > known until much later in the script. The build failure came from the configure script deciding something about dup2 based on MSYSTEM. That sounds wrong to me: the characteristics of a function are supposed to be decided based on specific tests. That means that when dup2 is probed by the configure script the test code should detect that we are using the MS C runtime and return an specific code. Is MSYSTEM relevant for anything that must be deciced before we can invoke the compiler? > Perhaps we should only worry about detecting that MSYSTEM isn't set > when it should be. For that, we can wait until the script figures out > how to invoke the compiler, and _then_ see if the preprocessor defines > __MINGW32__. If it does, but MSYSTEM is not set, we display an error > message and exit. I think this should be enough; valid MSYS > installation should read /etc/profile and then they will have MSYSTEM > defined. Something like this would be good too, but please note that MSYSTEM can be defined with a wrong value. My build failure came from starting MSYS2 with the wrong script, the one that defines MSYSTEM to "MSYS". ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 16:19 ` Óscar Fuentes @ 2014-06-05 17:52 ` Eli Zaretskii 0 siblings, 0 replies; 38+ messages in thread From: Eli Zaretskii @ 2014-06-05 17:52 UTC (permalink / raw) To: Óscar Fuentes; +Cc: emacs-devel > From: Óscar Fuentes <ofv@wanadoo.es> > Date: Thu, 05 Jun 2014 18:19:11 +0200 > > Eli Zaretskii <eliz@gnu.org> writes: > > >> Why not test if the preprocessor defines __MINGW32__? > > > > How will you call the compiler? Its exact name and directory isn't > > known until much later in the script. > > The build failure came from the configure script deciding something > about dup2 based on MSYSTEM. No, dup2 is only a tip of an iceberg. When MSYSTEM is not defined, the configure script will not source nt/mingw-cfg.site, and quite a few other things will become broken/flawed in the resulting binary. nt/mingw-cfg.site is our way of augmenting the configure script in a way that keeps most of the gory details out of sight of most of the maintainers, who don't want to know too much about MinGW-specific quirks. > That sounds wrong to me: the characteristics of a function are > supposed to be decided based on specific tests. That means that when > dup2 is probed by the configure script the test code should detect > that we are using the MS C runtime and return an specific code. Most of the configure-time tests indeed do that. But this particular test, and a few others, don't, because Emacs on Windows has special needs that are provided in Emacs's own sources; the configure script cannot possibly know about that, because it only probes system headers and libraries. One such other example is the ACL-related primitives, which are coded entirely in w32.c; symlink support is yet another. In these cases, we force the configure script to make the correct decision by setting select shell variables to known values in mingw-cfg.site. > Is MSYSTEM relevant for anything that must be deciced before we can > invoke the compiler? See above. Better yet, just read configure.ac where it tests for that variable, and then take it from there. It's really not so complicated. > > Perhaps we should only worry about detecting that MSYSTEM isn't set > > when it should be. For that, we can wait until the script figures out > > how to invoke the compiler, and _then_ see if the preprocessor defines > > __MINGW32__. If it does, but MSYSTEM is not set, we display an error > > message and exit. I think this should be enough; valid MSYS > > installation should read /etc/profile and then they will have MSYSTEM > > defined. > > Something like this would be good too, but please note that MSYSTEM can > be defined with a wrong value. My build failure came from starting MSYS2 > with the wrong script, the one that defines MSYSTEM to "MSYS". I know nothing about MSYS2; please consider providing the necessary details so some of them could be added to nt/INSTALL. I did add there text that tells how to invoke the MSYS Bash to avoid this problem. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 2:51 ` Eli Zaretskii 2014-06-05 3:40 ` Óscar Fuentes @ 2014-06-05 13:31 ` Stefan Monnier 2014-06-05 15:15 ` Eli Zaretskii 1 sibling, 1 reply; 38+ messages in thread From: Stefan Monnier @ 2014-06-05 13:31 UTC (permalink / raw) To: Eli Zaretskii; +Cc: vincent.b.1, eggert, emacs-devel, dmoncayo >> How 'bout testing a functionality on which we rely during the build, >> rather than looking for some indirect evidence? > Chicken-and-egg problem: that test is there so that we could source > nt/mingw-cfg.site file, which does what you want. AFAIK it's not exactly a chicken-and-egg problem: yes, we usually rely on autoconf to do "functionality tests" and here we'd need to do a functionality test in order to decide how to run autoconf, but we can perform functionality tests without autoconf. One more thing: what is this test *really* trying to figure out? You say that the "uname" output is not very useful, but I don't understand why case "$(uname -a)" in *MINGW* | *MinGW* ) ... esac wouldn't give the right answer. IIUC we're trying to figure out whether we're doing an "MSYS" build (whatever that means) and to do that we should: - discover that we're on a w32 system. - discover that we're not doing a cygwin build. Stefan ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 13:31 ` Stefan Monnier @ 2014-06-05 15:15 ` Eli Zaretskii 2014-06-05 16:50 ` Stefan Monnier 0 siblings, 1 reply; 38+ messages in thread From: Eli Zaretskii @ 2014-06-05 15:15 UTC (permalink / raw) To: Stefan Monnier; +Cc: vincent.b.1, eggert, emacs-devel, dmoncayo > From: Stefan Monnier <monnier@iro.umontreal.ca> > Cc: dmoncayo@gmail.com, vincent.b.1@hotmail.fr, eggert@cs.ucla.edu, emacs-devel@gnu.org > Date: Thu, 05 Jun 2014 09:31:50 -0400 > > One more thing: what is this test *really* trying to figure out? > You say that the "uname" output is not very useful, but I don't > understand why > > case "$(uname -a)" in > *MINGW* | *MinGW* ) ... > esac > > wouldn't give the right answer. How is that different from what config.guess already does? The problem, as I see it, is that we need to know the results much earlier than config.guess is run. But I'm not an expert on Autotools, so if there's a clean way of calling config.guess early, that might be it. Alternatively, as I wrote elsewhere, we might not try so hard to detect MinGW up front, but just error out when we find out the host is MinGW, but MSYSTEM is not set. That might be a good enough solution with a much smaller footprint. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 15:15 ` Eli Zaretskii @ 2014-06-05 16:50 ` Stefan Monnier 2014-06-05 18:07 ` Eli Zaretskii 0 siblings, 1 reply; 38+ messages in thread From: Stefan Monnier @ 2014-06-05 16:50 UTC (permalink / raw) To: Eli Zaretskii; +Cc: vincent.b.1, eggert, emacs-devel, dmoncayo >> case "$(uname -a)" in >> *MINGW* | *MinGW* ) ... >> esac >> wouldn't give the right answer. > How is that different from what config.guess already does? I'm not trying to replace config.guess nor am I trying to avoid duplicating it. I'm just trying to replace the if test "x$MSYSTEM" = "xMINGW32" -o "x$MSYSTEM" = "xMINGW64" in configure.ac since it turns out that $MSYSTEM may not be set. > is MinGW, but MSYSTEM is not set. That might be a good enough Is $MSYSTEM really necessary? I only see it used in the above "test" and in nt/gmake.defs (which I'm not sure we use nowadays). Of course if the /etc/profile thingy that sets MSYSTEM also sets lots of other important things, then we may as well rely on $MSYSTEM, indeed. Stefan ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 16:50 ` Stefan Monnier @ 2014-06-05 18:07 ` Eli Zaretskii 2014-06-05 19:35 ` Paul Eggert 2014-06-05 20:54 ` Stefan Monnier 0 siblings, 2 replies; 38+ messages in thread From: Eli Zaretskii @ 2014-06-05 18:07 UTC (permalink / raw) To: Stefan Monnier; +Cc: vincent.b.1, eggert, emacs-devel, dmoncayo > From: Stefan Monnier <monnier@iro.umontreal.ca> > Cc: dmoncayo@gmail.com, vincent.b.1@hotmail.fr, eggert@cs.ucla.edu, emacs-devel@gnu.org > Date: Thu, 05 Jun 2014 12:50:29 -0400 > > >> case "$(uname -a)" in > >> *MINGW* | *MinGW* ) ... > >> esac > >> wouldn't give the right answer. > > > How is that different from what config.guess already does? > > I'm not trying to replace config.guess nor am I trying to avoid > duplicating it. > I'm just trying to replace the > > if test "x$MSYSTEM" = "xMINGW32" -o "x$MSYSTEM" = "xMINGW64" > > in configure.ac since it turns out that $MSYSTEM may not be set. I'm all for better alternatives, if they exist. I'm just not sure that calling config.guess so early in the script is a good idea (otherwise, why every configure script calls config.guess at that place and no earlier?). Some Autoconf expert should comment on that; if they approve, we should do that, because config.guess is reliable. > > is MinGW, but MSYSTEM is not set. That might be a good enough > > Is $MSYSTEM really necessary? I only see it used in the above "test" > and in nt/gmake.defs (which I'm not sure we use nowadays). We need some sign that we are configuring the MinGW build of Emacs, and we need it very early in the script. That is all. $MSYSTEM is just a handle to do that. (And yes, gmake.defs is no longer important, and should disappear from the trunk soonish.) > Of course if the /etc/profile thingy that sets MSYSTEM also sets lots of > other important things, then we may as well rely on $MSYSTEM, indeed. Yes, /etc/profile sets more than just MSYSTEM. E.g., it sets PATH. More importantly, the MSYS developers provide /etc/profile, and they set up the shell window to invoke Bash with the --login switch. So the official way of starting the MSYS environment is to read /etc/profile, and I therefore strongly advise all users to use that. People who know what they are doing can change their setup, or invoke Bash differently, but then they need to accept the risk that some things might become broken or unreliable, because MSYS strikes a very fragile balance between Posix and Windows worlds. If there are more reliable ways of detecting MinGW by a simple test, I think we should adopt it. But I don't think we should complicate the lives of users who faithfully follow instructions in order to placate those who don't; that's just backwards in my book. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 18:07 ` Eli Zaretskii @ 2014-06-05 19:35 ` Paul Eggert 2014-06-05 19:54 ` Eli Zaretskii 2014-06-10 19:25 ` Dani Moncayo 2014-06-05 20:54 ` Stefan Monnier 1 sibling, 2 replies; 38+ messages in thread From: Paul Eggert @ 2014-06-05 19:35 UTC (permalink / raw) To: Eli Zaretskii; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 369 bytes --] On 06/05/2014 11:07 AM, Eli Zaretskii wrote: > Some Autoconf expert should comment on that; > if they approve, we should do that, because config.guess is reliable. We can invoke AC_CANONICAL_HOST early in configure.ac, right after AC_INIT_AUTOMAKE. The attached patch, for example, should work fine on non-Microsoft platforms (I haven't tested it on MingW though). [-- Attachment #2: canonical.diff --] [-- Type: text/x-patch, Size: 2200 bytes --] === modified file 'configure.ac' --- configure.ac 2014-06-05 08:03:22 +0000 +++ configure.ac 2014-06-05 19:34:10 +0000 @@ -25,22 +25,6 @@ dnl Note this is parsed by (at least) make-dist and lisp/cedet/ede/emacs.el. AC_INIT(GNU Emacs, 24.4.50, bug-gnu-emacs@gnu.org) -dnl We get MINGW64 with MSYS2 -if test "x$MSYSTEM" = "xMINGW32" -o "x$MSYSTEM" = "xMINGW64" -then - . $srcdir/nt/mingw-cfg.site - - case $srcdir in - /* | ?:*) - # srcdir is an absolute path. In this case, force the format - # "/c/foo/bar", to simplify later conversions to native Windows - # format ("c:/foo/bar") - srcdir=`cd "${srcdir}" && pwd -W` - srcdir="/${srcdir:0:1}${srcdir:2}" - ;; - esac -fi - dnl Set emacs_config_options to the options of 'configure', quoted for the shell, dnl and then quoted again for a C string. Separate options with spaces. dnl Add some environment variables, if they were passed via the environment @@ -146,6 +130,27 @@ dnl Fairly arbitrary, older versions might work too. AM_INIT_AUTOMAKE(1.11) +dnl Canonicalize the configuration name. +AC_CANONICAL_HOST +canonical=$host +configuration=${host_alias-${build_alias-$host}} + +dnl We get MINGW64 with MSYS2. +case $canonical in + *-mingw*) + . $srcdir/nt/mingw-cfg.site + + case $srcdir in + /* | ?:*) + # srcdir is an absolute path. In this case, force the format + # "/c/foo/bar", to simplify later conversions to native Windows + # format ("c:/foo/bar"). + srcdir=`cd "${srcdir}" && pwd -W` + srcdir="/${srcdir:0:1}${srcdir:2}" + ;; + esac;; +esac + dnl Support for --program-prefix, --program-suffix and dnl --program-transform-name options AC_ARG_PROGRAM @@ -488,12 +493,6 @@ [Show Gtk+/Gdk deprecation warnings for Gtk+ >= 3.0])], [ac_enable_gtk_deprecation_warnings="${enableval}"],[]) -### Canonicalize the configuration name. - -AC_CANONICAL_HOST -canonical=$host -configuration=${host_alias-${build_alias-$host}} - dnl This used to use changequote, but, apart from `changequote is evil' dnl per the autoconf manual, we can speed up autoconf somewhat by quoting dnl the great gob of text. Thus it's not processed for possible expansion. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 19:35 ` Paul Eggert @ 2014-06-05 19:54 ` Eli Zaretskii 2014-06-10 19:25 ` Dani Moncayo 1 sibling, 0 replies; 38+ messages in thread From: Eli Zaretskii @ 2014-06-05 19:54 UTC (permalink / raw) To: Paul Eggert; +Cc: emacs-devel > Date: Thu, 05 Jun 2014 12:35:15 -0700 > From: Paul Eggert <eggert@cs.ucla.edu> > CC: emacs-devel@gnu.org > > On 06/05/2014 11:07 AM, Eli Zaretskii wrote: > > Some Autoconf expert should comment on that; > > if they approve, we should do that, because config.guess is reliable. > > We can invoke AC_CANONICAL_HOST early in configure.ac, right after > AC_INIT_AUTOMAKE. The attached patch, for example, should work fine on > non-Microsoft platforms (I haven't tested it on MingW though). Thanks. However, one problem with that is that $srcdir might be corrected too late, after it is already used several times in the script. I don't remember exactly why we have the test where we do, but this looks like one of the places where we would need it: if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi Anyway, someone who builds Emacs under the MSYS root directory should test this. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 19:35 ` Paul Eggert 2014-06-05 19:54 ` Eli Zaretskii @ 2014-06-10 19:25 ` Dani Moncayo 2014-06-10 20:21 ` Eli Zaretskii 1 sibling, 1 reply; 38+ messages in thread From: Dani Moncayo @ 2014-06-10 19:25 UTC (permalink / raw) To: Paul Eggert; +Cc: Eli Zaretskii, Emacs development discussions On Thu, Jun 5, 2014 at 9:35 PM, Paul Eggert <eggert@cs.ucla.edu> wrote: > On 06/05/2014 11:07 AM, Eli Zaretskii wrote: >> >> Some Autoconf expert should comment on that; >> if they approve, we should do that, because config.guess is reliable. > > We can invoke AC_CANONICAL_HOST early in configure.ac, right after > AC_INIT_AUTOMAKE. The attached patch, for example, should work fine on > non-Microsoft platforms (I haven't tested it on MingW though). I've just tested Paul's patch in my MinGW/MSYS enviroment where I usually build Emacs, and it seems to work flawlessly. In fact, the output of "./autogen.sh && ./configure" is identical with or without the patch. -- Dani Moncayo ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-10 19:25 ` Dani Moncayo @ 2014-06-10 20:21 ` Eli Zaretskii 0 siblings, 0 replies; 38+ messages in thread From: Eli Zaretskii @ 2014-06-10 20:21 UTC (permalink / raw) To: Dani Moncayo; +Cc: eggert, emacs-devel > Date: Tue, 10 Jun 2014 21:25:02 +0200 > From: Dani Moncayo <dmoncayo@gmail.com> > Cc: Eli Zaretskii <eliz@gnu.org>, Emacs development discussions <emacs-devel@gnu.org> > > I've just tested Paul's patch in my MinGW/MSYS enviroment where I > usually build Emacs, and it seems to work flawlessly. In fact, the > output of "./autogen.sh && ./configure" is identical with or without > the patch. Thanks for testing. Paul, please commit your changes, and thanks. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-05 18:07 ` Eli Zaretskii 2014-06-05 19:35 ` Paul Eggert @ 2014-06-05 20:54 ` Stefan Monnier 1 sibling, 0 replies; 38+ messages in thread From: Stefan Monnier @ 2014-06-05 20:54 UTC (permalink / raw) To: Eli Zaretskii; +Cc: vincent.b.1, eggert, emacs-devel, dmoncayo >> >> case "$(uname -a)" in >> >> *MINGW* | *MinGW* ) ... >> >> esac >> >> wouldn't give the right answer. >> >> > How is that different from what config.guess already does? >> >> I'm not trying to replace config.guess nor am I trying to avoid >> duplicating it. >> I'm just trying to replace the >> >> if test "x$MSYSTEM" = "xMINGW32" -o "x$MSYSTEM" = "xMINGW64" >> >> in configure.ac since it turns out that $MSYSTEM may not be set. > I'm all for better alternatives, if they exist. I'm just not sure > that calling config.guess so early in the script is a good idea I'm not sure what you mean by "calling config.guess early". I don't suggest touching config.guess and/or the moment it's called. > We need some sign that we are configuring the MinGW build of Emacs, > and we need it very early in the script. That is all. $MSYSTEM is > just a handle to do that. That's what I understood and I simply suggest replacing if test "x$MSYSTEM" = "xMINGW32" -o "x$MSYSTEM" = "xMINGW64" with case "$(uname -a)" in *MINGW* | *MinGW* ) nothing more. I must say I have no idea whether such a test is more or less reliable, so I'll stop here. Stefan ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-04 21:50 ` Dani Moncayo 2014-06-05 0:42 ` Stefan Monnier @ 2014-06-05 2:47 ` Eli Zaretskii 1 sibling, 0 replies; 38+ messages in thread From: Eli Zaretskii @ 2014-06-05 2:47 UTC (permalink / raw) To: Dani Moncayo; +Cc: vincent.b.1, eggert, emacs-devel > Date: Wed, 4 Jun 2014 23:50:09 +0200 > From: Dani Moncayo <dmoncayo@gmail.com> > Cc: Vincent Belaïche <vincent.b.1@hotmail.fr>, > Paul Eggert <eggert@cs.ucla.edu>, Emacs development discussions <emacs-devel@gnu.org> > > Another option would be, perphaps, to check the environment > variable $OSTYPE (instead of $MSYSTEM). I've just done a quick > test on my system: if I invoke "bash.exe" (without "--login"), I > see that $OSTYPE holds "msys", while $MSYSTEM is undefined. (But > I don't know if this is also true in other MSYS flavors). $OSTYPE is not a global environment variable (try "env"). Besides, this only solves one problem, with --login. I hoped a more reliable method will be available that is independent of any variables (that can be unset). ^ permalink raw reply [flat|nested] 38+ messages in thread
* Using Qunsupported__w32_dialog 2014-06-03 21:15 ` Eli Zaretskii 2014-06-03 21:21 ` Vincent Belaïche @ 2014-06-04 12:22 ` Dmitry Antipov 2014-06-04 13:09 ` Eli Zaretskii 1 sibling, 1 reply; 38+ messages in thread From: Dmitry Antipov @ 2014-06-04 12:22 UTC (permalink / raw) To: Eli Zaretskii; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 211 bytes --] Eli, could you please review this? This is similar to r117255 but for popup dialogs, and Qunsupported__w32_dialog really confuses me (especially taking into account that I can't build for MS-Windows). Dmitry [-- Attachment #2: popup_dialog_hook.patch --] [-- Type: text/x-patch, Size: 9221 bytes --] === modified file 'src/menu.c' --- src/menu.c 2014-06-04 04:58:31 +0000 +++ src/menu.c 2014-06-04 12:07:36 +0000 @@ -1434,6 +1434,38 @@ return selection; } +/* If F's terminal is not capable to display popup dialog, + emulate it with a menu. */ + +Lisp_Object +emulate_dialog_with_menu (struct frame *f, Lisp_Object contents) +{ + Lisp_Object x, y, frame, newpos, prompt = Fcar (contents); + int x_coord, y_coord; + + if (FRAME_WINDOW_P (f)) + { + x_coord = FRAME_PIXEL_WIDTH (f); + y_coord = FRAME_PIXEL_HEIGHT (f); + } + else + { + x_coord = FRAME_COLS (f); + /* Center the title at frame middle. (TTY menus have + their upper-left corner at the given position.) */ + if (STRINGP (prompt)) + x_coord -= SCHARS (prompt); + y_coord = FRAME_LINES (f); + } + + XSETFRAME (frame, f); + XSETINT (x, x_coord / 2); + XSETINT (y, y_coord / 2); + newpos = list2 (list2 (x, y), frame); + + return Fx_popup_menu (newpos, list2 (prompt, contents)); +} + DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 3, 0, doc: /* Pop up a dialog box and return user's selection. POSITION specifies which frame to use. @@ -1466,24 +1498,7 @@ if (EQ (position, Qt) || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar) || EQ (XCAR (position), Qtool_bar)))) - { -#if 0 /* Using the frame the mouse is on may not be right. */ - /* Use the mouse's current position. */ - struct frame *new_f = SELECTED_FRAME (); - Lisp_Object bar_window; - enum scroll_bar_part part; - Time time; - Lisp_Object x, y; - - (*mouse_position_hook) (&new_f, 1, &bar_window, &part, &x, &y, &time); - - if (new_f != 0) - XSETFRAME (window, new_f); - else - window = selected_window; -#endif - window = selected_window; - } + window = selected_window; else if (CONSP (position)) { Lisp_Object tem = XCAR (position); @@ -1525,51 +1540,12 @@ string contents, because Fredisplay may GC and relocate them. */ Fredisplay (Qt); -#if defined USE_X_TOOLKIT || defined USE_GTK - if (FRAME_WINDOW_P (f)) - return xw_popup_dialog (f, header, contents); -#endif -#ifdef HAVE_NTGUI - if (FRAME_W32_P (f)) - { - Lisp_Object selection = w32_popup_dialog (f, header, contents); - - if (!EQ (selection, Qunsupported__w32_dialog)) - return selection; - } -#endif -#ifdef HAVE_NS - if (FRAME_NS_P (f)) - return ns_popup_dialog (position, header, contents); -#endif - /* Display a menu with these alternatives - in the middle of frame F. */ - { - Lisp_Object x, y, frame, newpos, prompt; - int x_coord, y_coord; - - prompt = Fcar (contents); - if (FRAME_WINDOW_P (f)) - { - x_coord = FRAME_PIXEL_WIDTH (f); - y_coord = FRAME_PIXEL_HEIGHT (f); - } - else - { - x_coord = FRAME_COLS (f); - /* Center the title at frame middle. (TTY menus have their - upper-left corner at the given position.) */ - if (STRINGP (prompt)) - x_coord -= SCHARS (prompt); - y_coord = FRAME_LINES (f); - } - XSETFRAME (frame, f); - XSETINT (x, x_coord / 2); - XSETINT (y, y_coord / 2); - newpos = list2 (list2 (x, y), frame); - - return Fx_popup_menu (newpos, list2 (prompt, contents)); - } + /* Display the popup dialog by a terminal-specific hook ... */ + if (FRAME_TERMINAL (f)->popup_dialog_hook) + return FRAME_TERMINAL (f)->popup_dialog_hook (f, header, contents); + + /* ... or emulate it with a menu. */ + return emulate_dialog_with_menu (f, contents); } void === modified file 'src/menu.h' --- src/menu.h 2014-06-04 04:58:31 +0000 +++ src/menu.h 2014-06-04 12:07:43 +0000 @@ -22,10 +22,6 @@ #include "systime.h" /* for Time */ #include "../lwlib/lwlib-widget.h" -#ifdef HAVE_NTGUI -extern Lisp_Object Qunsupported__w32_dialog; -#endif - /* Bit fields used by terminal-specific menu_show_hook. */ enum { @@ -72,4 +68,6 @@ extern Lisp_Object tty_menu_show (struct frame *, int, int, int, Lisp_Object, const char **); extern ptrdiff_t menu_item_width (const unsigned char *); +extern Lisp_Object emulate_dialog_with_menu (struct frame *, Lisp_Object); + #endif /* MENU_H */ === modified file 'src/nsmenu.m' --- src/nsmenu.m 2014-06-04 04:58:31 +0000 +++ src/nsmenu.m 2014-06-04 11:52:07 +0000 @@ -1428,11 +1428,10 @@ Lisp_Object -ns_popup_dialog (Lisp_Object position, Lisp_Object header, Lisp_Object contents) +ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents) { id dialog; Lisp_Object window, tem, title; - struct frame *f; NSPoint p; BOOL isQ; NSAutoreleasePool *pool; @@ -1441,41 +1440,6 @@ isQ = NILP (header); - if (EQ (position, Qt) - || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar) - || EQ (XCAR (position), Qtool_bar)))) - { - window = selected_window; - } - else if (CONSP (position)) - { - Lisp_Object tem; - tem = Fcar (position); - if (XTYPE (tem) == Lisp_Cons) - window = Fcar (Fcdr (position)); - else - { - tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ - window = Fcar (tem); /* POSN_WINDOW (tem) */ - } - } - else if (WINDOWP (position) || FRAMEP (position)) - { - window = position; - } - else - window = Qnil; - - if (FRAMEP (window)) - f = XFRAME (window); - else if (WINDOWP (window)) - { - CHECK_LIVE_WINDOW (window); - f = XFRAME (WINDOW_FRAME (XWINDOW (window))); - } - else - CHECK_WINDOW (window); - check_window_system (f); p.x = (int)f->left_pos + ((int)FRAME_COLUMN_WIDTH (f) * f->text_cols)/2; === modified file 'src/nsterm.h' --- src/nsterm.h 2014-05-26 11:16:47 +0000 +++ src/nsterm.h 2014-06-04 12:13:45 +0000 @@ -855,7 +855,7 @@ extern Lisp_Object find_and_return_menu_selection (struct frame *f, bool keymaps, void *client_data); -extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object header, +extern Lisp_Object ns_popup_dialog (struct frame *, Lisp_Object header, Lisp_Object contents); #define NSAPP_DATA2_RUNASSCRIPT 10 === modified file 'src/nsterm.m' --- src/nsterm.m 2014-06-04 04:58:31 +0000 +++ src/nsterm.m 2014-06-04 11:58:49 +0000 @@ -4165,6 +4165,7 @@ terminal->frame_raise_lower_hook = ns_frame_raise_lower; terminal->fullscreen_hook = ns_fullscreen_hook; terminal->menu_show_hook = ns_menu_show; + terminal->popup_dialog_hook = ns_popup_dialog; terminal->set_vertical_scroll_bar_hook = ns_set_vertical_scroll_bar; terminal->condemn_scroll_bars_hook = ns_condemn_scroll_bars; terminal->redeem_scroll_bar_hook = ns_redeem_scroll_bar; === modified file 'src/termhooks.h' --- src/termhooks.h 2014-06-04 04:58:31 +0000 +++ src/termhooks.h 2014-06-04 12:00:07 +0000 @@ -482,6 +482,10 @@ Lisp_Object (*menu_show_hook) (struct frame *f, int x, int y, int menuflags, Lisp_Object title, const char **error_name); + /* This hook is called to display popup dialog. */ + Lisp_Object (*popup_dialog_hook) (struct frame *f, Lisp_Object header, + Lisp_Object contents); + /* Scroll bar hooks. */ /* The representation of scroll bars is determined by the code which === modified file 'src/w32menu.c' --- src/w32menu.c 2014-06-04 04:58:31 +0000 +++ src/w32menu.c 2014-06-04 12:07:50 +0000 @@ -98,7 +98,8 @@ MessageBoxW_Proc unicode_message_box = NULL; #endif /* NTGUI_UNICODE */ -Lisp_Object Qdebug_on_next_call, Qunsupported__w32_dialog; +Lisp_Object Qdebug_on_next_call; +static Lisp_Object Qunsupported__w32_dialog; void set_frame_menubar (struct frame *, bool, bool); @@ -148,6 +149,8 @@ FRAME_DISPLAY_INFO (f)->grabbed = 0; if (error_name) error (error_name); + if (EQ (selection, Qunsupported__w32_dialog)) + return emulate_dialog_with_menu (f, contents); return selection; } #endif /* HAVE_DIALOGS */ === modified file 'src/w32term.c' --- src/w32term.c 2014-06-04 04:58:31 +0000 +++ src/w32term.c 2014-06-04 11:58:08 +0000 @@ -6274,6 +6274,7 @@ terminal->frame_raise_lower_hook = w32_frame_raise_lower; terminal->fullscreen_hook = w32fullscreen_hook; terminal->menu_show_hook = w32_menu_show; + terminal->popup_dialog_hook = w32_popup_dialog; terminal->set_vertical_scroll_bar_hook = w32_set_vertical_scroll_bar; terminal->condemn_scroll_bars_hook = w32_condemn_scroll_bars; terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar; === modified file 'src/xterm.c' --- src/xterm.c 2014-06-04 04:58:31 +0000 +++ src/xterm.c 2014-06-04 11:59:10 +0000 @@ -10533,6 +10533,9 @@ terminal->frame_raise_lower_hook = XTframe_raise_lower; terminal->fullscreen_hook = XTfullscreen_hook; terminal->menu_show_hook = x_menu_show; +#if defined (USE_X_TOOLKIT) || defined (USE_GTK) + terminal->popup_dialog_hook = xw_popup_dialog; +#endif terminal->set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar; terminal->condemn_scroll_bars_hook = XTcondemn_scroll_bars; terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar; ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Using Qunsupported__w32_dialog 2014-06-04 12:22 ` Using Qunsupported__w32_dialog Dmitry Antipov @ 2014-06-04 13:09 ` Eli Zaretskii 2014-06-04 13:37 ` Dmitry Antipov 0 siblings, 1 reply; 38+ messages in thread From: Eli Zaretskii @ 2014-06-04 13:09 UTC (permalink / raw) To: Dmitry Antipov; +Cc: emacs-devel > Date: Wed, 04 Jun 2014 16:22:00 +0400 > From: Dmitry Antipov <dmantipov@yandex.ru> > CC: emacs-devel@gnu.org > > could you please review this? This is similar to r117255 but for > popup dialogs, and Qunsupported__w32_dialog really confuses me > (especially taking into account that I can't build for MS-Windows). The patch looks good, except for one gotcha: > + /* Display the popup dialog by a terminal-specific hook ... */ > + if (FRAME_TERMINAL (f)->popup_dialog_hook) > + return FRAME_TERMINAL (f)->popup_dialog_hook (f, header, contents); > + > + /* ... or emulate it with a menu. */ > + return emulate_dialog_with_menu (f, contents); This is incorrect for MS-Windows (and is indeed related to the Qunsupported__w32_dialog thingy). The problem here is that Emacs on MS-Windows does support dialogs, but only "simple" ones, those that have only Yes/No choices. Dialogs that require more alternatives, or alternatives other than Yes/No, are not yet supported (the relevant code is incomplete and ifdef'ed away). Since many dialogs used by Emacs _are_ "simple", we don't want to lose support for these dialogs, and so the popup_dialog_hook should not be NULL on Windows. So instead we do provide w32_popup_dialog, but if it encounters a dialog structure it cannot support, it returns a special value 'unsupported--w32-dialog', which is a signal for the caller (x-popup-dialog) to call the emulation routine instead. Therefore, the snippet above should instead say something like this: /* Display the popup dialog by a terminal-specific hook ... */ if (FRAME_TERMINAL (f)->popup_dialog_hook) { Lisp_Object val = FRAME_TERMINAL (f)->popup_dialog_hook (f, header, contents); if (!EQ (val, Qunsupported__w32_dialog)) return val; } /* ... or emulate it with a menu. */ return emulate_dialog_with_menu (f, contents); And I think this means Qunsupported__w32_dialog cannot be static. Thanks. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Using Qunsupported__w32_dialog 2014-06-04 13:09 ` Eli Zaretskii @ 2014-06-04 13:37 ` Dmitry Antipov 2014-06-04 13:47 ` Eli Zaretskii 0 siblings, 1 reply; 38+ messages in thread From: Dmitry Antipov @ 2014-06-04 13:37 UTC (permalink / raw) To: Eli Zaretskii; +Cc: emacs-devel On 06/04/2014 05:09 PM, Eli Zaretskii wrote: > Therefore, the snippet above should instead say something like this: > > /* Display the popup dialog by a terminal-specific hook ... */ > if (FRAME_TERMINAL (f)->popup_dialog_hook) > { > Lisp_Object val = > FRAME_TERMINAL (f)->popup_dialog_hook (f, header, contents); > > if (!EQ (val, Qunsupported__w32_dialog)) > return val; > } > > /* ... or emulate it with a menu. */ > return emulate_dialog_with_menu (f, contents); > > And I think this means Qunsupported__w32_dialog cannot be static. Hm... I would like to see Qunsupported__w32_dialog as a local Windows-specific workaround, and let w32_popup_dialog call emulate_dialog_with_menu in case of unsupported dialog structure. So, to preserve the proposed end of Fx_popup_dialog: /* Display the popup dialog by a terminal-specific hook ... */ if (FRAME_TERMINAL (f)->popup_dialog_hook) return FRAME_TERMINAL (f)->popup_dialog_hook (f, header, contents); /* ... or emulate it with a menu. */ return emulate_dialog_with_menu (f, contents); MS-Windows stuff should be: Lisp_Object w32_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents) { Lisp_Object selection; check_window_system (f); #ifndef HAVE_DIALOGS /* Handle simple Yes/No choices as MessageBox popups. */ if (is_simple_dialog (contents)) selection = simple_dialog_show (f, contents, header); else selection = Qunsupported__w32_dialog; #else /* HAVE_DIALOGS */ { Lisp_Object title; char *error_name; /* Decode the dialog items from what was specified. */ title = Fcar (contents); CHECK_STRING (title); list_of_panes (Fcons (contents, Qnil)); /* Display them in a dialog box. */ block_input (); selection = w32_dialog_show (f, title, header, &error_name); unblock_input (); discard_menu_items (); FRAME_DISPLAY_INFO (f)->grabbed = 0; if (error_name) error (error_name); } #endif /* HAVE_DIALOGS */ return (EQ (selection, Qunsupported__w32_dialog) ? emulate_dialog_with_menu (f, contents) : selection); } IIUC this should have the same behavior as the old code, isn't it? Dmitry ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Using Qunsupported__w32_dialog 2014-06-04 13:37 ` Dmitry Antipov @ 2014-06-04 13:47 ` Eli Zaretskii 2014-06-04 14:06 ` Eli Zaretskii 0 siblings, 1 reply; 38+ messages in thread From: Eli Zaretskii @ 2014-06-04 13:47 UTC (permalink / raw) To: Dmitry Antipov; +Cc: emacs-devel > Date: Wed, 04 Jun 2014 17:37:46 +0400 > From: Dmitry Antipov <dmantipov@yandex.ru> > CC: emacs-devel@gnu.org > > On 06/04/2014 05:09 PM, Eli Zaretskii wrote: > > > Therefore, the snippet above should instead say something like this: > > > > /* Display the popup dialog by a terminal-specific hook ... */ > > if (FRAME_TERMINAL (f)->popup_dialog_hook) > > { > > Lisp_Object val = > > FRAME_TERMINAL (f)->popup_dialog_hook (f, header, contents); > > > > if (!EQ (val, Qunsupported__w32_dialog)) > > return val; > > } > > > > /* ... or emulate it with a menu. */ > > return emulate_dialog_with_menu (f, contents); > > > > And I think this means Qunsupported__w32_dialog cannot be static. > > Hm... I would like to see Qunsupported__w32_dialog as a local > Windows-specific workaround, and let w32_popup_dialog call > emulate_dialog_with_menu in case of unsupported dialog structure. Why? What does this gain us? > So, to preserve the proposed end of Fx_popup_dialog: > > /* Display the popup dialog by a terminal-specific hook ... */ > if (FRAME_TERMINAL (f)->popup_dialog_hook) > return FRAME_TERMINAL (f)->popup_dialog_hook (f, header, contents); > > /* ... or emulate it with a menu. */ > return emulate_dialog_with_menu (f, contents); > > MS-Windows stuff should be: > > Lisp_Object > w32_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents) > { > Lisp_Object selection; > > check_window_system (f); > > #ifndef HAVE_DIALOGS > /* Handle simple Yes/No choices as MessageBox popups. */ > if (is_simple_dialog (contents)) > selection = simple_dialog_show (f, contents, header); > else > selection = Qunsupported__w32_dialog; > #else /* HAVE_DIALOGS */ > { > Lisp_Object title; > char *error_name; > > /* Decode the dialog items from what was specified. */ > title = Fcar (contents); > CHECK_STRING (title); > > list_of_panes (Fcons (contents, Qnil)); > > /* Display them in a dialog box. */ > block_input (); > selection = w32_dialog_show (f, title, header, &error_name); > unblock_input (); > > discard_menu_items (); > FRAME_DISPLAY_INFO (f)->grabbed = 0; > > if (error_name) error (error_name); > } > #endif /* HAVE_DIALOGS */ > return (EQ (selection, Qunsupported__w32_dialog) ? > emulate_dialog_with_menu (f, contents) : selection); > } > > IIUC this should have the same behavior as the old code, isn't it? More or less, but how is this better? For starters, you now have emulate_dialog_with_menu extern instead of static, and it is called from 2 places rather than one. I don't see the gain here. I can put the explanation of why we need Qunsupported__w32_dialog in comments, if that would help. Btw, the part of your patch that does this: @@ -148,6 +149,8 @@ FRAME_DISPLAY_INFO (f)->grabbed = 0; if (error_name) error (error_name); + if (EQ (selection, Qunsupported__w32_dialog)) + return emulate_dialog_with_menu (f, contents); return selection; } #endif /* HAVE_DIALOGS */ is unnecessary: the HAVE_DIALOGS code will never return this special value. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Using Qunsupported__w32_dialog 2014-06-04 13:47 ` Eli Zaretskii @ 2014-06-04 14:06 ` Eli Zaretskii 0 siblings, 0 replies; 38+ messages in thread From: Eli Zaretskii @ 2014-06-04 14:06 UTC (permalink / raw) To: dmantipov; +Cc: emacs-devel > Date: Wed, 04 Jun 2014 16:47:37 +0300 > From: Eli Zaretskii <eliz@gnu.org> > Cc: emacs-devel@gnu.org > > > Hm... I would like to see Qunsupported__w32_dialog as a local > > Windows-specific workaround, and let w32_popup_dialog call > > emulate_dialog_with_menu in case of unsupported dialog structure. > > Why? What does this gain us? Btw, if the problem is with the name, we could rename that symbol to something like Qunsupported__dialog_type, and other frame types could then use it if and when needed. ^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: Latest EMACS on BZR trunk does not compile with MinGW 2014-06-03 20:00 Latest EMACS on BZR trunk does not compile with MinGW Vincent Belaïche 2014-06-03 20:22 ` Paul Eggert @ 2014-06-03 21:14 ` Eli Zaretskii 1 sibling, 0 replies; 38+ messages in thread From: Eli Zaretskii @ 2014-06-03 21:14 UTC (permalink / raw) To: Vincent Belaïche; +Cc: emacs-devel > From: Vincent Belaïche <vincent.b.1@hotmail.fr> > Date: Tue, 03 Jun 2014 22:00:02 +0200 > > Here is what I get: > > dup2.c:35:0: warning: "WIN32_LEAN_AND_MEAN" redefined [enabled by default] > c:/Programme/GNU/installation/emacs-install/emacs/trunk/nt/inc/ms-w32.h:148:0: note: this is the location of the previous definition > dup2.c:38:26: fatal error: msvc-inval.h: No such file or directory > compilation terminated. lib/dup2.c isn't supposed to be compiled in the MinGW build. My config.log says: configure:23230: checking whether dup2 works configure:23307: result: yes Please look at yours to find out why it thought dup2 didn't work, and tried to build a gnulib "replacement". > msvc-inval.h, given its naming, is probably a file from the MS Visual C > compiler suite No, it's a gnulib file which is not imported from gnulib, because dup2.c shouldn't be compiled on Windows. > Maybe the > > `&& ! defined __CYGWIN__' > > wherever used in this file for this topic should be replaced by > > `&& defined _MSC_VER' > > or something like that --- I cannot remember exactly the #definition > that one can use to detect MSVC compiler. > > An alternative would be to use > > `&& ! defined __CYGWIN__ && ! defined __MINGW32__' > > but well, if the msvc_xxx.h file are MSVC specific, I would prefer the > other one. We don't want lib/dup2.c on Windows, the one that comes with the usual runtime is good enough. ^ permalink raw reply [flat|nested] 38+ messages in thread
end of thread, other threads:[~2014-06-10 20:21 UTC | newest] Thread overview: 38+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-06-03 20:00 Latest EMACS on BZR trunk does not compile with MinGW Vincent Belaïche 2014-06-03 20:22 ` Paul Eggert 2014-06-03 20:56 ` Óscar Fuentes 2014-06-03 21:15 ` Eli Zaretskii 2014-06-03 21:21 ` Vincent Belaïche 2014-06-04 6:47 ` Eli Zaretskii 2014-06-04 13:17 ` Vincent Belaïche 2014-06-04 13:31 ` Eli Zaretskii 2014-06-04 15:28 ` Vincent Belaïche 2014-06-04 15:44 ` Eli Zaretskii 2014-06-04 15:54 ` Dani Moncayo 2014-06-04 16:05 ` Eli Zaretskii 2014-06-04 21:50 ` Dani Moncayo 2014-06-05 0:42 ` Stefan Monnier 2014-06-05 2:51 ` Eli Zaretskii 2014-06-05 3:40 ` Óscar Fuentes 2014-06-05 7:03 ` Dani Moncayo 2014-06-05 9:03 ` Vincent Belaïche 2014-06-05 15:09 ` Eli Zaretskii 2014-06-05 14:51 ` Eli Zaretskii 2014-06-05 16:19 ` Óscar Fuentes 2014-06-05 17:52 ` Eli Zaretskii 2014-06-05 13:31 ` Stefan Monnier 2014-06-05 15:15 ` Eli Zaretskii 2014-06-05 16:50 ` Stefan Monnier 2014-06-05 18:07 ` Eli Zaretskii 2014-06-05 19:35 ` Paul Eggert 2014-06-05 19:54 ` Eli Zaretskii 2014-06-10 19:25 ` Dani Moncayo 2014-06-10 20:21 ` Eli Zaretskii 2014-06-05 20:54 ` Stefan Monnier 2014-06-05 2:47 ` Eli Zaretskii 2014-06-04 12:22 ` Using Qunsupported__w32_dialog Dmitry Antipov 2014-06-04 13:09 ` Eli Zaretskii 2014-06-04 13:37 ` Dmitry Antipov 2014-06-04 13:47 ` Eli Zaretskii 2014-06-04 14:06 ` Eli Zaretskii 2014-06-03 21:14 ` Latest EMACS on BZR trunk does not compile with MinGW Eli Zaretskii
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.