add w32-ime support to emacs with Windows GUI and various modifications
--- ./configure.ac.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./configure.ac 2015-04-11 07:27:30.430112300 +0900 | |
@@ -263,6 +263,12 @@ | |
OPTION_DEFAULT_OFF([ns],[use NeXTstep (Cocoa or GNUstep) windowing system]) | |
OPTION_DEFAULT_OFF([w32], [use native MS Windows GUI in a Cygwin build]) | |
+OPTION_DEFAULT_ON([w32-ime], [don't compile with W32-IME support]) | |
+OPTION_DEFAULT_ON([reconversion], [don't compile with RECONVERSION support]) | |
+OPTION_DEFAULT_ON([documentfeed], [don't compile with DOCUMENTFEED support]) | |
+ | |
+OPTION_DEFAULT_ON([cmigemo], [don't compile with CMIGEMO support]) | |
+ | |
OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console]) | |
OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support]) | |
OPTION_DEFAULT_ON([gconf],[don't compile with GConf support]) | |
@@ -2236,7 +2242,7 @@ | |
### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified. | |
HAVE_RSVG=no | |
-if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then | |
+if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}" = "yes"; then | |
if test "${with_rsvg}" != "no"; then | |
RSVG_REQUIRED=2.11.0 | |
RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED" | |
@@ -5006,6 +5012,50 @@ | |
acl_summary=no | |
fi | |
+USE_W32_IME=no | |
+if test "${HAVE_W32}" = "yes"; then | |
+ if test "${with_w32_ime}" != "no"; then | |
+ USE_W32_IME=yes | |
+ AC_DEFINE(USE_W32_IME, 1, [Define to support W32-IME.]) | |
+ | |
+ RECONVERSION=no | |
+ if test "${with_reconversion}" != "no"; then | |
+ AC_CACHE_CHECK([whether RECONVERTSTRING is declared], | |
+ emacs_cv_have_reconvertstring, | |
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | |
+#include <windows.h> | |
+#include <imm.h>]], [[RECONVERTSTRING]])], | |
+ emacs_cv_have_reconvertstring=yes, emacs_cv_have_reconvertstring=no)]) | |
+ if test "$emacs_cv_have_reconvertstring" = "yes"; then | |
+ RECONVERSION=yes | |
+ AC_DEFINE(RECONVERSION, 1, [Define to support RECONVERSION.]) | |
+ AC_DEFINE(HAVE_RECONVERTSTRING, 1, [Define to 1 if you have RECONVERTSTRING.]) | |
+ | |
+ DOCUMENTFEED=no | |
+ if test "${with_documentfeed}" != "no"; then | |
+ AC_CHECK_DECL(IMR_DOCUMENTFEED, HAVE_IMR_DOCUMENTFEED=yes, | |
+ HAVE_IMR_DOCUMENTFEED=no,[[ | |
+#include <windows.h> | |
+#include <imm.h>]]) | |
+ if test "$ac_cv_have_decl_IMR_DOCUMENTFEED" = "yes"; then | |
+ DOCUMENTFEED=yes | |
+ AC_DEFINE(DOCUMENTFEED, 1, [Define to support DOCUMENTFEED.]) | |
+ AC_DEFINE(HAVE_IMR_DOCUMENTFEED, 1, [Define to 1 if you have IMR_DOCUMENTFEED.]) | |
+ fi | |
+ fi | |
+ fi | |
+ fi | |
+ fi | |
+fi | |
+ | |
+HAVE_CMIGEMO=no | |
+if test "${with_cmigemo}" != "no"; then | |
+ AC_CHECK_HEADER(migemo.h, HAVE_CMIGEMO=yes) | |
+ if test "${HAVE_CMIGEMO}" = "yes"; then | |
+ AC_DEFINE(HAVE_CMIGEMO, 1, [Define to 1 if you have the "migemo.h" header file.]) | |
+ fi | |
+fi | |
+ | |
echo " | |
Configured for \`${canonical}'. | |
@@ -5056,6 +5106,20 @@ | |
echo " Does Emacs directly use zlib? ${HAVE_ZLIB}" | |
echo " Does Emacs use toolkit scroll bars? ${USE_TOOLKIT_SCROLL_BARS}" | |
+ | |
+if test "${HAVE_W32}" = "yes"; then | |
+ echo \ | |
+ " Does Emacs support W32-IME? ${USE_W32_IME}" | |
+ if test "${USE_W32_IME}" = "yes"; then | |
+ echo \ | |
+ " Does Emacs support RECONVERSION? ${RECONVERSION}" | |
+ if test "${RECONVERSION}" = "yes"; then | |
+ echo \ | |
+ " Does Emacs support DOCUMENTFEED? ${DOCUMENTFEED}" | |
+ fi | |
+ fi | |
+fi | |
+echo " Does Emacs use a cmigemo library? ${HAVE_CMIGEMO}" | |
echo | |
if test -n "${EMACSDATA}"; then | |
--- ./lib-src/make-docfile.c.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./lib-src/make-docfile.c 2015-04-11 07:27:30.436116800 +0900 | |
@@ -50,6 +50,7 @@ | |
#endif /* WINDOWSNT */ | |
#ifdef DOS_NT | |
+#include <mbstring.h> | |
/* Defined to be sys_chdir in ms-w32.h, but only #ifdef emacs, so this | |
is really just insurance. | |
@@ -209,10 +210,18 @@ | |
{ | |
char *tmp; | |
+#ifdef DOS_NT | |
+ for (tmp = filename; *tmp; tmp = _mbsinc (tmp)) | |
+#else | |
for (tmp = filename; *tmp; tmp++) | |
+#endif | |
{ | |
if (IS_DIRECTORY_SEP (*tmp)) | |
+#ifdef DOS_NT | |
+ filename = _mbsinc (tmp); | |
+#else | |
filename = tmp + 1; | |
+#endif | |
} | |
putc (037, outfile); | |
--- ./lib-src/ntlib.c.orig 2015-02-02 02:27:17.000000000 +0900 | |
+++ ./lib-src/ntlib.c 2015-04-11 07:27:30.445112900 +0900 | |
@@ -370,7 +370,7 @@ | |
} | |
else | |
{ | |
- if (IS_DIRECTORY_SEP (name[len-1])) | |
+ if (IS_DIRECTORY_SEP (*_mbsdec(name, name + len))) | |
name[len - 1] = 0; | |
fh = FindFirstFile (name, &wfd); | |
--- ./lib-src/ntlib.h.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./lib-src/ntlib.h 2015-04-11 07:27:30.453111600 +0900 | |
@@ -90,6 +90,7 @@ | |
#define locking _locking | |
#define logb _logb | |
#define _longjmp longjmp | |
+#undef lseek | |
#define lseek _lseek | |
#define popen _popen | |
#define pclose _pclose | |
--- ./lisp/cedet/cedet-cscope.el.orig 2015-02-02 02:27:17.000000000 +0900 | |
+++ ./lisp/cedet/cedet-cscope.el 2015-04-11 07:27:30.477113600 +0900 | |
@@ -77,7 +77,7 @@ | |
"Create a CScope database at the current directory. | |
FLAGS are additional flags to pass to cscope beyond the | |
options -cR." | |
- (cedet-cscope-call (append (list "-cR") flags))) | |
+ (cedet-cscope-call (append (list "-bcR") flags))) | |
(defun cedet-cscope-call (flags) | |
"Call CScope with the list of FLAGS." | |
@@ -151,7 +151,7 @@ | |
nil) | |
(with-current-buffer b | |
(goto-char (point-min)) | |
- (re-search-forward "cscope: version \\([0-9.]+\\)" nil t) | |
+ (re-search-forward "cscope\\(?:\\.exe\\)?: version \\([0-9.]+\\)" nil t) | |
(setq rev (match-string 1)) | |
(if (inversion-check-version rev nil cedet-cscope-min-version) | |
(if noerror | |
--- ./lisp/image.el.orig 2015-02-02 02:27:17.000000000 +0900 | |
+++ ./lisp/image.el 2015-04-11 07:27:30.481113200 +0900 | |
@@ -126,6 +126,15 @@ | |
:type '(repeat (choice directory variable)) | |
:initialize 'custom-initialize-delay) | |
+;;;###autoload | |
+(defcustom image-fit-option-alist nil | |
+ "Alist of (IMAGE-TYPE . FIT-OPTION) pairs used by image loader to specify image size. | |
+the FIT-OPTION is one of 'never, 'frame, 'width-or-height, 'width or 'height. | |
+Note: All image loaders are not supporting this `fit' capability. | |
+" | |
+ :type 'sexp | |
+ :initialize 'custom-initialize-default | |
+ :group 'image) | |
(defun image-load-path-for-library (library image &optional path no-error) | |
"Return a suitable search path for images used by LIBRARY. | |
--- /dev/null 2015-04-11 07:27:55.000000000 +0900 | |
+++ ./lisp/international/w32-ime.el 2015-04-11 07:27:30.485113300 +0900 | |
@@ -0,0 +1,201 @@ | |
+;;;;; w32-ime.el ---- Meadow features for NTEmacs. | |
+;; | |
+;; Author H.Miyashita | |
+;; | |
+;;;;; | |
+ | |
+(defgroup W32-IME nil | |
+ "w32-ime" | |
+ :group 'emacs) | |
+ | |
+(defvar w32-last-selection nil | |
+ "It is stored the last data from Emacs.") | |
+ | |
+;---------- | |
+ | |
+(defvar w32-ime-on-hook nil | |
+ "Functions to eval when IME is turned on at least. | |
+Even if IME state is not changed, these functiona are maybe called.") | |
+(defvar w32-ime-off-hook nil | |
+ "Functions to eval when IME is turned off at least. | |
+Even if IME state is not changed, these functiona are maybe called.") | |
+(defvar w32-ime-buffer-switch-p t | |
+ "If this variable is nil, IME control when buffer is switched is disabled.") | |
+(defvar w32-ime-show-mode-line t | |
+ "When t, mode line indicates IME state.") | |
+(defvar w32-ime-mode-line-state-indicator "[O]" | |
+ "This is shown at the mode line. It is regarded as state of ime.") | |
+(make-variable-buffer-local 'w32-ime-mode-line-state-indicator) | |
+(put 'w32-ime-mode-line-state-indicator 'permanent-local t) | |
+(defvar w32-ime-mode-line-state-indicator-list '("-" "[|]" "[O]") | |
+ "List of IME state indicator string.") | |
+(defvar w32-ime-mode-line-format-original nil | |
+ "Original mode line format.") | |
+ | |
+;; | |
+;; Section: IME | |
+;; | |
+ | |
+;; ;; This is temporal solution. In the future, we will prepare | |
+;; ;; dynamic configuration. | |
+;; (defvar w32-ime-coding-system-language-environment-alist | |
+;; '(("Japanese" . japanese-shift-jis) | |
+;; ("Chinese-GB" . chinese-iso-8bit) | |
+;; ("Chinese-BIG5" . chinese-big5) | |
+;; ("Korean" . korean-iso-8bit))) | |
+ | |
+;; | |
+;; IME state indicator | |
+;; | |
+(global-set-key [kanji] 'ignore) | |
+(global-set-key [compend] 'ignore) | |
+ | |
+(defun wrap-function-to-control-ime | |
+ (function interactive-p interactive-arg &optional suffix) | |
+ "Wrap FUNCTION, and IME control is enabled when FUNCTION is called. | |
+An original function is saved to FUNCTION-SUFFIX when suffix is string. | |
+If SUFFIX is nil, \"-original\" is added. " | |
+ (let ((original-function | |
+ (intern (concat (symbol-name function) | |
+ (if suffix suffix "-original"))))) | |
+ (cond | |
+ ((not (fboundp original-function)) | |
+ (fset original-function | |
+ (symbol-function function)) | |
+ (fset function | |
+ (list | |
+ 'lambda '(&rest arguments) | |
+ (when interactive-p | |
+ (list 'interactive interactive-arg)) | |
+ `(cond | |
+ ((and (ime-get-mode) | |
+ (equal current-input-method "W32-IME")) | |
+ (ime-force-off) | |
+ (unwind-protect | |
+ (apply ',original-function arguments) | |
+ (when (and (not (ime-get-mode)) | |
+ (equal current-input-method "W32-IME")) | |
+ (ime-force-on)))) | |
+ (t | |
+ (apply ',original-function arguments))))))))) | |
+ | |
+(defvar w32-ime-toroku-region-yomigana nil | |
+ "* if this variable is string, toroku-region regard this value as yomigana.") | |
+ | |
+(defun w32-ime-toroku-region (begin end) | |
+ (interactive "r") | |
+ (let ((string (buffer-substring begin end)) | |
+ (w32-ime-buffer-switch-p nil) | |
+ (reading w32-ime-toroku-region-yomigana)) | |
+ (unless (stringp reading) | |
+ (w32-set-ime-mode 'hiragana) | |
+ (setq reading | |
+ (read-multilingual-string | |
+ (format "Input reading of \"%s\": " string) nil "W32-IME"))) | |
+ (w32-ime-register-word-dialog reading string))) | |
+ | |
+;; for IME management system. | |
+ | |
+(defun w32-ime-sync-state (window) | |
+ (when w32-ime-buffer-switch-p | |
+ (with-current-buffer (window-buffer window) | |
+ (let* ((frame (window-frame window)) | |
+ (ime-state (ime-get-mode))) | |
+ (cond | |
+ ((and (not ime-state) | |
+ (equal current-input-method "W32-IME")) | |
+ (ime-force-on nil) | |
+ (run-hooks 'w32-ime-on-hook)) | |
+ ((and ime-state | |
+ (not (equal current-input-method "W32-IME"))) | |
+;;; (when (= (w32-ime-undetermined-string-length) 0) | |
+ (ime-force-off nil) | |
+ (run-hooks 'w32-ime-off-hook))))))) | |
+ | |
+(defun w32-ime-set-selected-window-buffer-hook (oldbuf newwin newbuf) | |
+ (w32-ime-sync-state newwin)) | |
+ | |
+(defun w32-ime-select-window-hook (old new) | |
+ (w32-ime-sync-state new)) | |
+ | |
+(defun w32-ime-mode-line-update () | |
+ (cond | |
+ (w32-ime-show-mode-line | |
+ (unless (window-minibuffer-p (selected-window)) | |
+ (setq w32-ime-mode-line-state-indicator | |
+ (nth (if (ime-get-mode) 1 2) | |
+ w32-ime-mode-line-state-indicator-list)))) | |
+ (t | |
+ (setq w32-ime-mode-line-state-indicator | |
+ (nth 0 w32-ime-mode-line-state-indicator-list)))) | |
+ (force-mode-line-update)) | |
+ | |
+(defun w32-ime-init-mode-line-display () | |
+ (unless (member 'w32-ime-mode-line-state-indicator mode-line-format) | |
+ (setq w32-ime-mode-line-format-original | |
+ (default-value 'mode-line-format)) | |
+ (if (and (stringp (car mode-line-format)) | |
+ (string= (car mode-line-format) "-")) | |
+ (setq-default mode-line-format | |
+ (cons "" | |
+ (cons 'w32-ime-mode-line-state-indicator | |
+ (cdr mode-line-format)))) | |
+ (setq-default mode-line-format | |
+ (cons "" | |
+ (cons 'w32-ime-mode-line-state-indicator | |
+ mode-line-format)))) | |
+ (force-mode-line-update t))) | |
+ | |
+(defun w32-ime-initialize () | |
+ (when (and (or (eq system-type 'windows-nt) (eq system-type 'cygwin)) | |
+ (eq window-system 'w32) | |
+ (featurep 'w32-ime)) | |
+ (w32-ime-init-mode-line-display) | |
+ (w32-ime-mode-line-update) | |
+ (add-hook 'select-window-functions | |
+ 'w32-ime-select-window-hook) | |
+ (add-hook 'set-selected-window-buffer-functions | |
+ 'w32-ime-set-selected-window-buffer-hook) | |
+ (define-key global-map [kanji] 'toggle-input-method))) | |
+;; (set-keyboard-coding-system 'utf-8))) | |
+ | |
+(defun w32-ime-uninitialize () | |
+ (when (and (or (eq system-type 'windows-nt) (eq system-type 'cygwin)) | |
+ (eq window-system 'w32) | |
+ (featurep 'w32-ime)) | |
+ (setq-default mode-line-format | |
+ w32-ime-mode-line-format-original) | |
+ (force-mode-line-update t) | |
+ (remove-hook 'select-window-functions | |
+ 'w32-ime-select-window-hook) | |
+ (remove-hook 'set-selected-window-buffer-functions | |
+ 'w32-ime-set-selected-window-buffer-hook) | |
+ (define-key global-map [kanji] 'ignore))) | |
+ | |
+(defun w32-ime-exit-from-minibuffer () | |
+ (deactivate-input-method) | |
+ (when (<= (minibuffer-depth) 1) | |
+ (remove-hook 'minibuffer-exit-hook 'w32-ime-exit-from-minibuffer))) | |
+ | |
+(defun w32-ime-state-switch (&optional arg) | |
+ (if arg | |
+ (progn | |
+ (setq deactivate-current-input-method-function | |
+ 'w32-ime-state-switch) | |
+ (run-hooks 'input-method-activate-hook) | |
+ (run-hooks 'w32-ime-on-hook) | |
+ (setq describe-current-input-method-function nil) | |
+ (when (eq (selected-window) (minibuffer-window)) | |
+ (add-hook 'minibuffer-exit-hook 'w32-ime-exit-from-minibuffer)) | |
+ (ime-force-on)) | |
+ (setq current-input-method nil) | |
+ (run-hooks 'input-method-deactivate-hook) | |
+ (run-hooks 'w32-ime-off-hook) | |
+ (setq describe-current-input-method-function nil) | |
+ (ime-force-off)) | |
+ (w32-ime-mode-line-update)) | |
+ | |
+(register-input-method "W32-IME" "Japanese" 'w32-ime-state-switch "" | |
+ "W32 System IME") | |
+ | |
+(provide 'w32-ime) | |
--- ./lisp/language/japan-util.el.orig 2015-02-02 02:27:17.000000000 +0900 | |
+++ ./lisp/language/japan-util.el 2015-04-11 07:27:30.491115400 +0900 | |
@@ -31,9 +31,11 @@ | |
(defun setup-japanese-environment-internal () | |
;; By default, we use 'japanese-iso-8bit for file names. But, the | |
;; following prefer-coding-system will override it. | |
- (if (memq system-type '(windows-nt ms-dos cygwin)) | |
+ (if (memq system-type '(windows-nt ms-dos)) | |
(prefer-coding-system 'japanese-shift-jis) | |
- (prefer-coding-system 'japanese-iso-8bit)) | |
+ (if (eq system-type 'cygwin) | |
+ (prefer-coding-system 'utf-8) | |
+ (prefer-coding-system 'japanese-iso-8bit))) | |
(use-cjk-char-width-table 'ja_JP)) | |
(defconst japanese-kana-table | |
--- ./lisp/loadup.el.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./lisp/loadup.el 2015-04-11 07:27:30.494115700 +0900 | |
@@ -250,6 +250,7 @@ | |
(load "term/w32-win") | |
(load "disp-table") | |
(load "w32-common-fns") | |
+ (load "international/w32-ime") | |
(when (eq system-type 'windows-nt) | |
(load "w32-fns") | |
(load "ls-lisp") | |
--- ./lisp/startup.el.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./lisp/startup.el 2015-04-11 07:27:30.499116000 +0900 | |
@@ -595,6 +595,7 @@ | |
(put 'user-full-name 'standard-value | |
(list (default-value 'user-full-name))) | |
;; If the PWD environment variable isn't accurate, delete it. | |
+ (set-language-environment "japanese") | |
(let ((pwd (getenv "PWD"))) | |
(and (stringp pwd) | |
;; Use FOO/., so that if FOO is a symlink, file-attributes | |
@@ -1630,7 +1631,7 @@ | |
(defun fancy-splash-head () | |
"Insert the head part of the splash screen into the current buffer." | |
(let* ((image-file (fancy-splash-image-file)) | |
- (img (create-image image-file)) | |
+ (img (create-image image-file nil nil :fit 'never)) | |
(image-width (and img (car (image-size img)))) | |
(window-width (window-width))) | |
(when img | |
--- ./nt/inc/sys/socket.h.orig 2015-02-02 02:27:17.000000000 +0900 | |
+++ ./nt/inc/sys/socket.h 2015-04-11 07:27:30.502115800 +0900 | |
@@ -99,7 +99,11 @@ | |
#define recvfrom sys_recvfrom | |
#define sendto sys_sendto | |
+#ifdef __MINGW64__ | |
+SOCKET sys_socket(int af, int type, int protocol); | |
+#else | |
int sys_socket(int af, int type, int protocol); | |
+#endif | |
int sys_bind (int s, const struct sockaddr *addr, int namelen); | |
int sys_connect (int s, const struct sockaddr *addr, int namelen); | |
u_short sys_htons (u_short hostshort); | |
--- /dev/null 2015-04-11 07:27:56.000000000 +0900 | |
+++ ./sample/lisp/site-init.el 2015-04-11 07:27:30.510115100 +0900 | |
@@ -0,0 +1,19 @@ | |
+;; | |
+;; image options | |
+;; | |
+(setq image-library-alist | |
+ '((xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll") | |
+ (png "libpng14-14.dll" "libpng14.dll" "libpng15.dll") | |
+ (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll" | |
+ "libjpeg-8.dll" "jpegdll.dll") | |
+ (tiff "libtiff3.dll" "libtiff.dll" "libtiff-3.dll") | |
+ (gif "giflib4.dll" "libungif4.dll" "libungif.dll") | |
+ (svg "librsvg-2-2.dll" "librsvg2.dll") | |
+ (gdk-pixbuf "libgdk_pixbuf-2.0-0.dll" "gdk_pixbuf-2-vs9.dll") | |
+ (glib "libglib-2.0-0.dll" "glib-2-vs9.dll" ) | |
+ (gobject "libgobject-2.0-0.dll" "gobject-2-vs9.dll"))) | |
+ | |
+(setq image-fit-option-alist | |
+ '((jpeg . frame) | |
+ (svg . width-or-height))) | |
+ | |
--- /dev/null 2015-04-11 07:27:57.000000000 +0900 | |
+++ ./sample/lisp/site-start.el 2015-04-11 07:27:30.515116900 +0900 | |
@@ -0,0 +1,10 @@ | |
+;; | |
+;; create init.el for japanese user | |
+;; | |
+(when (and (not noninteractive) | |
+ (eq (window-system) 'w32) | |
+ (= (w32-get-default-locale-id) 1041)) ; japanese? | |
+ (add-hook 'after-init-hook | |
+ #'(lambda () | |
+ (unless (file-exists-p user-init-file) | |
+ (load-library "ezsetup"))))) | |
\ No newline at end of file | |
--- /dev/null 2015-04-11 07:27:57.000000000 +0900 | |
+++ ./site-lisp/cmigemo.el 2015-04-11 07:27:30.524115400 +0900 | |
@@ -0,0 +1,811 @@ | |
+;;; migemo.el --- Japanese incremental search through dynamic pattern expansion | |
+ | |
+;; $Id: migemo.el.in,v 1.9 2012/06/24 04:09:59 kaworu Exp $ | |
+;; Copyright (C) Satoru Takabayashi | |
+ | |
+;; Author: Satoru Takabayashi <satoru-t@is.aist-nara.ac.jp> | |
+;; URL: https://github.com/emacs-jp/migemo | |
+;; Version: 1.9 | |
+;; Keywords: | |
+ | |
+;; This file is free software; you can redistribute it and/or modify | |
+;; it under the terms of the GNU General Public License as published by | |
+;; the Free Software Foundation; either version 2, or (at your option) | |
+;; any later version. | |
+ | |
+;; This file is distributed in the hope that it will be useful, | |
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
+;; GNU General Public License for more details. | |
+ | |
+;; You should have received a copy of the GNU General Public License | |
+;; along with GNU Emacs; see the file COPYING. If not, write to | |
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
+;; Boston, MA 02111-1307, USA. | |
+ | |
+;;; Commentary: | |
+ | |
+;; | |
+ | |
+;;; Code: | |
+(defgroup migemo nil | |
+ "migemo - Japanese incremental search trough dynamic pattern expansion." | |
+ :group 'matching) | |
+ | |
+(defcustom migemo-cmigemo-library "cmigemo.dll" | |
+ "*Name or full path of the cmigemo dynamic library." | |
+ :group 'migemo | |
+ :type 'string) | |
+ | |
+(defcustom migemo-command "ruby" | |
+ "*Name or full path of the executable for running migemo." | |
+ :group 'migemo | |
+ :type '(choice (const :tag "Ruby Migemo" "ruby") | |
+ (const :tag "CMIGEMO" "cmigemo") | |
+ (string :tag "Other"))) | |
+ | |
+;; -t emacs for specifying the type of regular expression. | |
+;; "-i" "\a" for searching a word over multi-lines. | |
+(defcustom migemo-options '("-S" "migemo" "-t" "emacs" "-i" "\a") | |
+ "*Options for migemo command." | |
+ :group 'migemo | |
+ :type '(repeat string)) | |
+ | |
+(defcustom migemo-white-space-regexp "[ ¡¡\t\r\n]*" | |
+ "*Regexp representing white spaces." | |
+ :group 'migemo | |
+ :type 'string) | |
+ | |
+;; for C/Migemo | |
+;; (setq migemo-command "cmigemo") | |
+;; (setq migemo-options '("-q" "--emacs" "-i" "\g")) | |
+;; (setq migemo-dictionary "somewhere/migemo/euc-jp/migemo-dict") | |
+;; (setq migemo-user-dictionary nil) | |
+;; (setq migemo-regex-dictionary nil)) | |
+ | |
+(defcustom migemo-directory | |
+ (if (eq system-type 'windows-nt) | |
+ (concat data-directory "migemo") | |
+ "/usr/local/share/migemo") | |
+ "*Directory where migemo files are placed" | |
+ :group 'migemo | |
+ :type 'directory) | |
+ | |
+(defcustom migemo-isearch-enable-p t | |
+ "*Enable the migemo feature on isearch or not." | |
+ :group 'migemo | |
+ :type 'boolean) | |
+ | |
+(defcustom migemo-dictionary | |
+ (expand-file-name (concat "utf-8" "/migemo-dict") migemo-directory) | |
+ "*Migemo dictionary file." | |
+ :group 'migemo | |
+ :type '(file :must-match t)) | |
+ | |
+(defcustom migemo-user-dictionary nil | |
+ "*Migemo user dictionary file." | |
+ :group 'migemo | |
+ :type '(choice (file :must-match t) | |
+ (const :tag "Do not use" nil))) | |
+ | |
+(defcustom migemo-regex-dictionary nil | |
+ "*Migemo regex dictionary file." | |
+ :group 'migemo | |
+ :type '(choice (file :must-match t) | |
+ (const :tag "Do not use" nil))) | |
+ | |
+(defcustom migemo-pre-conv-function nil | |
+ "*Function of migemo pre-conversion." | |
+ :group 'migemo | |
+ :type '(choice (const :tag "Do not use" nil) | |
+ function)) | |
+ | |
+(defcustom migemo-after-conv-function nil | |
+ "*Function of migemo after-conversion." | |
+ :group 'migemo | |
+ :type '(choice (const :tag "Do not use" nil) | |
+ function)) | |
+ | |
+(defcustom migemo-coding-system | |
+ (with-no-warnings | |
+ (if (>= emacs-major-version 20) | |
+ (if (featurep 'mule) | |
+ (if (string-match "XEmacs" emacs-version) | |
+ (cond | |
+ ((memq 'euc-japan-unix (coding-system-list)) 'euc-japan-unix) | |
+ ((memq 'euc-jp-unix (coding-system-list)) 'euc-jp-unix)) | |
+ 'euc-japan-unix)) | |
+ (and (boundp 'MULE) *euc-japan*unix))) | |
+ "*Default coding system for migemo.el" | |
+ :group 'migemo | |
+ :type 'coding-system) | |
+ | |
+(defcustom migemo-use-pattern-alist nil | |
+ "*Use pattern cache." | |
+ :group 'migemo | |
+ :type 'boolean) | |
+ | |
+(defcustom migemo-use-frequent-pattern-alist nil | |
+ "*Use frequent patttern cache." | |
+ :group 'migemo | |
+ :type 'boolean) | |
+ | |
+(defcustom migemo-pattern-alist-length 512 | |
+ "*Maximal length of migemo-pattern-alist." | |
+ :group 'migemo | |
+ :type 'integer) | |
+ | |
+(defcustom migemo-pattern-alist-file "~/.migemo-pattern" | |
+ "*Path of migemo alist file. If nil, don't save and restore the file." | |
+ :group 'migemo | |
+ :type 'file) | |
+ | |
+(defcustom migemo-frequent-pattern-alist-file "~/.migemo-frequent" | |
+ "*Path of migemo frequent alist file. If nil, don't save and restore the file." | |
+ :group 'migemo | |
+ :type 'file) | |
+ | |
+(defcustom migemo-accept-process-output-timeout-msec 5 | |
+ "*Timeout of migemo process communication." | |
+ :group 'migemo | |
+ :type 'integer) | |
+ | |
+(defcustom migemo-isearch-min-length 1 | |
+ "*Minimum length of word to start isearch." | |
+ :group 'migemo | |
+ :type 'integer) | |
+ | |
+(defconst migemo-mw32-input-method (and (featurep 'meadow) "MW32-IME") | |
+ "Support \"MW32-IME\" for Meadow.") | |
+ | |
+;; internal variables | |
+(defvar migemo-process nil) | |
+(defvar migemo-buffer nil) | |
+(defvar migemo-current-input-method nil) | |
+(defvar migemo-search-pattern nil) | |
+(defvar migemo-pattern-alist nil) | |
+(defvar migemo-frequent-pattern-alist nil) | |
+(defconst migemo-emacs21p (and (> emacs-major-version 20) (not (featurep 'xemacs)))) | |
+(defvar migemo-search-pattern-alist nil) | |
+(defvar migemo-do-isearch nil) | |
+(defvar cmigemo-initialized nil) | |
+ | |
+(defconst coding-system-for-japanese | |
+ (let ((cs (cdr (assoc 'coding-system | |
+ (assoc "Japanese" language-info-alist))))) | |
+ (append | |
+ (mapcar | |
+ #'(lambda (c) | |
+ (intern-soft (concat (symbol-name c) "-unix"))) cs) | |
+ (mapcar | |
+ #'(lambda (c) | |
+ (intern-soft (concat (symbol-name c) "-dos"))) cs) | |
+ (mapcar | |
+ #'(lambda (c) | |
+ (intern-soft (concat (symbol-name c) "-mac"))) cs)))) | |
+ | |
+;; For warnings of byte-compile. Following functions are defined in XEmacs | |
+(declare-function set-process-input-coding-system "code-process") | |
+(declare-function set-process-output-coding-system "code-process") | |
+ | |
+(defsubst migemo-search-pattern-get (string) | |
+ (let ((pattern (cdr (assoc string migemo-search-pattern-alist)))) | |
+ (unless pattern | |
+ (setq pattern (migemo-get-pattern string)) | |
+ (setq migemo-search-pattern-alist | |
+ (cons (cons string pattern) | |
+ migemo-search-pattern-alist))) | |
+ pattern)) | |
+ | |
+(defun migemo-toggle-isearch-enable () | |
+ (interactive) | |
+ (setq migemo-isearch-enable-p (not migemo-isearch-enable-p)) | |
+ (message (if migemo-isearch-enable-p | |
+ "t" | |
+ "nil"))) | |
+ | |
+(defun migemo-start-process (name buffer program args) | |
+ (let ((proc (apply 'start-process name buffer program args))) | |
+ (if (fboundp 'set-process-coding-system) | |
+ (set-process-coding-system proc | |
+ migemo-coding-system | |
+ migemo-coding-system) | |
+ (set-process-input-coding-system proc migemo-coding-system) | |
+ (set-process-output-coding-system proc migemo-coding-system)) | |
+ proc)) | |
+ | |
+(defun migemo-init () | |
+ (when (and migemo-use-frequent-pattern-alist | |
+ migemo-frequent-pattern-alist-file | |
+ (null migemo-frequent-pattern-alist)) | |
+ (setq migemo-frequent-pattern-alist | |
+ (migemo-pattern-alist-load migemo-frequent-pattern-alist-file))) | |
+ (when (and migemo-use-pattern-alist | |
+ migemo-pattern-alist-file | |
+ (null migemo-pattern-alist)) | |
+ (setq migemo-pattern-alist | |
+ (migemo-pattern-alist-load migemo-pattern-alist-file))) | |
+ ;; C/Migemo begin | |
+ (if (fboundp 'cmigemo-open) | |
+ (when (not cmigemo-initialized) | |
+ (setq cmigemo-initialized | |
+ (cmigemo-open migemo-dictionary)) | |
+ (if (consp migemo-user-dictionary) | |
+ (dolist (d migemo-user-dictionary) | |
+ (cmigemo-load d)) | |
+ (cmigemo-load migemo-user-dictionary))) | |
+ ;; !!!WARNING!!! the following block has original indent | |
+ (or (and migemo-process | |
+ (eq (process-status migemo-process) 'run)) | |
+ (let ((options | |
+ (delq nil | |
+ (append migemo-options | |
+ (when (and migemo-user-dictionary | |
+ (file-exists-p migemo-user-dictionary)) | |
+ (list "-u" migemo-user-dictionary)) | |
+ (when (and migemo-regex-dictionary | |
+ (file-exists-p migemo-regex-dictionary)) | |
+ (list "-r" migemo-regex-dictionary)) | |
+ (list "-d" migemo-dictionary))))) | |
+ (setq migemo-buffer (get-buffer-create " *migemo*")) | |
+ (setq migemo-process (migemo-start-process | |
+ "migemo" migemo-buffer migemo-command options)) | |
+ (set-process-query-on-exit-flag migemo-process nil) | |
+ t)))) | |
+ ;; C/Migemo end | |
+ | |
+(defun migemo-replace-in-string (string from to) | |
+ (with-temp-buffer | |
+ (insert string) | |
+ (goto-char (point-min)) | |
+ (let ((migemo-do-isearch nil)) | |
+ (while (search-forward from nil t) | |
+ (replace-match to nil t))) | |
+ (buffer-substring (point-min) (point-max)))) | |
+ | |
+(defun migemo-get-pattern (word) | |
+ (cond | |
+ ((< (length word) migemo-isearch-min-length) | |
+ "") | |
+ (t | |
+ (let (deactivate-mark pattern freq alst) | |
+ (set-text-properties 0 (length word) nil word) | |
+ (migemo-init) | |
+ (when (and migemo-pre-conv-function | |
+ (functionp migemo-pre-conv-function)) | |
+ (setq word (funcall migemo-pre-conv-function word))) | |
+ (setq pattern | |
+ (cond | |
+ ((setq freq (and migemo-use-frequent-pattern-alist | |
+ (assoc word migemo-frequent-pattern-alist))) | |
+ (cdr freq)) | |
+ ((setq alst (and migemo-use-pattern-alist | |
+ (assoc word migemo-pattern-alist))) | |
+ (setq migemo-pattern-alist (cons alst (delq alst migemo-pattern-alist))) | |
+ (cdr alst)) | |
+ (t | |
+ ;; C/Migemo begin | |
+ (if (fboundp 'cmigemo-open) | |
+ (setq pattern (cmigemo-query word)) | |
+ ;; !!!WARNING!!! the following block has original indent | |
+ (with-current-buffer (process-buffer migemo-process) | |
+ (delete-region (point-min) (point-max)) | |
+ (process-send-string migemo-process (concat word "\n")) | |
+ (while (not (and (> (point-max) 1) | |
+ (eq (char-after (1- (point-max))) ?\n))) | |
+ (accept-process-output migemo-process | |
+ 0 migemo-accept-process-output-timeout-msec)) | |
+ (setq pattern (buffer-substring (point-min) (1- (point-max)))))) | |
+ ;; C/Migemo end | |
+ (when (and (memq system-type '(windows-nt OS/2 emx)) | |
+ (> (length pattern) 1) | |
+ (eq ?\r (aref pattern (1- (length pattern))))) | |
+ (setq pattern (substring pattern 0 -1))) | |
+ (when migemo-use-pattern-alist | |
+ (setq migemo-pattern-alist | |
+ (cons (cons word pattern) migemo-pattern-alist)) | |
+ (when (and migemo-pattern-alist-length | |
+ (> (length migemo-pattern-alist) | |
+ (* migemo-pattern-alist-length 2))) | |
+ (setcdr (nthcdr (1- (* migemo-pattern-alist-length 2)) | |
+ migemo-pattern-alist) nil))) | |
+ pattern))) | |
+ (if (and migemo-after-conv-function | |
+ (functionp migemo-after-conv-function)) | |
+ (funcall migemo-after-conv-function word pattern) | |
+ (migemo-replace-in-string pattern "\a" migemo-white-space-regexp)))))) | |
+ | |
+(defun migemo-pattern-alist-load (file) | |
+ "Load migemo alist file." | |
+ (setq file (expand-file-name file)) | |
+ (when (file-readable-p file) | |
+ (with-temp-buffer | |
+ (let ((coding-system-for-read migemo-coding-system) | |
+ (buffer-file-coding-system migemo-coding-system))) | |
+ (insert-file-contents file) | |
+ (goto-char (point-min)) | |
+ (condition-case err | |
+ (read (current-buffer)) | |
+ (error | |
+ (message "Error while reading %s; %s" | |
+ (file-name-nondirectory file) | |
+ (error-message-string err)) | |
+ nil))))) | |
+ | |
+(defun migemo-pattern-alist-save (&optional clear) | |
+ "Save migemo alist file." | |
+ (interactive) | |
+ (when (and migemo-use-pattern-alist | |
+ migemo-pattern-alist-file | |
+ (or migemo-pattern-alist clear)) | |
+ (let ((file (expand-file-name migemo-pattern-alist-file))) | |
+ (when (file-writable-p file) | |
+ (when clear | |
+ (setq migemo-pattern-alist nil)) | |
+ (when (and migemo-pattern-alist-length | |
+ (> (length migemo-pattern-alist) migemo-pattern-alist-length)) | |
+ (setcdr (nthcdr (1- migemo-pattern-alist-length) | |
+ migemo-pattern-alist) nil)) | |
+ (with-temp-buffer | |
+ (let ((coding-system-for-write migemo-coding-system) | |
+ (buffer-file-coding-system migemo-coding-system)) | |
+ (if (fboundp 'pp) | |
+ (pp migemo-pattern-alist (current-buffer)) | |
+ (prin1 migemo-pattern-alist (current-buffer))) | |
+ (write-region (point-min) (point-max) file nil 'nomsg))) | |
+ (setq migemo-pattern-alist nil))))) | |
+ | |
+(defun migemo-kill () | |
+ "Kill migemo process" | |
+ (interactive) | |
+ ;; C/Migemo begin | |
+ (if (fboundp 'cmigemo-open) | |
+ (when cmigemo-initialized | |
+ (cmigemo-close)) | |
+ ;; !!!WARNING!!! the following block has original indent | |
+ (when (and migemo-process (eq (process-status migemo-process) 'run)) | |
+ (kill-process migemo-process) | |
+ (setq migemo-process nil) | |
+ (when (get-buffer migemo-buffer) | |
+ (kill-buffer migemo-buffer))))) | |
+ ;; C/Migemo end | |
+ | |
+(defun migemo-pattern-alist-clear () | |
+ "Clear migemo alist data & file." | |
+ (interactive) | |
+ (migemo-kill) | |
+ (migemo-pattern-alist-save 'clear) | |
+ (migemo-init)) | |
+ | |
+(defun migemo-frequent-pattern-make (fcfile) | |
+ "Create frequent pattern from `frequent-chars'." | |
+ (interactive "ffrequent-chars: ") | |
+ (migemo-pattern-alist-save 'clear) | |
+ (when migemo-frequent-pattern-alist-file | |
+ (migemo-kill) | |
+ (migemo-init) | |
+ (let ((file (expand-file-name migemo-frequent-pattern-alist-file)) | |
+ (migemo-use-pattern-alist nil) | |
+ (migemo-use-frequent-pattern-alist nil) | |
+ (migemo-after-conv-function (lambda (_x y) y)) | |
+ word) | |
+ (setq migemo-frequent-pattern-alist nil) | |
+ (with-temp-buffer | |
+ (let ((coding-system-for-write migemo-coding-system) | |
+ (buffer-file-coding-system migemo-coding-system))) | |
+ (insert-file-contents fcfile) | |
+ (goto-char (point-min)) | |
+ (message "Make frequently pattern...") | |
+ (while (not (eobp)) | |
+ (when (looking-at "^[a-z]+$") | |
+ (setq word (match-string 0)) | |
+ (message "Make frequently pattern...%s" word) | |
+ (setq migemo-frequent-pattern-alist | |
+ (cons (cons word (migemo-get-pattern word)) | |
+ migemo-frequent-pattern-alist))) | |
+ (forward-line 1)) | |
+ (when (file-writable-p file) | |
+ (setq migemo-frequent-pattern-alist | |
+ (nreverse migemo-frequent-pattern-alist)) | |
+ (erase-buffer) | |
+ (if (fboundp 'pp) | |
+ (pp migemo-frequent-pattern-alist (current-buffer)) | |
+ (prin1 migemo-frequent-pattern-alist (current-buffer))) | |
+ (write-region (point-min) (point-max) file nil 'nomsg))) | |
+ (migemo-kill) | |
+ (migemo-init) | |
+ (message "Make frequently pattern...done")))) | |
+ | |
+(defun migemo-expand-pattern () "\ | |
+Expand the Romaji sequences on the left side of the cursor | |
+into the migemo's regexp pattern." | |
+ (interactive) | |
+ (let ((pos (point))) | |
+ (goto-char (- pos 1)) | |
+ (if (re-search-backward "[^-a-zA-Z]" (line-beginning-position) t) | |
+ (forward-char 1) | |
+ (beginning-of-line)) | |
+ (let* ((str (buffer-substring-no-properties (point) pos)) | |
+ (jrpat (migemo-get-pattern str))) | |
+ (delete-region (point) pos) | |
+ (insert jrpat)))) | |
+ | |
+(defun migemo-forward (word &optional bound noerror count) | |
+ (interactive "sSearch: \nP\nP") | |
+ (if (delq 'ascii (find-charset-string word)) | |
+ (setq migemo-search-pattern word) | |
+ (setq migemo-search-pattern (migemo-search-pattern-get word))) | |
+ (search-forward-regexp migemo-search-pattern bound noerror count)) | |
+ | |
+(defun migemo-backward (word &optional bound noerror count) | |
+ (interactive "sSearch backward: \nP\nP") | |
+ (if (delq 'ascii (find-charset-string word)) | |
+ (setq migemo-search-pattern word) | |
+ (setq migemo-search-pattern (migemo-search-pattern-get word))) | |
+ (if (null migemo-do-isearch) | |
+ (search-backward-regexp migemo-search-pattern bound noerror count) | |
+ (or (and (not (eq this-command 'isearch-repeat-backward)) | |
+ (not (get-char-property (point) 'invisible (current-buffer))) | |
+ (or (and (looking-at migemo-search-pattern) | |
+ (match-beginning 0)) | |
+ (and (not (eq (point) (point-min))) | |
+ (progn (forward-char -1) | |
+ (and (looking-at migemo-search-pattern) | |
+ (match-beginning 0)))))) | |
+ (search-backward-regexp migemo-search-pattern bound noerror count)))) | |
+ | |
+;; experimental | |
+;; (define-key global-map "\M-;" 'migemo-dabbrev-expand) | |
+(defcustom migemo-dabbrev-display-message nil | |
+ "*Display dabbrev message to minibuffer." | |
+ :group 'migemo | |
+ :type 'boolean) | |
+ | |
+(defcustom migemo-dabbrev-ol-face 'highlight | |
+ "*Face of migemo-dabbrev overlay." | |
+ :group 'migemo | |
+ :type 'face) | |
+ | |
+(defvar migemo-dabbrev-pattern nil) | |
+(defvar migemo-dabbrev-start-point nil) | |
+(defvar migemo-dabbrev-search-point nil) | |
+(defvar migemo-dabbrev-pre-patterns nil) | |
+(defvar migemo-dabbrev-ol nil) | |
+(defun migemo-dabbrev-expand-done () | |
+ (remove-hook 'pre-command-hook 'migemo-dabbrev-expand-done) | |
+ (unless (eq last-command this-command) | |
+ (setq migemo-search-pattern-alist nil) | |
+ (setq migemo-dabbrev-pre-patterns nil)) | |
+ (when migemo-dabbrev-ol | |
+ (delete-overlay migemo-dabbrev-ol))) | |
+ | |
+(defun migemo-dabbrev-expand () | |
+ (interactive) | |
+ (let ((end-pos (point)) | |
+ matched-start matched-string) | |
+ (if (eq last-command this-command) | |
+ (goto-char migemo-dabbrev-search-point) | |
+ (goto-char (- end-pos 1)) | |
+ (if (re-search-backward "[^a-z-]" (line-beginning-position) t) | |
+ (forward-char 1) | |
+ (beginning-of-line)) | |
+ (setq migemo-search-pattern-alist nil) | |
+ (setq migemo-dabbrev-start-point (point)) | |
+ (setq migemo-dabbrev-search-point (point)) | |
+ (setq migemo-dabbrev-pattern | |
+ (buffer-substring-no-properties (point) end-pos)) | |
+ (setq migemo-dabbrev-pre-patterns nil)) | |
+ (if (catch 'found | |
+ (while (if (> migemo-dabbrev-search-point migemo-dabbrev-start-point) | |
+ (and (migemo-forward migemo-dabbrev-pattern (point-max) t) | |
+ (setq migemo-dabbrev-search-point (match-end 0))) | |
+ (if (migemo-backward migemo-dabbrev-pattern (point-min) t) | |
+ (setq migemo-dabbrev-search-point (match-beginning 0)) | |
+ (goto-char migemo-dabbrev-start-point) | |
+ (forward-word 1) | |
+ (message (format "Trun back for `%s'" migemo-dabbrev-pattern)) | |
+ (and (migemo-forward migemo-dabbrev-pattern (point-max) t) | |
+ (setq migemo-dabbrev-search-point (match-end 0))))) | |
+ (setq matched-start (match-beginning 0)) | |
+ (unless (re-search-forward ".\\>" (line-end-position) t) | |
+ (end-of-line)) | |
+ (setq matched-string (buffer-substring-no-properties matched-start (point))) | |
+ (unless (member matched-string migemo-dabbrev-pre-patterns) | |
+ (let ((matched-end (point)) | |
+ (str (copy-sequence matched-string)) | |
+ lstart lend) | |
+ (if (and (pos-visible-in-window-p matched-start) | |
+ (pos-visible-in-window-p matched-end)) | |
+ (progn | |
+ (if migemo-dabbrev-ol | |
+ (move-overlay migemo-dabbrev-ol matched-start (point)) | |
+ (setq migemo-dabbrev-ol (make-overlay matched-start (point)))) | |
+ (overlay-put migemo-dabbrev-ol 'evaporate t) | |
+ (overlay-put migemo-dabbrev-ol 'face migemo-dabbrev-ol-face)) | |
+ (when migemo-dabbrev-ol | |
+ (delete-overlay migemo-dabbrev-ol)) | |
+ (when migemo-dabbrev-display-message | |
+ (save-excursion | |
+ (save-restriction | |
+ (goto-char matched-start) | |
+ (setq lstart (progn (beginning-of-line) (point))) | |
+ (setq lend (progn (end-of-line) (point))) | |
+ (if migemo-emacs21p | |
+ (put-text-property 0 (length str) | |
+ 'face migemo-dabbrev-ol-face str) | |
+ (setq str (concat "¡Ú" str "¡Û"))) | |
+ (message "(%d): %s%s%s" | |
+ (count-lines (point-min) matched-start) | |
+ (buffer-substring-no-properties lstart matched-start) | |
+ str | |
+ (buffer-substring-no-properties matched-end lend))))))) | |
+ (throw 'found t)) | |
+ (goto-char migemo-dabbrev-search-point))) | |
+ (progn | |
+ (setq migemo-dabbrev-pre-patterns | |
+ (cons matched-string migemo-dabbrev-pre-patterns)) | |
+ (delete-region migemo-dabbrev-start-point end-pos) | |
+ (forward-char 1) | |
+ (goto-char migemo-dabbrev-start-point) | |
+ (insert matched-string)) | |
+ (goto-char end-pos) | |
+ (message (format "No dynamic expansion for `%s' found" | |
+ migemo-dabbrev-pattern))) | |
+ (add-hook 'pre-command-hook 'migemo-dabbrev-expand-done))) | |
+ | |
+;; Use migemo-{forward,backward} instead of search-{forward,backward}. | |
+(defadvice isearch-search (around migemo-search-ad activate) | |
+ "adviced by migemo." | |
+ (when migemo-isearch-enable-p | |
+ (setq migemo-do-isearch t)) | |
+ (unwind-protect | |
+ ad-do-it | |
+ (setq migemo-do-isearch nil))) | |
+ | |
+(defadvice isearch-search-and-update (around migemo-search-ad activate) | |
+ "adviced by migemo." | |
+ (let ((isearch-adjusted isearch-adjusted)) | |
+ (when (and migemo-isearch-enable-p | |
+ (not isearch-forward) (not isearch-regexp) (not isearch-word)) | |
+ ;; don't use 'looking-at' | |
+ (setq isearch-adjusted t)) | |
+ ad-do-it)) | |
+ | |
+(defadvice search-forward (around migemo-search-ad activate) | |
+ "adviced by migemo." | |
+ (if migemo-do-isearch | |
+ (setq ad-return-value | |
+ (migemo-forward (ad-get-arg 0) (ad-get-arg 1) (ad-get-arg 2) (ad-get-arg 3))) | |
+ ad-do-it)) | |
+ | |
+(defadvice search-backward (around migemo-search-ad activate) | |
+ "adviced by migemo." | |
+ (if migemo-do-isearch | |
+ (setq ad-return-value | |
+ (migemo-backward (ad-get-arg 0) (ad-get-arg 1) (ad-get-arg 2) (ad-get-arg 3))) | |
+ ad-do-it)) | |
+ | |
+(when (and (boundp 'isearch-regexp-lax-whitespace) | |
+ (fboundp 're-search-forward-lax-whitespace) | |
+ (fboundp 'search-forward-lax-whitespace)) | |
+ (setq isearch-search-fun-function 'isearch-search-fun-migemo) | |
+ | |
+ (defun isearch-search-fun-migemo () | |
+ "Return default functions to use for the search with migemo." | |
+ (cond | |
+ (isearch-word | |
+ (lambda (string &optional bound noerror count) | |
+ ;; Use lax versions to not fail at the end of the word while | |
+ ;; the user adds and removes characters in the search string | |
+ ;; (or when using nonincremental word isearch) | |
+ (let* ((state-string-func (if (fboundp 'isearch--state-string) | |
+ 'isearch--state-string | |
+ 'isearch-string-state)) | |
+ (lax (not (or isearch-nonincremental | |
+ (eq (length isearch-string) | |
+ (length (funcall state-string-func (car isearch-cmds)))))))) | |
+ (funcall | |
+ (if isearch-forward #'re-search-forward #'re-search-backward) | |
+ (if (functionp isearch-word) | |
+ (funcall isearch-word string lax) | |
+ (word-search-regexp string lax)) | |
+ bound noerror count)))) | |
+ ((and isearch-regexp isearch-regexp-lax-whitespace | |
+ search-whitespace-regexp) | |
+ (if isearch-forward | |
+ 're-search-forward-lax-whitespace | |
+ 're-search-backward-lax-whitespace)) | |
+ (isearch-regexp | |
+ (if isearch-forward 're-search-forward 're-search-backward)) | |
+ ((and (if (boundp 'isearch-lax-whitespace) isearch-lax-whitespace t) | |
+ search-whitespace-regexp migemo-do-isearch) | |
+ (if isearch-forward 'migemo-forward 'migemo-backward)) | |
+ ((and (if (boundp 'isearch-lax-whitespace) isearch-lax-whitespace t) | |
+ search-whitespace-regexp) | |
+ (if isearch-forward 'search-forward-lax-whitespace | |
+ 'search-backward-lax-whitespace)) | |
+ (migemo-do-isearch | |
+ (if isearch-forward 'migemo-forward 'migemo-backward)) | |
+ (t | |
+ (if isearch-forward 'search-forward 'search-backward)))) | |
+ ) | |
+ | |
+(defun japanese-p (coding-system-list) | |
+ (cond ((atom coding-system-list) nil) | |
+ ((member (car coding-system-list) | |
+ coding-system-for-japanese) | |
+ t) | |
+ (t (japanese-p (cdr coding-system-list))))) | |
+ | |
+;; Turn off input-method automatically when C-s or C-r are typed. | |
+(defadvice isearch-mode (before migemo-search-ad activate) | |
+ "adviced by migemo." | |
+ (unless (local-variable-p 'migemo-isearch-enable-p) | |
+ (set (make-local-variable 'migemo-isearch-enable-p) | |
+ (japanese-p (detect-coding-with-language-environment | |
+ (point-min) (point-max) "japanese")))) | |
+ (setq migemo-search-pattern nil) | |
+ (setq migemo-search-pattern-alist nil)) | |
+ | |
+(defadvice isearch-done (after migemo-search-ad activate) | |
+ "adviced by migemo." | |
+ (setq migemo-search-pattern nil) | |
+ (setq migemo-search-pattern-alist nil)) | |
+ | |
+(defcustom migemo-message-prefix-face 'highlight | |
+ "*Face of minibuffer prefix" | |
+ :group 'migemo | |
+ :type 'face) | |
+ | |
+(defadvice isearch-message-prefix (after migemo-status activate) | |
+ "adviced by migemo." | |
+ (let ((ret ad-return-value) | |
+ (str "[MIGEMO]")) | |
+ (when migemo-emacs21p | |
+ (put-text-property 0 (length str) 'face migemo-message-prefix-face str)) | |
+ (when (and migemo-isearch-enable-p | |
+ (not (or isearch-regexp isearch-word))) | |
+ (setq ad-return-value (concat str " " ret))))) | |
+ | |
+;;;; for isearch-lazy-highlight (Emacs 21) | |
+;; Avoid byte compile warningsfor other emacsen | |
+(defvar isearch-lazy-highlight-wrapped) | |
+(defvar isearch-lazy-highlight-start) | |
+(defvar isearch-lazy-highlight-end) | |
+ | |
+(defun migemo-isearch-lazy-highlight-search () | |
+ "Search ahead for the next or previous match, for lazy highlighting. | |
+Attempt to do the search exactly the way the pending isearch would. | |
+This function used with Megemo feature." | |
+ (let ((case-fold-search isearch-case-fold-search) | |
+ (choices (cond (isearch-word | |
+ '(word-search-forward word-search-backward)) | |
+ (isearch-regexp | |
+ '(re-search-forward re-search-backward)) | |
+ (migemo-isearch-enable-p | |
+ '(re-search-forward re-search-backward t)) | |
+ (t | |
+ '(search-forward search-backward)))) | |
+ (pattern isearch-string)) | |
+ (when (nth 2 choices) | |
+ (setq pattern (migemo-search-pattern-get isearch-string))) | |
+ (funcall (if isearch-forward | |
+ (nth 0 choices) (nth 1 choices)) | |
+ pattern | |
+ (if isearch-forward | |
+ (if isearch-lazy-highlight-wrapped | |
+ isearch-lazy-highlight-start | |
+ (window-end)) | |
+ (if isearch-lazy-highlight-wrapped | |
+ isearch-lazy-highlight-end | |
+ (window-start))) | |
+ t))) | |
+ | |
+(when (fboundp 'isearch-lazy-highlight-search) | |
+ (defalias 'isearch-lazy-highlight-search 'migemo-isearch-lazy-highlight-search)) | |
+ | |
+;;;; for isearch-highlightify-region (XEmacs 21) | |
+(when (fboundp 'isearch-highlightify-region) | |
+ (defadvice isearch-highlightify-region (around migemo-highlightify-region | |
+ activate) | |
+ "adviced by migemo." | |
+ (if migemo-isearch-enable-p | |
+ (let ((isearch-string (migemo-search-pattern-get isearch-string)) | |
+ (isearch-regexp t)) | |
+ ad-do-it) | |
+ ad-do-it))) | |
+ | |
+;; supports C-w C-d for GNU emacs only [migemo:00171] | |
+(when (and (not (featurep 'xemacs)) | |
+ (fboundp 'isearch-yank-line)) | |
+ (add-hook 'isearch-mode-hook | |
+ (lambda () | |
+ (define-key isearch-mode-map "\C-d" 'migemo-isearch-yank-char) | |
+ (define-key isearch-mode-map "\C-w" 'migemo-isearch-yank-word) | |
+ (define-key isearch-mode-map "\C-y" 'migemo-isearch-yank-line) | |
+ (define-key isearch-mode-map "\M-m" 'migemo-isearch-toggle-migemo))) | |
+ | |
+ (defun migemo-isearch-toggle-migemo () | |
+ "Toggle migemo mode in isearch." | |
+ (interactive) | |
+ (unless (or isearch-regexp isearch-word) | |
+ (discard-input) | |
+ (setq migemo-isearch-enable-p (not migemo-isearch-enable-p))) | |
+ (when (fboundp 'isearch-lazy-highlight-new-loop) | |
+ (let ((isearch-lazy-highlight-last-string nil)) | |
+ (condition-case nil | |
+ (isearch-lazy-highlight-new-loop) | |
+ (error | |
+ (isearch-lazy-highlight-new-loop nil nil))))) | |
+ (isearch-message)) | |
+ | |
+ (defun migemo-isearch-yank-char () | |
+ "Pull next character from buffer into search string with migemo." | |
+ (interactive) | |
+ (when (and migemo-isearch-enable-p | |
+ (not isearch-regexp) isearch-other-end) | |
+ (setq isearch-string (buffer-substring-no-properties | |
+ isearch-other-end (point))) | |
+ (setq isearch-message isearch-string)) | |
+ (let ((search-upper-case (unless migemo-isearch-enable-p | |
+ search-upper-case))) | |
+ (isearch-yank-string | |
+ (save-excursion | |
+ (and (not isearch-forward) isearch-other-end | |
+ (goto-char isearch-other-end)) | |
+ (buffer-substring-no-properties (point) | |
+ (progn (forward-char 1) (point))))))) | |
+ | |
+ (defun migemo-isearch-yank-word () | |
+ "Pull next character from buffer into search string with migemo." | |
+ (interactive) | |
+ (when (and migemo-isearch-enable-p | |
+ (not isearch-regexp) isearch-other-end) | |
+ (setq isearch-string (buffer-substring-no-properties | |
+ isearch-other-end (point))) | |
+ (setq isearch-message isearch-string)) | |
+ (let ((search-upper-case (unless migemo-isearch-enable-p | |
+ search-upper-case))) | |
+ (isearch-yank-string | |
+ (save-excursion | |
+ (and (not isearch-forward) isearch-other-end | |
+ (goto-char isearch-other-end)) | |
+ (buffer-substring-no-properties (point) | |
+ (progn (forward-word 1) (point))))))) | |
+ | |
+ (defun migemo-isearch-yank-line () | |
+ "Pull next character from buffer into search string with migemo." | |
+ (interactive) | |
+ (when (and migemo-isearch-enable-p | |
+ (not isearch-regexp) isearch-other-end) | |
+ (setq isearch-string (buffer-substring-no-properties | |
+ isearch-other-end (point))) | |
+ (setq isearch-message isearch-string)) | |
+ (let ((search-upper-case (unless migemo-isearch-enable-p | |
+ search-upper-case))) | |
+ (isearch-yank-string | |
+ (save-excursion | |
+ (and (not isearch-forward) isearch-other-end | |
+ (goto-char isearch-other-end)) | |
+ (buffer-substring-no-properties (point) | |
+ (line-end-position)))))) | |
+) | |
+ | |
+(if (and (not (fboundp 'cmigemo-open)) | |
+ (fboundp 'load-dynamic-library)) | |
+ (load-dynamic-library migemo-cmigemo-library)) | |
+ | |
+(add-hook 'kill-emacs-hook 'migemo-pattern-alist-save) | |
+ | |
+(provide 'cmigemo) | |
+ | |
+;; sample | |
+;; 0123 abcd ABCD ¤Ò¤é¤¬¤Ê ¥«¥¿¥«¥Ê ´Á»ú !"[#\$]%^&_':`(;)<*=+>,?-@./{|}~ | |
+ | |
+;; Local Variables: | |
+;; coding: euc-japan-unix | |
+;; lexical-binding: t | |
+;; indent-tabs-mode: nil | |
+;; End: | |
+ | |
+;;; migemo.el ends here | |
--- /dev/null 2015-04-11 07:27:57.000000000 +0900 | |
+++ ./site-lisp/cp5022x.el 2015-04-11 07:27:30.531116300 +0900 | |
@@ -0,0 +1,156 @@ | |
+;;; cp5022x.el --- cp50220, cp50221, cp50222 coding system | |
+ | |
+;; Copyright (C) 2008 ARISAWA Akihiro | |
+ | |
+;; Author: ARISAWA Akihiro <ari@mbf.ocn.ne.jp> | |
+;; Keywords: languages, cp50220, cp50221, cp50222, cp51932, cp932 | |
+ | |
+;; This file is free software; you can redistribute it and/or modify | |
+;; it under the terms of the GNU General Public License as published by | |
+;; the Free Software Foundation; either version 3, or (at your option) | |
+;; any later version. | |
+ | |
+;; This file is distributed in the hope that it will be useful, | |
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
+;; GNU General Public License for more details. | |
+ | |
+;; You should have received a copy of the GNU General Public License | |
+;; along with GNU Emacs; see the file COPYING. If not, write to | |
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
+;; Boston, MA 02110-1301, USA. | |
+ | |
+;;; Commentary: | |
+ | |
+;; This program requires Mule-6.0 or later. | |
+ | |
+;;; Code: | |
+ | |
+;; http://unicode.org/reports/tr30/datafiles/WidthFolding.txt | |
+(define-translation-table | |
+ 'cp50220-jisx0201-katakana-to-zenkaku | |
+ '(;; Half-width to generic width (singletons) | |
+ (#xFF61 . #x3002) ;; 。 â ã HALFWIDTH IDEOGRAPHIC FULL STOP â IDEOGRAPHIC FULL STOP | |
+ (#xFF62 . #x300C) ;; ï½¢ â ã HALFWIDTH LEFT CORNER BRACKET â LEFT CORNER BRACKET | |
+ (#xFF63 . #x300D) ;; ï½£ â ã HALFWIDTH RIGHT CORNER BRACKET â RIGHT CORNER BRACKET | |
+ (#xFF64 . #x3001) ;; 、 â ã HALFWIDTH IDEOGRAPHIC COMMA â IDEOGRAPHIC COMMA | |
+ ;; Half-witdh to generic Katakana (singletons) | |
+ (#xFF65 . #x30FB) ;; ï½¥ â ã» HALFWIDTH KATAKANA MIDDLE DOT â KATAKANA MIDDLE DOT | |
+ (#xFF66 . #x30F2) ;; ヲ â ã² HALFWIDTH KATAKANA LETTER WO â KATAKANA LETTER WO | |
+ (#xFF67 . #x30A1) ;; ï½§ â ã¡ HALFWIDTH KATAKANA LETTER SMALL A â KATAKANA LETTER SMALL A | |
+ (#xFF68 . #x30A3) ;; ィ â 㣠HALFWIDTH KATAKANA LETTER SMALL I â KATAKANA LETTER SMALL I | |
+ (#xFF69 . #x30A5) ;; ゥ â 㥠HALFWIDTH KATAKANA LETTER SMALL U â KATAKANA LETTER SMALL U | |
+ (#xFF6A . #x30A7) ;; ェ â ã§ HALFWIDTH KATAKANA LETTER SMALL E â KATAKANA LETTER SMALL E | |
+ (#xFF6B . #x30A9) ;; ォ â ã© HALFWIDTH KATAKANA LETTER SMALL O â KATAKANA LETTER SMALL O | |
+ (#xFF6C . #x30E3) ;; ャ â 㣠HALFWIDTH KATAKANA LETTER SMALL YA â KATAKANA LETTER SMALL YA | |
+ (#xFF6D . #x30E5) ;; ï½ â 㥠HALFWIDTH KATAKANA LETTER SMALL YU â KATAKANA LETTER SMALL YU | |
+ (#xFF6E . #x30E7) ;; ï½® â ã§ HALFWIDTH KATAKANA LETTER SMALL YO â KATAKANA LETTER SMALL YO | |
+ (#xFF6F . #x30C3) ;; ッ â ã HALFWIDTH KATAKANA LETTER SMALL TU â KATAKANA LETTER SMALL TU | |
+ (#xFF70 . #x30FC) ;; ï½° â ã¼ HALFWIDTH KATAKANA-HIRAGANA PROLONGED SOUND MARK â KATAKANA-HIRAGANA PROLONGED SOUND MARK | |
+ (#xFF71 . #x30A2) ;; ï½± â 㢠HALFWIDTH KATAKANA LETTER A â KATAKANA LETTER A | |
+ (#xFF72 . #x30A4) ;; ï½² â 㤠HALFWIDTH KATAKANA LETTER I â KATAKANA LETTER I | |
+ (#xFF73 . #x30A6) ;; ï½³ â 㦠HALFWIDTH KATAKANA LETTER U â KATAKANA LETTER U | |
+ (#xFF74 . #x30A8) ;; ï½´ â 㨠HALFWIDTH KATAKANA LETTER E â KATAKANA LETTER E | |
+ (#xFF75 . #x30AA) ;; ï½µ â 㪠HALFWIDTH KATAKANA LETTER O â KATAKANA LETTER O | |
+ (#xFF76 . #x30AB) ;; ï½¶ â ã« HALFWIDTH KATAKANA LETTER KA â KATAKANA LETTER KA | |
+ (#xFF77 . #x30AD) ;; ï½· â ã HALFWIDTH KATAKANA LETTER KI â KATAKANA LETTER KI | |
+ (#xFF78 . #x30AF) ;; ク â 㯠HALFWIDTH KATAKANA LETTER KU â KATAKANA LETTER KU | |
+ (#xFF79 . #x30B1) ;; ï½¹ â ã± HALFWIDTH KATAKANA LETTER KE â KATAKANA LETTER KE | |
+ (#xFF7A . #x30B3) ;; コ â ã³ HALFWIDTH KATAKANA LETTER KO â KATAKANA LETTER KO | |
+ (#xFF7B . #x30B5) ;; ï½» â ãµ HALFWIDTH KATAKANA LETTER SA â KATAKANA LETTER SA | |
+ (#xFF7C . #x30B7) ;; ï½¼ â ã· HALFWIDTH KATAKANA LETTER SI â KATAKANA LETTER SI | |
+ (#xFF7D . #x30B9) ;; ï½½ â ã¹ HALFWIDTH KATAKANA LETTER SU â KATAKANA LETTER SU | |
+ (#xFF7E . #x30BB) ;; ï½¾ â ã» HALFWIDTH KATAKANA LETTER SE â KATAKANA LETTER SE | |
+ (#xFF7F . #x30BD) ;; ソ â ã½ HALFWIDTH KATAKANA LETTER SO â KATAKANA LETTER SO | |
+ (#xFF80 . #x30BF) ;; ï¾ â ã¿ HALFWIDTH KATAKANA LETTER TA â KATAKANA LETTER TA | |
+ (#xFF81 . #x30C1) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER TI â KATAKANA LETTER TI | |
+ (#xFF82 . #x30C4) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER TU â KATAKANA LETTER TU | |
+ (#xFF83 . #x30C6) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER TE â KATAKANA LETTER TE | |
+ (#xFF84 . #x30C8) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER TO â KATAKANA LETTER TO | |
+ (#xFF85 . #x30CA) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER NA â KATAKANA LETTER NA | |
+ (#xFF86 . #x30CB) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER NI â KATAKANA LETTER NI | |
+ (#xFF87 . #x30CC) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER NU â KATAKANA LETTER NU | |
+ (#xFF88 . #x30CD) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER NE â KATAKANA LETTER NE | |
+ (#xFF89 . #x30CE) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER NO â KATAKANA LETTER NO | |
+ (#xFF8A . #x30CF) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER HA â KATAKANA LETTER HA | |
+ (#xFF8B . #x30D2) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER HI â KATAKANA LETTER HI | |
+ (#xFF8C . #x30D5) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER HU â KATAKANA LETTER HU | |
+ (#xFF8D . #x30D8) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER HE â KATAKANA LETTER HE | |
+ (#xFF8E . #x30DB) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER HO â KATAKANA LETTER HO | |
+ (#xFF8F . #x30DE) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER MA â KATAKANA LETTER MA | |
+ (#xFF90 . #x30DF) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER MI â KATAKANA LETTER MI | |
+ (#xFF91 . #x30E0) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER MU â KATAKANA LETTER MU | |
+ (#xFF92 . #x30E1) ;; ï¾ â ã¡ HALFWIDTH KATAKANA LETTER ME â KATAKANA LETTER ME | |
+ (#xFF93 . #x30E2) ;; ï¾ â 㢠HALFWIDTH KATAKANA LETTER MO â KATAKANA LETTER MO | |
+ (#xFF94 . #x30E4) ;; ï¾ â 㤠HALFWIDTH KATAKANA LETTER YA â KATAKANA LETTER YA | |
+ (#xFF95 . #x30E6) ;; ï¾ â 㦠HALFWIDTH KATAKANA LETTER YU â KATAKANA LETTER YU | |
+ (#xFF96 . #x30E8) ;; ï¾ â 㨠HALFWIDTH KATAKANA LETTER YO â KATAKANA LETTER YO | |
+ (#xFF97 . #x30E9) ;; ï¾ â ã© HALFWIDTH KATAKANA LETTER RA â KATAKANA LETTER RA | |
+ (#xFF98 . #x30EA) ;; ï¾ â 㪠HALFWIDTH KATAKANA LETTER RI â KATAKANA LETTER RI | |
+ (#xFF99 . #x30EB) ;; ï¾ â ã« HALFWIDTH KATAKANA LETTER RU â KATAKANA LETTER RU | |
+ (#xFF9A . #x30EC) ;; ï¾ â 㬠HALFWIDTH KATAKANA LETTER RE â KATAKANA LETTER RE | |
+ (#xFF9B . #x30ED) ;; ï¾ â ã HALFWIDTH KATAKANA LETTER RO â KATAKANA LETTER RO | |
+ (#xFF9C . #x30EF) ;; ï¾ â 㯠HALFWIDTH KATAKANA LETTER WA â KATAKANA LETTER WA | |
+ (#xFF9D . #x30F3) ;; ï¾ â ã³ HALFWIDTH KATAKANA LETTER N â KATAKANA LETTER N | |
+; (#xFF9E . #x3099) ;; ï¾ â ã HALFWIDTH KATAKANA VOICED SOUND MARK â COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK | |
+; (#xFF9F . #x309A) ;; ï¾ â ã HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK â COMBINING KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK | |
+ (#xFF9E . #x309B) ;; ï¾ â ã HALFWIDTH KATAKANA VOICED SOUND MARK â KATAKANA-HIRAGANA VOICED SOUND MARK | |
+ (#xFF9F . #x309C) ;; ï¾ â ã HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK â KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK | |
+ )) | |
+ | |
+(define-coding-system 'cp50220 | |
+ "CP50220 (Microsoft iso-2022-jp for mail)" | |
+ :coding-type 'iso-2022 | |
+ :mnemonic ?J | |
+ :designation [(ascii japanese-jisx0208-1978 japanese-jisx0208 | |
+ latin-jisx0201 katakana-jisx0201) | |
+ nil nil nil] | |
+ :flags '(short ascii-at-eol ascii-at-cntl 7-bit designation) | |
+ :charset-list '(ascii japanese-jisx0208 | |
+ japanese-jisx0208-1978 latin-jisx0201 | |
+ katakana-jisx0201) | |
+ :decode-translation-table '(cp51932-decode japanese-ucs-jis-to-cp932-map) | |
+ :encode-translation-table '(cp50220-jisx0201-katakana-to-zenkaku | |
+ cp51932-encode japanese-ucs-cp932-to-jis-map)) | |
+ | |
+(define-coding-system 'cp50221 | |
+ "CP50221 (Microsoft iso-2022-jp)" | |
+ :coding-type 'iso-2022 | |
+ :mnemonic ?J | |
+ :designation [(ascii japanese-jisx0208-1978 japanese-jisx0208 | |
+ latin-jisx0201 katakana-jisx0201) | |
+ nil nil nil] | |
+ :flags '(short ascii-at-eol ascii-at-cntl 7-bit designation) | |
+ :charset-list '(ascii japanese-jisx0208 | |
+ japanese-jisx0208-1978 latin-jisx0201 | |
+ katakana-jisx0201) | |
+ :decode-translation-table '(cp51932-decode japanese-ucs-jis-to-cp932-map) | |
+ :encode-translation-table '(cp51932-encode japanese-ucs-cp932-to-jis-map)) | |
+ | |
+(define-coding-system 'cp50222 | |
+ "CP50222 (Microsoft iso-2022-jp)" | |
+ :coding-type 'iso-2022 | |
+ :mnemonic ?J | |
+ :designation [(ascii japanese-jisx0208-1978 japanese-jisx0208 | |
+ latin-jisx0201) | |
+ katakana-jisx0201 nil nil] | |
+ :flags '(short ascii-at-eol ascii-at-cntl 7-bit designation) | |
+ :charset-list '(ascii japanese-jisx0208 | |
+ japanese-jisx0208-1978 latin-jisx0201 | |
+ katakana-jisx0201) | |
+ :decode-translation-table '(cp51932-decode japanese-ucs-jis-to-cp932-map) | |
+ :encode-translation-table '(cp51932-encode japanese-ucs-cp932-to-jis-map)) | |
+ | |
+(define-coding-system 'cp51932 | |
+ "CP51932 (Microsoft euc-jp)" | |
+ :coding-type 'iso-2022 | |
+ :mnemonic ?E | |
+ :designation [ascii japanese-jisx0208 katakana-jisx0201 nil] | |
+ :flags '(short ascii-at-eol ascii-at-cntl single-shift) | |
+ :charset-list '(ascii latin-jisx0201 japanese-jisx0208 | |
+ katakana-jisx0201) | |
+ :decode-translation-table '(cp51932-decode japanese-ucs-jis-to-cp932-map) | |
+ :encode-translation-table '(cp51932-encode japanese-ucs-cp932-to-jis-map)) | |
+ | |
+(provide 'cp5022x) | |
+;;; cp5022x.el ends here | |
--- /dev/null 2015-04-11 07:27:58.000000000 +0900 | |
+++ ./site-lisp/ezsetup.el 2015-04-11 07:27:30.542118200 +0900 | |
@@ -0,0 +1,104 @@ | |
+;; | |
+;; | |
+;; | |
+(when (and (= (w32-get-default-locale-id) 1041) ; japanese? | |
+ (not (file-exists-p user-init-file))) | |
+ (require 'cus-edit) | |
+ (let ((user-init-file | |
+ (expand-file-name "init.el" user-emacs-directory)) | |
+ (cust-vars | |
+ `((default-frame-alist . | |
+ ,(cons | |
+ '(font . "fontset-std:std") | |
+ (cons '(ime-cursor-color . "SkyBlue") | |
+ default-frame-alist))) | |
+ (current-language-environment . "Japanese")))) | |
+ | |
+ (mapc #'(lambda (l) | |
+ (let ((symbol (car l)) | |
+ (value (cdr l))) | |
+ (put symbol 'saved-value | |
+ (list (custom-quote value))))) | |
+ cust-vars) | |
+ | |
+ (with-temp-buffer | |
+ (if (member "Migu 1M" (font-family-list)) | |
+ (insert ";; | |
+;; ãã©ã³ã | |
+;; | |
+(dolist (spec '((10 . \"small\") | |
+ (12 . \"std\") | |
+ (14 . \"large\"))) | |
+ | |
+ (let* ((ff \"Migu 1M\") | |
+ (sz (car spec)) | |
+ (fs (create-fontset-from-ascii-font | |
+ (format \"-*-%s-normal-*-*-*-%g-*\" ff sz) nil ff))) | |
+ | |
+ (dolist (sn '(katakana-jisx0201 | |
+ japanese-jisx0208 | |
+ japanese-jisx0212)) | |
+ (set-fontset-font fs sn (cons ff \"iso10646-1\")) | |
+ (add-to-list 'fontset-alias-alist | |
+ (cons fs (format \"fontset-std:%s\" (cdr spec)))))))")) | |
+ | |
+ (insert ";; | |
+;; æ¥æ¬èªã³ã¼ã | |
+;; | |
+(load-library \"ja-coding\") | |
+;; | |
+;; ã¢ã¼ãã©ã¤ã³ã«IMEã®ç¶æ ã表示 | |
+;; | |
+(setq-default w32-ime-mode-line-state-indicator \"[--]\") | |
+(setq w32-ime-mode-line-state-indicator-list '(\"[--]\" \"[ã]\" \"[--]\")) | |
+ | |
+;; | |
+;; imeãµãã¼ã ã»ããã¢ãã | |
+;; | |
+(w32-ime-initialize) | |
+(require 'smart-ime) | |
+ | |
+;; | |
+;; MIGEMO | |
+;; | |
+(unless (boundp 'isearch-mode-map) | |
+ (load-library \"isearch\")) | |
+ | |
+(dolist (key (where-is-internal | |
+ 'toggle-input-method global-map nil nil | |
+ (command-remapping 'toggle-input-method))) | |
+ (when (= (length key) 1) | |
+ (define-key isearch-mode-map | |
+ key 'migemo-isearch-toggle-migemo))) | |
+ | |
+(require 'cmigemo) | |
+ | |
+;; | |
+(custom-set-variables) | |
+ | |
+;; ã«ã¼ã½ã«è² | |
+;; custom-variableã®å¤ã使ãã®ã§ãã®ä½ç½®ã«è¨è¿°ãã | |
+(add-hook 'w32-ime-on-hook | |
+ `(lambda () (set-cursor-color ,(frame-parameter nil 'ime-cursor-color)))) | |
+(add-hook 'w32-ime-off-hook | |
+ `(lambda () (set-cursor-color ,(frame-parameter nil 'cursor-color))))") | |
+ (set-buffer-file-coding-system 'utf-8) | |
+ (custom-save-variables) | |
+ (write-file (expand-file-name "init.el" user-emacs-directory))) | |
+ (load-file user-init-file) | |
+ | |
+ (save-window-excursion | |
+ (with-temp-buffer | |
+ (pop-to-buffer (current-buffer)) | |
+ (insert "è¨å®ãã¡ã¤ã« ~/.emacs.d/init.elã使ãã¾ããã | |
+以ä¸ã®ã«ã¹ã¿ã 夿°ãè¨å®ãã¾ããããããã®å¤æ°ã¯ | |
+M-x customize-variable<ENTER> | |
+ã®å¾ã«å¤æ°åãå ¥åãã夿´ãããã¨ãã§ãã¾ãã\n") | |
+ (mapc #'(lambda (l) | |
+ (insert | |
+ (format "%s: %s\n" (car l) (symbol-value (car l))))) | |
+ cust-vars) | |
+ (insert "ä½ããã¼ãæ¼ãã¦ãã ããã") | |
+ (read-char "? "))))) | |
+ | |
+ | |
--- /dev/null 2015-04-11 07:27:58.000000000 +0900 | |
+++ ./site-lisp/ja-coding.el 2015-04-11 07:27:30.547117100 +0900 | |
@@ -0,0 +1,81 @@ | |
+;; http://nijino.homelinux.net/emacs/emacs23-ja.html | |
+(cond | |
+ ((not (string< mule-version "6.0")) | |
+ | |
+ (coding-system-put 'euc-jp :encode-translation-table | |
+ (get 'japanese-ucs-cp932-to-jis-map 'translation-table)) | |
+ (coding-system-put 'iso-2022-jp :encode-translation-table | |
+ (get 'japanese-ucs-cp932-to-jis-map 'translation-table)) | |
+ (coding-system-put 'cp932 :encode-translation-table | |
+ (get 'japanese-ucs-jis-to-cp932-map 'translation-table)) | |
+ ;; charset 㨠coding-system ã®åªå 度è¨å® | |
+ (set-charset-priority 'ascii 'japanese-jisx0208 'latin-jisx0201 | |
+ 'katakana-jisx0201 'iso-8859-1 'cp1252 'unicode) | |
+ (set-coding-system-priority 'utf-8 'cp932 'euc-jp 'iso-2022-jp) | |
+ | |
+ ;; East Asian Ambiguous | |
+ (let ((width 2)) | |
+ (while (char-table-parent char-width-table) | |
+ (setq char-width-table (char-table-parent char-width-table))) | |
+ (let ((table (make-char-table nil))) | |
+ (dolist (range | |
+ '(#x00A1 #x00A4 (#x00A7 . #x00A8) #x00AA (#x00AD . #x00AE) | |
+ (#x00B0 . #x00B4) (#x00B6 . #x00BA) (#x00BC . #x00BF) | |
+ #x00C6 #x00D0 (#x00D7 . #x00D8) (#x00DE . #x00E1) #x00E6 | |
+ (#x00E8 . #x00EA) (#x00EC . #x00ED) #x00F0 | |
+ (#x00F2 . #x00F3) (#x00F7 . #x00FA) #x00FC #x00FE | |
+ #x0101 #x0111 #x0113 #x011B (#x0126 . #x0127) #x012B | |
+ (#x0131 . #x0133) #x0138 (#x013F . #x0142) #x0144 | |
+ (#x0148 . #x014B) #x014D (#x0152 . #x0153) | |
+ (#x0166 . #x0167) #x016B #x01CE #x01D0 #x01D2 #x01D4 | |
+ #x01D6 #x01D8 #x01DA #x01DC #x0251 #x0261 #x02C4 #x02C7 | |
+ (#x02C9 . #x02CB) #x02CD #x02D0 (#x02D8 . #x02DB) #x02DD | |
+ #x02DF (#x0300 . #x036F) (#x0391 . #x03A9) | |
+ (#x03B1 . #x03C1) (#x03C3 . #x03C9) #x0401 | |
+ (#x0410 . #x044F) #x0451 #x2010 (#x2013 . #x2016) | |
+ (#x2018 . #x2019) (#x201C . #x201D) (#x2020 . #x2022) | |
+ (#x2024 . #x2027) #x2030 (#x2032 . #x2033) #x2035 #x203B | |
+ #x203E #x2074 #x207F (#x2081 . #x2084) #x20AC #x2103 | |
+ #x2105 #x2109 #x2113 #x2116 (#x2121 . #x2122) #x2126 | |
+ #x212B (#x2153 . #x2154) (#x215B . #x215E) | |
+ (#x2160 . #x216B) (#x2170 . #x2179) (#x2190 . #x2199) | |
+ (#x21B8 . #x21B9) #x21D2 #x21D4 #x21E7 #x2200 | |
+ (#x2202 . #x2203) (#x2207 . #x2208) #x220B #x220F #x2211 | |
+ #x2215 #x221A (#x221D . #x2220) #x2223 #x2225 | |
+ (#x2227 . #x222C) #x222E (#x2234 . #x2237) | |
+ (#x223C . #x223D) #x2248 #x224C #x2252 (#x2260 . #x2261) | |
+ (#x2264 . #x2267) (#x226A . #x226B) (#x226E . #x226F) | |
+ (#x2282 . #x2283) (#x2286 . #x2287) #x2295 #x2299 #x22A5 | |
+ #x22BF #x2312 (#x2460 . #x24E9) (#x24EB . #x254B) | |
+ (#x2550 . #x2573) (#x2580 . #x258F) (#x2592 . #x2595) | |
+ (#x25A0 . #x25A1) (#x25A3 . #x25A9) (#x25B2 . #x25B3) | |
+ (#x25B6 . #x25B7) (#x25BC . #x25BD) (#x25C0 . #x25C1) | |
+ (#x25C6 . #x25C8) #x25CB (#x25CE . #x25D1) | |
+ (#x25E2 . #x25E5) #x25EF (#x2605 . #x2606) #x2609 | |
+ (#x260E . #x260F) (#x2614 . #x2615) #x261C #x261E #x2640 | |
+ #x2642 (#x2660 . #x2661) (#x2663 . #x2665) | |
+ (#x2667 . #x266A) (#x266C . #x266D) #x266F #x273D | |
+ (#x2776 . #x277F) (#xE000 . #xF8FF) (#xFE00 . #xFE0F) | |
+ #xFFFD | |
+ )) | |
+ (set-char-table-range table range width)) | |
+ (optimize-char-table table) | |
+ (set-char-table-parent table char-width-table) | |
+ (setq char-width-table table))) | |
+ | |
+ ;; æ©ç¨®ä¾åæå | |
+ (require 'cp5022x))) | |
+ | |
+;; emacs-w3m | |
+(eval-after-load "w3m" | |
+ '(when (coding-system-p 'cp51932) | |
+ (add-to-list 'w3m-compatible-encoding-alist '(euc-jp . cp51932)))) | |
+;; Gnus | |
+(eval-after-load "mm-util" | |
+ '(when (coding-system-p 'cp50220) | |
+ (add-to-list 'mm-charset-override-alist '(iso-2022-jp . cp50220)))) | |
+;; SEMI (cf. http://d.hatena.ne.jp/kiwanami/20091103/1257243524) | |
+(eval-after-load "mcs-20" | |
+ '(when (coding-system-p 'cp50220) | |
+ (add-to-list 'mime-charset-coding-system-alist | |
+ '(iso-2022-jp . cp50220)))) | |
\ No newline at end of file | |
--- /dev/null 2015-04-11 07:27:58.000000000 +0900 | |
+++ ./site-lisp/smart-ime.el 2015-04-11 07:27:30.553117700 +0900 | |
@@ -0,0 +1,173 @@ | |
+;;; smart-ime.el - smart Input Method | |
+;; | |
+;; Copyright (C) 2011 HIROSHI OOTA | |
+ | |
+;; Author: HIROSHI OOTA | |
+;; Keywords: convenience | |
+ | |
+;; This program is free software; you can redistribute it and/or | |
+;; modify it under the terms of the GNU General Public License as | |
+;; published by the Free Software Foundation; either version 3, or (at | |
+;; your option) any later version. | |
+ | |
+;; This program is distributed in the hope that it will be useful, but | |
+;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
+;; General Public License for more details. | |
+ | |
+;; You should have received a copy of the GNU General Public License | |
+;; along with GNU Emacs; see the file COPYING. If not, write to the | |
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
+;; Boston, MA 02110-1301, USA. | |
+ | |
+;;; Commentary: | |
+;; | |
+;; smart-im frees you from the frustration about IM. | |
+;; It disables an IM automatically according to a situation. | |
+ | |
+;;; Install: | |
+;; Put this file into load-path'ed directory, and byte compile it if | |
+;; desired. And put the following expression into your ~/.emacs. | |
+;; | |
+;; (require 'smart-ime) | |
+ | |
+;; Todo: | |
+ | |
+;;; Code: | |
+ | |
+;; variable | |
+(defvar sime-saved-input-method nil) | |
+(make-variable-buffer-local 'sime-saved-input-method) | |
+(set-default 'sime-saved-input-method nil) | |
+ | |
+(defun sime-activate-input-method () | |
+ (setq sime-saved-input-method (list current-input-method)) | |
+ (inactivate-input-method)) | |
+(defun sime-inactivate-input-method () | |
+ (when sime-saved-input-method | |
+ (activate-input-method (car sime-saved-input-method)) | |
+ (setq sime-saved-input-method nil))) | |
+ | |
+;; | |
+;; minibuffer | |
+(add-hook 'minibuffer-setup-hook 'sime-activate-input-method) | |
+(add-hook 'minibuffer-exit-hook 'sime-inactivate-input-method) | |
+;; | |
+;; incremental search | |
+(add-hook 'isearch-mode-hook 'sime-activate-input-method) | |
+(add-hook 'isearch-mode-end-hook 'sime-inactivate-input-method) | |
+ | |
+;; | |
+;; query-replace, query-replace-regexp, query-replace-regexp-eval ... | |
+(defadvice perform-replace | |
+ (around sime-ad-perform-replace compile activate) | |
+ (let ((im current-input-method)) | |
+ (if (or (not im) | |
+ (not (ad-get-arg 2))) | |
+ ad-do-it | |
+ (inactivate-input-method) | |
+ ad-do-it | |
+ (activate-input-method im)))) | |
+ | |
+;; | |
+;; read-passwd | |
+(defadvice read-passwd | |
+ (around sime-ad-read-passwd compile activate) | |
+ (let ((sime-ad-toggle-ime-mapped-key-list nil) | |
+ (im current-input-method)) | |
+ (dolist (k (where-is-internal | |
+ 'toggle-input-method overriding-local-map nil nil | |
+ (command-remapping 'toggle-input-method))) | |
+ (when (integerp (aref k 0)) | |
+ (setq sime-ad-toggle-ime-mapped-key-list | |
+ (cons (aref k 0) sime-ad-toggle-ime-mapped-key-list)))) | |
+ | |
+ (ad-enable-advice 'read-key 'around 'sime-ad-read-key) | |
+ (ad-activate 'read-key) | |
+ (inactivate-input-method) | |
+ ad-do-it | |
+ (activate-input-method im) | |
+ (ad-disable-advice 'read-key 'around 'sime-ad-read-key) | |
+ (ad-activate 'read-key))) | |
+ | |
+(defadvice read-key | |
+ (around sime-ad-read-key compile) | |
+ (let ((flag t) | |
+ (msg (current-message))) | |
+ (while flag | |
+ ad-do-it | |
+ (if (not (memq ad-return-value | |
+ sime-ad-toggle-ime-mapped-key-list)) | |
+ (setq flag nil) | |
+ (toggle-input-method) | |
+ (message msg))))) | |
+ | |
+;; | |
+;; universal-argument | |
+(defun sime-universal-toggle-input-method (arg) | |
+ (interactive "P") | |
+ (if (consp arg) | |
+ (universal-argument-other-key arg) | |
+ (toggle-input-method) | |
+ (setq prefix-arg arg | |
+ universal-argument-num-events | |
+ (length (this-command-keys))))) | |
+ | |
+; patch universal-argument-map after init | |
+(add-hook | |
+ 'after-init-hook | |
+ #'(lambda () | |
+ (require 'simple) | |
+ (dolist (key (where-is-internal | |
+ 'toggle-input-method global-map nil nil | |
+ (command-remapping 'toggle-input-method))) | |
+ (when (= (length key) 1) | |
+ (define-key | |
+ universal-argument-map | |
+ key 'sime-universal-toggle-input-method))))) | |
+ | |
+(defadvice universal-argument | |
+ (after sime-ad-universal-argument compile activate) | |
+ (setq sime-saved-input-method | |
+ (or sime-saved-input-method | |
+ (list current-input-method))) | |
+ (inactivate-input-method)) | |
+ | |
+(defadvice restore-overriding-map | |
+ (after sime-ad-restore-overriding-map compile activate) | |
+ (when sime-saved-input-method | |
+ (activate-input-method (car sime-saved-input-method)) | |
+ (setq sime-saved-input-method nil))) | |
+ | |
+;; a keyboard which has no KANJI-KEY | |
+;; entering/leaving KANJI-mode key-sequence is <kanji><M-kanji> | |
+;; then we should pass prefix-arg to next command. | |
+(global-set-key | |
+ [M-kanji] | |
+ #'(lambda (arg) | |
+ (interactive "P") | |
+ (setq prefix-arg arg))) | |
+ | |
+;; | |
+;; others | |
+(defmacro wrap-function-to-control-input-method (fcn) | |
+ `(defadvice ,fcn (around | |
+ ,(make-symbol (concat "sime-ad-" (symbol-name fcn))) | |
+ compile activate) | |
+ (let ((im current-input-method)) | |
+ (inactivate-input-method) | |
+ ad-do-it | |
+ (activate-input-method im)))) | |
+ | |
+(wrap-function-to-control-input-method map-y-or-n-p) | |
+(wrap-function-to-control-input-method y-or-n-p) | |
+(wrap-function-to-control-input-method read-key-sequence) | |
+ | |
+;; disable W32-IME control during processing the timer handler | |
+(defadvice timer-event-handler | |
+ (around sime-ad-timer-event-handler compile activate) | |
+ (let ((w32-ime-buffer-switch-p nil)) | |
+ ad-do-it)) | |
+ | |
+(provide 'smart-ime) | |
+;; -*- mode: Emacs-Lisp; coding: euc-jp-unix -*- | |
--- ./src/alloc.c.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./src/alloc.c 2015-04-11 07:27:30.561118400 +0900 | |
@@ -30,6 +30,13 @@ | |
#ifdef HAVE_PTHREAD | |
#include <pthread.h> | |
#endif | |
+#ifdef WINDOWSNT | |
+#if (defined(_MSC_VER) && _MSC_VER >= 1600) || defined(__MINGW32__) | |
+#include <stdint.h> | |
+#else | |
+#include <crtdefs.h> | |
+#endif | |
+#endif | |
#include "lisp.h" | |
#include "process.h" | |
@@ -336,6 +343,9 @@ | |
/* Base address of stack. Set in main. */ | |
+#ifdef USE_W32_CALL_LISP_THREAD | |
+TLS | |
+#endif | |
Lisp_Object *stack_base; | |
/* Root of the tree describing allocated Lisp memory. */ | |
@@ -655,9 +665,31 @@ | |
# define MALLOC_BLOCK_INPUT malloc_block_input () | |
# define MALLOC_UNBLOCK_INPUT malloc_unblock_input () | |
#else | |
+#ifdef USE_W32_CALL_LISP_THREAD | |
+CRITICAL_SECTION alloc_critical_section; | |
+# define MALLOC_BLOCK_INPUT \ | |
+ do \ | |
+ { \ | |
+ if (dwMainThreadId == GetCurrentThreadId ()) \ | |
+ block_input (); \ | |
+ w32_apc_mutex_acquire(); \ | |
+ EnterCriticalSection(&alloc_critical_section); \ | |
+ } \ | |
+ while (0) | |
+# define MALLOC_UNBLOCK_INPUT \ | |
+ do \ | |
+ { \ | |
+ LeaveCriticalSection(&alloc_critical_section); \ | |
+ w32_apc_mutex_release(); \ | |
+ if (dwMainThreadId == GetCurrentThreadId ()) \ | |
+ unblock_input (); \ | |
+ } \ | |
+ while (0) | |
+#else | |
# define MALLOC_BLOCK_INPUT ((void) 0) | |
# define MALLOC_UNBLOCK_INPUT ((void) 0) | |
#endif | |
+#endif | |
#define MALLOC_PROBE(size) \ | |
do { \ | |
@@ -3757,6 +3789,10 @@ | |
/* This used to call error, but if we've run out of memory, we could | |
get infinite recursion trying to build the string. */ | |
xsignal (Qnil, Vmemory_signal_data); | |
+#ifdef EMACSDEBUG | |
+ if (noninteractive) | |
+ abort(); | |
+#endif | |
} | |
/* If we released our reserve (due to running out of memory), | |
@@ -5320,6 +5356,34 @@ | |
return obj; | |
} | |
+#ifdef USE_W32_CALL_LISP_THREAD | |
+static VOID CALLBACK mark_stack_stub(ULONG_PTR ev) | |
+{ | |
+ mark_stack (); | |
+ SetEvent((HANDLE)ev); | |
+} | |
+ | |
+static void w32_mark_stack() | |
+{ | |
+ static HANDLE ev; | |
+ static int inilialized = 0; | |
+ | |
+ if (hWindowsThread == NULL) | |
+ return; | |
+ | |
+ if (!inilialized) { | |
+ if ((ev = CreateEvent(NULL, FALSE, FALSE, NULL)) == NULL) | |
+ abort(); | |
+ inilialized = 1; | |
+ } | |
+ ResetEvent(ev); | |
+ | |
+ if (QueueUserAPC(mark_stack_stub, hWindowsThread, (ULONG_PTR)ev) == 0) | |
+ abort (); | |
+ | |
+ WaitForSingleObject(ev, INFINITE); | |
+} | |
+#endif | |
/*********************************************************************** | |
@@ -5582,6 +5646,10 @@ | |
message1_nolog ("Garbage collecting..."); | |
block_input (); | |
+#ifdef USE_W32_CALL_LISP_THREAD | |
+ w32_apc_mutex_acquire(); | |
+ EnterCriticalSection(&alloc_critical_section); | |
+#endif | |
shrink_regexp_cache (); | |
@@ -5607,6 +5675,9 @@ | |
#if (GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS \ | |
|| GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS) | |
mark_stack (); | |
+#ifdef USE_W32_CALL_LISP_THREAD | |
+ w32_mark_stack(); | |
+#endif | |
#else | |
{ | |
register struct gcpro *tail; | |
@@ -5663,6 +5734,10 @@ | |
gc_in_progress = 0; | |
+#ifdef USE_W32_CALL_LISP_THREAD | |
+ w32_apc_mutex_release(); | |
+ LeaveCriticalSection(&alloc_critical_section); | |
+#endif | |
unblock_input (); | |
consing_since_gc = 0; | |
--- ./src/callproc.c.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./src/callproc.c 2015-04-11 07:27:30.567120000 +0900 | |
@@ -30,6 +30,9 @@ | |
#include "lisp.h" | |
+#ifdef DOS_NT | |
+#include <mbstring.h> | |
+#endif | |
#ifdef WINDOWSNT | |
#define NOMINMAX | |
#include <sys/socket.h> /* for fcntl */ | |
@@ -1236,6 +1239,10 @@ | |
at least check. */ | |
if (chdir (temp) < 0) | |
_exit (EXIT_CANCELED); | |
+ | |
+ /* Strip trailing slashes for PWD, but leave "/" and "//" alone. */ | |
+ while (i > 2 && IS_DIRECTORY_SEP (temp[i - 1])) | |
+ temp[--i] = 0; | |
#else /* DOS_NT */ | |
/* Get past the drive letter, so that d:/ is left alone. */ | |
if (i > 2 && IS_DEVICE_SEP (temp[1]) && IS_DIRECTORY_SEP (temp[2])) | |
@@ -1243,11 +1250,11 @@ | |
temp += 2; | |
i -= 2; | |
} | |
-#endif /* DOS_NT */ | |
/* Strip trailing slashes for PWD, but leave "/" and "//" alone. */ | |
- while (i > 2 && IS_DIRECTORY_SEP (temp[i - 1])) | |
+ while (i > 2 && IS_DIRECTORY_SEP (*_mbsdec(temp, temp + i))) | |
temp[--i] = 0; | |
+#endif /* DOS_NT */ | |
} | |
/* Set `env' to a vector of the strings in the environment. */ | |
--- /dev/null 2015-04-11 07:27:59.000000000 +0900 | |
+++ ./src/cmigemo.c 2015-04-11 07:27:30.576125800 +0900 | |
@@ -0,0 +1,460 @@ | |
+#ifdef NULL | |
+#undef NULL | |
+#endif | |
+#include <config.h> | |
+#ifdef HAVE_CMIGEMO | |
+#include <setjmp.h> | |
+ | |
+#include "lisp.h" | |
+#include "charset.h" | |
+#include "coding.h" | |
+ | |
+#ifdef WINDOWSNT | |
+#include <windows.h> | |
+#define MIGEMO_DLL "migemo.dll" | |
+#else | |
+#ifdef CYGWIN | |
+#define MIGEMO_DLL "cygmigemo1.dll" | |
+#else | |
+#define MIGEMO_DLL "libmigemo.so" | |
+#endif | |
+#include <stdio.h> | |
+#include <dlfcn.h> | |
+#endif | |
+ | |
+#include "migemo.h" | |
+ | |
+/* from cmigemo charset.h */ | |
+enum { | |
+ CHARSET_NONE = 0, | |
+ CHARSET_CP932 = 1, | |
+ CHARSET_EUCJP = 2, | |
+ CHARSET_UTF8 = 3, | |
+}; | |
+typedef int (*charset_proc_int2char)(unsigned int, unsigned char*); | |
+#define CHARSET_PROC_INT2CHAR charset_proc_int2char | |
+ | |
+/* from cmigemo charset.c */ | |
+#define BUFLEN_DETECT 4096 | |
+static int cp932_int2char(unsigned int in, unsigned char* out) | |
+{ | |
+ if (in >= 0x100) | |
+ { | |
+ if (out) | |
+ { | |
+ out[0] = (unsigned char)((in >> 8) & 0xFF); | |
+ out[1] = (unsigned char)(in & 0xFF); | |
+ } | |
+ return 2; | |
+ } | |
+ else | |
+ return 0; | |
+} | |
+static int eucjp_int2char(unsigned int in, unsigned char* out) | |
+{ | |
+ /* CP932ã¨å 容ã¯åãã ãå°æ¥JISX0213ã«å¯¾å¿ãããããã«åé¢ãã¦ãã */ | |
+ if (in >= 0x100) | |
+ { | |
+ if (out) | |
+ { | |
+ out[0] = (unsigned char)((in >> 8) & 0xFF); | |
+ out[1] = (unsigned char)(in & 0xFF); | |
+ } | |
+ return 2; | |
+ } | |
+ else | |
+ return 0; | |
+} | |
+static int utf8_int2char(unsigned int in, unsigned char* out) | |
+{ | |
+ if (in < 0x80) | |
+ return 0; | |
+ if (in < 0x800) | |
+ { | |
+ if (out) | |
+ { | |
+ out[0] = 0xc0 + (in >> 6); | |
+ out[1] = 0x80 + ((in >> 0) & 0x3f); | |
+ } | |
+ return 2; | |
+ } | |
+ if (in < 0x10000) | |
+ { | |
+ if (out) | |
+ { | |
+ out[0] = 0xe0 + (in >> 12); | |
+ out[1] = 0x80 + ((in >> 6) & 0x3f); | |
+ out[2] = 0x80 + ((in >> 0) & 0x3f); | |
+ } | |
+ return 3; | |
+ } | |
+ if (in < 0x200000) | |
+ { | |
+ if (out) | |
+ { | |
+ out[0] = 0xf0 + (in >> 18); | |
+ out[1] = 0x80 + ((in >> 12) & 0x3f); | |
+ out[2] = 0x80 + ((in >> 6) & 0x3f); | |
+ out[3] = 0x80 + ((in >> 0) & 0x3f); | |
+ } | |
+ return 4; | |
+ } | |
+ if (in < 0x4000000) | |
+ { | |
+ if (out) | |
+ { | |
+ out[0] = 0xf8 + (in >> 24); | |
+ out[1] = 0x80 + ((in >> 18) & 0x3f); | |
+ out[2] = 0x80 + ((in >> 12) & 0x3f); | |
+ out[3] = 0x80 + ((in >> 6) & 0x3f); | |
+ out[4] = 0x80 + ((in >> 0) & 0x3f); | |
+ } | |
+ return 5; | |
+ } | |
+ else | |
+ { | |
+ if (out) | |
+ { | |
+ out[0] = 0xf8 + (in >> 30); | |
+ out[1] = 0x80 + ((in >> 24) & 0x3f); | |
+ out[2] = 0x80 + ((in >> 18) & 0x3f); | |
+ out[3] = 0x80 + ((in >> 12) & 0x3f); | |
+ out[4] = 0x80 + ((in >> 6) & 0x3f); | |
+ out[5] = 0x80 + ((in >> 0) & 0x3f); | |
+ } | |
+ return 6; | |
+ } | |
+} | |
+static int | |
+charset_detect_buf(const unsigned char* buf, int len) | |
+{ | |
+ int sjis = 0, smode = 0; | |
+ int euc = 0, emode = 0, eflag = 0; | |
+ int utf8 = 0, umode = 0, ufailed = 0; | |
+ int i; | |
+ for (i = 0; i < len; ++i) | |
+ { | |
+ unsigned char c = buf[i]; | |
+ // SJISã§ãããã®ãã§ã㯠| |
+ if (smode) | |
+ { | |
+ if ((0x40 <= c && c <= 0x7e) || (0x80 <= c && c <= 0xfc)) | |
+ ++sjis; | |
+ smode = 0; | |
+ } | |
+ else if ((0x81 <= c && c <= 0x9f) || (0xe0 <= c && c <= 0xf0)) | |
+ smode = 1; | |
+ // EUCã§ãããã®ãã§ã㯠| |
+ eflag = 0xa1 <= c && c <= 0xfe; | |
+ if (emode) | |
+ { | |
+ if (eflag) | |
+ ++euc; | |
+ emode = 0; | |
+ } | |
+ else if (eflag) | |
+ emode = 1; | |
+ // UTF8ã§ãããã®ãã§ã㯠| |
+ if (!ufailed) | |
+ { | |
+ if (umode < 1) | |
+ { | |
+ if ((c & 0x80) != 0) | |
+ { | |
+ if ((c & 0xe0) == 0xc0) | |
+ umode = 1; | |
+ else if ((c & 0xf0) == 0xe0) | |
+ umode = 2; | |
+ else if ((c & 0xf8) == 0xf0) | |
+ umode = 3; | |
+ else if ((c & 0xfc) == 0xf8) | |
+ umode = 4; | |
+ else if ((c & 0xfe) == 0xfc) | |
+ umode = 5; | |
+ else | |
+ { | |
+ ufailed = 1; | |
+ --utf8; | |
+ } | |
+ } | |
+ } | |
+ else | |
+ { | |
+ if ((c & 0xc0) == 0x80) | |
+ { | |
+ ++utf8; | |
+ --umode; | |
+ } | |
+ else | |
+ { | |
+ --utf8; | |
+ umode = 0; | |
+ ufailed = 1; | |
+ } | |
+ } | |
+ if (utf8 < 0) | |
+ utf8 = 0; | |
+ } | |
+ } | |
+ // æçµçã«ä¸çªå¾ç¹ã®é«ãã¨ã³ã³ã¼ããè¿ã | |
+ if (euc > sjis && euc > utf8) | |
+ return CHARSET_EUCJP; | |
+ else if (!ufailed && utf8 > euc && utf8 > sjis) | |
+ return CHARSET_UTF8; | |
+ else if (sjis > euc && sjis > utf8) | |
+ return CHARSET_CP932; | |
+ else | |
+ return CHARSET_NONE; | |
+} | |
+static int | |
+charset_detect_file(const char* path) | |
+{ | |
+ int charset = CHARSET_NONE; | |
+ FILE* fp; | |
+ if ((fp = fopen(path, "rt")) != NULL) | |
+ { | |
+ unsigned char buf[BUFLEN_DETECT]; | |
+ size_t len = fread(buf, sizeof(buf[0]), sizeof(buf), fp); | |
+ fclose(fp); | |
+ if (len > 0 && len <= INT_MAX) | |
+ charset = charset_detect_buf(buf, (int)len); | |
+ } | |
+ return charset; | |
+} | |
+/**/ | |
+ | |
+migemo* (*migemo_open_)(const char*); | |
+void (*migemo_close_)(migemo*); | |
+unsigned char* (*migemo_query_)(migemo*, unsigned char*); | |
+void (*migemo_release_)(migemo*, unsigned char*); | |
+ | |
+int (*migemo_set_operator_)(migemo*, int, unsigned char*); | |
+int (*migemo_is_enable_)(migemo*); | |
+int (*migemo_load_)(migemo*, int, char *); | |
+void (*migemo_setproc_char2int_)(migemo*, MIGEMO_PROC_CHAR2INT); | |
+void (*migemo_setproc_int2char_)(migemo*, MIGEMO_PROC_INT2CHAR); | |
+ | |
+static migemo *pmigemo = NULL; | |
+#ifdef WINDOWSNT | |
+static HMODULE hMigemo = NULL; | |
+#else | |
+static void *hMigemo = NULL; | |
+#endif | |
+ | |
+static int int2char(unsigned int in, unsigned char* out, | |
+ CHARSET_PROC_INT2CHAR proc) | |
+{ | |
+ switch (in) { | |
+ case '.': case '*': case '+': case '?': | |
+ case '[': case ']': case '^': case '$': | |
+ case '\\': | |
+ if (!out) | |
+ return 0; | |
+ out[0] = '\\'; | |
+ out[1] = in; | |
+ return 2; | |
+ default: | |
+ break; | |
+ } | |
+ return (*proc)(in, out); | |
+} | |
+ | |
+static int eucjp(unsigned int in, unsigned char* out) | |
+{ | |
+ return int2char(in, out, eucjp_int2char); | |
+} | |
+ | |
+static int cp932(unsigned int in, unsigned char* out) | |
+{ | |
+ return int2char(in, out, cp932_int2char); | |
+} | |
+ | |
+static int utf8(unsigned int in, unsigned char* out) | |
+{ | |
+ return int2char(in, out, utf8_int2char); | |
+} | |
+ | |
+static int charset; | |
+ | |
+static MIGEMO_PROC_INT2CHAR getproc(int charset) | |
+{ | |
+ | |
+ switch (charset) { | |
+ case CHARSET_CP932: | |
+ return cp932; | |
+ break; | |
+ case CHARSET_EUCJP: | |
+ return eucjp; | |
+ break; | |
+ case CHARSET_UTF8: | |
+ return utf8; | |
+ break; | |
+ default: | |
+ break; | |
+ } | |
+ return NULL; | |
+} | |
+ | |
+DEFUN ("cmigemo-open", Fcmigemo_open, Scmigemo_open, 1, 1, 0, | |
+ doc: /* open cmigemo with DICTIONARY.*/ ) | |
+ (Lisp_Object dictionary) | |
+{ | |
+ static int coding_system_initialized = 0; | |
+ MIGEMO_PROC_INT2CHAR int2char; | |
+ | |
+ if (pmigemo) | |
+ error ("cmigemo already opened"); | |
+ | |
+ CHECK_STRING(dictionary); | |
+ | |
+#ifdef WINDOWSNT | |
+ hMigemo = LoadLibrary(MIGEMO_DLL); | |
+#else | |
+ hMigemo = dlopen(MIGEMO_DLL, RTLD_NOW); | |
+#endif | |
+ if (hMigemo == NULL) | |
+ error (MIGEMO_DLL ": can't load"); | |
+ | |
+#ifdef WINDOWSNT | |
+#define GETPROC(n, t) do { \ | |
+ migemo_ ## n ## _ = (t) GetProcAddress(hMigemo, "migemo_" # n); \ | |
+} while(0) | |
+#else | |
+#define GETPROC(n, t) do { \ | |
+ migemo_ ## n ## _ = (t) dlsym(hMigemo, "migemo_" # n); \ | |
+} while(0) | |
+#endif | |
+ | |
+ GETPROC(open, migemo* (*)(const char*)); | |
+ GETPROC(close, void (*)(migemo*)); | |
+ GETPROC(query, unsigned char* (*)(migemo*, unsigned char*)); | |
+ GETPROC(release, void (*)(migemo*, unsigned char*)); | |
+ GETPROC(set_operator, int (*)(migemo*, int, unsigned char*)); | |
+ GETPROC(is_enable, int (*)(migemo*)); | |
+ GETPROC(load, int (*)(migemo*, int, char *)); | |
+ GETPROC(setproc_char2int, void (*)(migemo*, MIGEMO_PROC_CHAR2INT)); | |
+ GETPROC(setproc_int2char, void (*)(migemo*, MIGEMO_PROC_INT2CHAR)); | |
+ | |
+ if (!(pmigemo = migemo_open_(SDATA(dictionary))) || | |
+ !migemo_is_enable_(pmigemo)) { | |
+ pmigemo = NULL; | |
+ error("could not open cmigemo"); | |
+ } | |
+ migemo_set_operator_(pmigemo, MIGEMO_OPINDEX_OR, "\\|"); | |
+ migemo_set_operator_(pmigemo, MIGEMO_OPINDEX_NEST_IN, "\\("); | |
+ migemo_set_operator_(pmigemo, MIGEMO_OPINDEX_NEST_OUT, "\\)"); | |
+ migemo_set_operator_(pmigemo, MIGEMO_OPINDEX_NEWLINE, "\\s-*"); | |
+ | |
+ charset = charset_detect_file(SDATA(dictionary)); | |
+ | |
+ if ((int2char = getproc(charset)) != NULL) | |
+ migemo_setproc_int2char_(pmigemo, int2char); | |
+ | |
+ return Qt; | |
+} | |
+ | |
+DEFUN ("cmigemo-close", Fcmigemo_close, Scmigemo_close, 0, 0, 0, | |
+ doc: /*close cmigemo.*/) | |
+ (void) | |
+{ | |
+ if (!pmigemo) | |
+ error ("cmigemo was not opened"); | |
+ migemo_close_(pmigemo); | |
+ pmigemo = NULL; | |
+#ifdef WINDOWSNT | |
+ FreeLibrary(hMigemo); | |
+#else | |
+ dlclose(hMigemo); | |
+#endif | |
+ hMigemo = NULL; | |
+ return Qt; | |
+} | |
+ | |
+DEFUN ("cmigemo-query", Fcmigemo_query, Scmigemo_query, 1, 1, 0, | |
+ doc: /*query cmigemo about WORD.*/) | |
+ (Lisp_Object word) | |
+{ | |
+ char *ans; | |
+ Lisp_Object temp; | |
+ struct gcpro gcpro1; | |
+ | |
+ if (!pmigemo) | |
+ error ("cmigemo was not opened"); | |
+ | |
+ CHECK_STRING(word); | |
+ | |
+ GCPRO1(temp); | |
+ temp = word; | |
+ | |
+ if (STRING_MULTIBYTE (temp)) | |
+ switch (charset) { | |
+ default: | |
+ case CHARSET_CP932: | |
+ temp = code_convert_string_norecord(temp, intern("sjis"), 1); | |
+ break; | |
+ case CHARSET_EUCJP: | |
+ temp = code_convert_string_norecord(temp, intern("euc-japan"), 1); | |
+ break; | |
+ case CHARSET_UTF8: | |
+ break; | |
+ } | |
+ | |
+ ans = migemo_query_(pmigemo, SDATA(temp)); | |
+ | |
+ if (!ans) | |
+ temp = Qnil; | |
+ else | |
+ switch (charset) { | |
+ default: | |
+ case CHARSET_CP932: | |
+ temp = code_convert_string_norecord(temp = build_string(ans), | |
+ intern("sjis"), 0); | |
+ break; | |
+ case CHARSET_EUCJP: | |
+ temp = code_convert_string_norecord(temp = build_string(ans), | |
+ intern("euc-japan"), 0); | |
+ break; | |
+ case CHARSET_UTF8: | |
+ temp = build_string(ans); | |
+ break; | |
+ } | |
+ UNGCPRO; | |
+ migemo_release_(pmigemo, ans); | |
+ return temp; | |
+} | |
+ | |
+DEFUN ("cmigemo-load", Fcmigemo_load, Scmigemo_load, 1, 1, 0, | |
+ doc: /*load a sub DICTIONARY.*/) | |
+ (Lisp_Object dictionary) | |
+{ | |
+ MIGEMO_PROC_INT2CHAR int2char; | |
+ | |
+ if (!pmigemo) | |
+ error ("cmigemo was not opened"); | |
+ | |
+ CHECK_STRING(dictionary); | |
+ | |
+ if (migemo_load_(pmigemo, MIGEMO_DICTID_MIGEMO, | |
+ SDATA(dictionary)) == MIGEMO_DICTID_INVALID) | |
+ error("migemo_load invalid dict %s", dictionary); | |
+ | |
+ /* | |
+ * Migemo_load resets int2char proc, | |
+ * then we set it again. | |
+ */ | |
+ | |
+ int2char = getproc(charset); | |
+ migemo_setproc_int2char_(pmigemo, int2char); | |
+ | |
+ return Qt; | |
+} | |
+ | |
+void | |
+syms_of_cmigemo () | |
+{ | |
+ defsubr(&Scmigemo_open); | |
+ defsubr(&Scmigemo_close); | |
+ defsubr(&Scmigemo_query); | |
+ defsubr(&Scmigemo_load); | |
+} | |
+#endif /* HAVE_CMIGEMO */ | |
--- ./src/doprnt.c.orig 2015-02-02 02:27:17.000000000 +0900 | |
+++ ./src/doprnt.c 2015-04-11 07:27:30.582120600 +0900 | |
@@ -155,9 +155,9 @@ | |
if (format_end == 0) | |
format_end = format + strlen (format); | |
- fmtcpy = (format_end - format < sizeof (fixed_buffer) - 1 | |
+ fmtcpy = (format_end - format + 1 + 1 < sizeof (fixed_buffer) | |
? fixed_buffer | |
- : SAFE_ALLOCA (format_end - format + 1)); | |
+ : SAFE_ALLOCA (format_end - format + 1 + 1)); | |
bufsize--; | |
--- ./src/emacs.c.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./src/emacs.c 2015-04-11 07:27:30.589121000 +0900 | |
@@ -208,6 +208,10 @@ | |
static void sort_args (int argc, char **argv); | |
static void syms_of_emacs (void); | |
+#ifdef HAVE_CMIGEMO | |
+extern void syms_of_cmigemo (void); | |
+#endif | |
+ | |
/* C89 needs each string be at most 509 characters, so the usage | |
strings below are split to not overflow this limit. */ | |
static char const *const usage_message[] = | |
@@ -768,6 +772,13 @@ | |
atexit (close_output_streams); | |
+#ifdef USE_W32_CALL_LISP_THREAD | |
+ { | |
+ extern CRITICAL_SECTION alloc_critical_section; | |
+ InitializeCriticalSection(&alloc_critical_section); | |
+ } | |
+#endif | |
+ | |
sort_args (argc, argv); | |
argc = 0; | |
while (argv[argc]) argc++; | |
@@ -1523,6 +1534,10 @@ | |
syms_of_profiler (); | |
+#ifdef HAVE_CMIGEMO | |
+ syms_of_cmigemo (); | |
+#endif /* HAVE_CMIGEMO */ | |
+ | |
keys_of_casefiddle (); | |
keys_of_cmds (); | |
keys_of_buffer (); | |
--- ./src/frame.c.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./src/frame.c 2015-04-11 07:27:30.596121900 +0900 | |
@@ -2744,6 +2744,9 @@ | |
{"fullscreen", &Qfullscreen}, | |
{"font-backend", &Qfont_backend}, | |
{"alpha", &Qalpha}, | |
+#ifdef USE_W32_IME | |
+ {"ime-font", &Qime_font}, | |
+#endif /* USE_W32_IME */ | |
{"sticky", &Qsticky}, | |
{"tool-bar-position", &Qtool_bar_position}, | |
}; | |
--- ./src/frame.h.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./src/frame.h 2015-04-11 07:27:30.604123000 +0900 | |
@@ -1217,6 +1217,9 @@ | |
extern Lisp_Object Qbuffer_predicate; | |
extern Lisp_Object Qcursor_color, Qcursor_type; | |
extern Lisp_Object Qfont; | |
+#ifdef USE_W32_IME | |
+extern Lisp_Object Qime_font; | |
+#endif /* USE_W32_IME */ | |
extern Lisp_Object Qbackground_color, Qforeground_color; | |
extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top; | |
extern Lisp_Object Qinternal_border_width; | |
--- ./src/image.c.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./src/image.c 2015-04-11 07:27:30.613127900 +0900 | |
@@ -536,6 +536,10 @@ | |
static struct image_type *image_types; | |
+/* "Alist of (IMAGE-TYPE . FIT-OPTION) pairs used by image loader to specify image size. */ | |
+ | |
+//static Lisp_Object Vimage_fit_option_alist; | |
+ | |
/* The symbol `xbm' which is used as the type symbol for XBM images. */ | |
static Lisp_Object Qxbm; | |
@@ -544,6 +548,7 @@ | |
Lisp_Object QCascent, QCmargin, QCrelief; | |
Lisp_Object QCconversion; | |
+Lisp_Object QCfit; | |
static Lisp_Object QCheuristic_mask; | |
static Lisp_Object QCcolor_symbols; | |
static Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask, QCgeometry; | |
@@ -617,6 +622,102 @@ | |
return p; | |
} | |
+Lisp_Object Qnever, Qframe, Qwidth_or_height; | |
+ | |
+static void image_error (const char *, Lisp_Object, Lisp_Object); | |
+static int get_fit_size(Lisp_Object opt, const struct frame *f, | |
+ int *w, int *h, | |
+ Lisp_Object image_type, int rise_error) | |
+{ | |
+ if (NILP(opt)) | |
+ return 0; | |
+ | |
+ if (EQ(opt, Qnever)) { | |
+ *w = *h = 0; | |
+ } else if (EQ(opt, Qframe)) { | |
+ *w = FRAME_PIXEL_WIDTH (f) - FRAME_CONFIG_SCROLL_BAR_WIDTH (f) - FRAME_SCROLL_BAR_AREA_WIDTH (f); | |
+ *h = FRAME_PIXEL_HEIGHT (f); | |
+ } else if (EQ(opt, Qwidth_or_height)) { | |
+ *w = -(FRAME_PIXEL_WIDTH (f) - FRAME_CONFIG_SCROLL_BAR_WIDTH (f) - FRAME_SCROLL_BAR_AREA_WIDTH (f)); | |
+ *h = -FRAME_PIXEL_HEIGHT (f); | |
+ } else if (EQ(opt, Qwidth)) { | |
+ *w = FRAME_PIXEL_WIDTH (f) - FRAME_CONFIG_SCROLL_BAR_WIDTH (f) - FRAME_SCROLL_BAR_AREA_WIDTH (f); | |
+ *h = 0; | |
+ } else if (EQ(opt, Qheight)) { | |
+ *w = 0; | |
+ *h = FRAME_PIXEL_HEIGHT (f); | |
+ } else { | |
+ if (rise_error) | |
+ xsignal2 (Qnil, build_string("unknown fit type"), opt); | |
+ else | |
+ image_error ("Invalid fit option for %s", image_type, Qnil); | |
+ return -1; | |
+ } | |
+ return 1; | |
+} | |
+ | |
+static Lisp_Object image_spec_value (Lisp_Object, Lisp_Object, bool *); | |
+static int | |
+lookup_fit_size(Lisp_Object image_type, | |
+ const struct frame *f, | |
+ const struct image *img, | |
+ int *w, int *h, int rise_error) | |
+{ | |
+ Lisp_Object a, err, pred; | |
+ static const struct frame f_ = {0}; | |
+ int w_, h_; | |
+ int r; | |
+ | |
+// assert(SYMBOLP (image_type)); | |
+ | |
+ if (img && | |
+ (r = get_fit_size(image_spec_value(img->spec, QCfit, NULL), | |
+ f, w, h, image_type, rise_error)) != 0) | |
+ return r; | |
+ | |
+#if 0 | |
+ if (!CONSP (err = Vimage_fit_option_alist)) { | |
+ pred = Qconsp; | |
+ goto error; | |
+ } | |
+#endif | |
+ | |
+ for (a = Vimage_fit_option_alist; !NILP(a); a = XCDR(a)) { | |
+ Lisp_Object o; | |
+ { | |
+ Lisp_Object e = XCAR(a); | |
+ | |
+ if (!CONSP(err = e)) { | |
+ pred = Qconsp; | |
+ goto error; | |
+ } | |
+ | |
+ if (!EQ(XCAR(e), image_type)) | |
+ continue; | |
+ o = XCDR(e); | |
+ } | |
+ | |
+ if (!SYMBOLP(err = o)) { | |
+ pred = Qsymbolp; | |
+ goto error; | |
+ } | |
+ if (f) | |
+ return get_fit_size(o, f, w, h, image_type, rise_error); | |
+ get_fit_size(o, &f_, &w_, &h_, image_type, rise_error); | |
+ } | |
+ | |
+ /* not found */ | |
+ if (f) | |
+ *w = *h = 0; | |
+ return 0; | |
+ | |
+ error: | |
+ if (rise_error) | |
+ wrong_type_argument(pred, err); | |
+ else | |
+ image_error ("Invalid fit option for %s", image_type, Qnil); | |
+ return -1; | |
+} | |
/* Value is true if OBJECT is a valid Lisp image specification. A | |
valid image specification is a list whose car is the symbol | |
@@ -3096,6 +3197,8 @@ | |
#define XImage xpm_XImage | |
#define Display xpm_Display | |
#define PIXEL_ALREADY_TYPEDEFED | |
+#undef close | |
+#undef open | |
#include "X11/xpm.h" | |
#undef FOR_MSW | |
#undef XColor | |
@@ -6483,6 +6586,10 @@ | |
XImagePtr ximg = NULL; | |
unsigned long *colors; | |
int width, height; | |
+ int fit_width = 0, fit_height = 0; | |
+ | |
+ if (lookup_fit_size (Qjpeg, f, img, &fit_width, &fit_height, !0) < 0) | |
+ return 0; | |
/* Open the JPEG file. */ | |
specified_file = image_spec_value (img->spec, QCfile, NULL); | |
@@ -6560,6 +6667,43 @@ | |
fn_jpeg_read_header (&mgr->cinfo, 1); | |
+#define JPEG8C_UNIT 8 | |
+ | |
+ if (fit_width > 0 && fit_height == 0) { | |
+ if (mgr->cinfo.image_width > fit_width) { /* fit to width */ | |
+ mgr->cinfo.scale_num = ((double) fit_width / mgr->cinfo.image_width) * JPEG8C_UNIT; | |
+ mgr->cinfo.scale_denom = JPEG8C_UNIT; | |
+ } | |
+ } else if (fit_width == 0 && fit_height > 0) { | |
+ if (mgr->cinfo.image_height > fit_height) { /* fit to width */ | |
+ mgr->cinfo.scale_num = ((double)fit_height / mgr->cinfo.image_height) * JPEG8C_UNIT; | |
+ mgr->cinfo.scale_denom = JPEG8C_UNIT; | |
+ } | |
+ } else if (fit_width > 0 && fit_height > 0) { /* fit to frame */ | |
+ if (mgr->cinfo.image_width > fit_width || | |
+ mgr->cinfo.image_height > fit_height) { | |
+ if ((double)fit_width / mgr->cinfo.image_width < | |
+ (double)fit_height / mgr->cinfo.image_height) { | |
+ mgr->cinfo.scale_num = ((double)fit_width / mgr->cinfo.image_width) * JPEG8C_UNIT; | |
+ } else { | |
+ mgr->cinfo.scale_num = ((double)fit_height / mgr->cinfo.image_height) * JPEG8C_UNIT; | |
+ mgr->cinfo.scale_denom = JPEG8C_UNIT; | |
+ } | |
+ } | |
+ } else if (fit_width < 0 && fit_height < 0) { /* fit to width or height */ | |
+ if (mgr->cinfo.image_width > -fit_width && | |
+ mgr->cinfo.image_height > -fit_height) { | |
+ if ((double)-fit_width / mgr->cinfo.image_width > | |
+ (double)-fit_height / mgr->cinfo.image_height) { | |
+ mgr->cinfo.scale_num = ((double)-fit_width / mgr->cinfo.image_width) * JPEG8C_UNIT; | |
+ mgr->cinfo.scale_denom = JPEG8C_UNIT; | |
+ } else { | |
+ mgr->cinfo.scale_num = ((double)-fit_height / mgr->cinfo.image_height) * JPEG8C_UNIT; | |
+ mgr->cinfo.scale_denom = JPEG8C_UNIT; | |
+ } | |
+ } | |
+ } | |
+ | |
/* Customize decompression so that color quantization will be used. | |
Start decompression. */ | |
mgr->cinfo.quantize_colors = 1; | |
@@ -8512,6 +8656,12 @@ | |
{ | |
bool success_p = 0; | |
Lisp_Object file_name; | |
+ int w, h; | |
+ | |
+#if 0 | |
+ if (lookup_fit_size(Qjpeg, NULL, NULL, NULL, NULL, !0) < 0) | |
+ return 0; | |
+#endif | |
/* If IMG->spec specifies a file name, create a non-file spec from it. */ | |
file_name = image_spec_value (img->spec, QCfile, NULL); | |
@@ -8722,6 +8872,7 @@ | |
LOAD_IMGLIB_FN (library, rsvg_handle_write); | |
LOAD_IMGLIB_FN (library, rsvg_handle_close); | |
LOAD_IMGLIB_FN (library, rsvg_handle_get_pixbuf); | |
+ LOAD_IMGLIB_FN (library, rsvg_handle_set_size_callback); | |
LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_width); | |
LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_height); | |
@@ -8749,6 +8900,7 @@ | |
#define fn_rsvg_handle_write rsvg_handle_write | |
#define fn_rsvg_handle_close rsvg_handle_close | |
#define fn_rsvg_handle_get_pixbuf rsvg_handle_get_pixbuf | |
+#define fn_rsvg_handle_set_size_callback rsvg_handle_set_size_callback | |
#define fn_gdk_pixbuf_get_width gdk_pixbuf_get_width | |
#define fn_gdk_pixbuf_get_height gdk_pixbuf_get_height | |
@@ -8819,6 +8971,48 @@ | |
return success_p; | |
} | |
+static void rsvg_size_callback (gint *width, | |
+ gint *height, | |
+ gpointer user_data) | |
+{ | |
+ int *fit_size = (int *)user_data; | |
+ | |
+ /* | |
+ * 0, 0: never | |
+ * 0, +: fit to height | |
+ * +, 0: fit to width | |
+ * +, +: fit to frame | |
+ * -, -: fit to width or height | |
+ */ | |
+ if (fit_size[0] > 0 && fit_size[1] == 0) { | |
+ *height *= (double)fit_size[0] / *width; | |
+ *width = (gint)fit_size[0]; | |
+ } else if (fit_size[0] == 0 && fit_size[1] > 0) { | |
+ *width *= (double)fit_size[1] / *height; | |
+ *height = (gint)fit_size[1]; | |
+ } else if (fit_size[0] > 0 && fit_size[1] > 0) { /* fit to frame */ | |
+ if ((double)fit_size[0] / *width < (double)fit_size[1] / *height) { | |
+ /* fit to width */ | |
+ *height *= (double)fit_size[0] / *width; | |
+ *width = (gint)fit_size[0]; | |
+ } else { | |
+ /* fit to height */ | |
+ *width *= (double)fit_size[1] / *height; | |
+ *height = (gint)fit_size[1]; | |
+ } | |
+ } else if (fit_size[0] < 0 && fit_size[1] < 0) { /* fit to width or height */ | |
+ if ((double)-fit_size[0] / *width < (double)-fit_size[1] / *height) { | |
+ /* fit to height */ | |
+ *width *= (double)-fit_size[1] / *height; | |
+ *height = (gint)-fit_size[1]; | |
+ } else { | |
+ /* fit to width */ | |
+ *height *= (double)-fit_size[0] / *width; | |
+ *width = (gint)-fit_size[0]; | |
+ } | |
+ } | |
+} | |
+ | |
/* svg_load_image is a helper function for svg_load, which does the | |
actual loading given contents and size, apart from frame and image | |
structures, passed from svg_load. | |
@@ -8845,6 +9039,10 @@ | |
XColor background; | |
int x; | |
int y; | |
+ int fit_size[2] = {0, 0}; | |
+ | |
+ if (lookup_fit_size(Qsvg, f, img, fit_size, fit_size+1, 0) < 0) | |
+ return 0; | |
#if ! GLIB_CHECK_VERSION (2, 36, 0) | |
/* g_type_init is a glib function that must be called prior to | |
@@ -8855,6 +9053,9 @@ | |
/* Make a handle to a new rsvg object. */ | |
rsvg_handle = fn_rsvg_handle_new (); | |
+ if (fit_size[0] || fit_size[1]) | |
+ fn_rsvg_handle_set_size_callback(rsvg_handle, rsvg_size_callback, fit_size, NULL); | |
+ | |
/* Parse the contents argument and fill in the rsvg_handle. */ | |
fn_rsvg_handle_write (rsvg_handle, contents, size, &err); | |
if (err) goto rsvg_error; | |
@@ -9438,6 +9639,7 @@ | |
DEFSYM (QCmatrix, ":matrix"); | |
DEFSYM (QCcolor_adjustment, ":color-adjustment"); | |
DEFSYM (QCmask, ":mask"); | |
+ DEFSYM (QCfit, ":fit"); | |
DEFSYM (Qlaplace, "laplace"); | |
DEFSYM (Qemboss, "emboss"); | |
@@ -9484,12 +9686,26 @@ | |
); | |
#endif | |
+ DEFVAR_LISP ("image-fit-option-alist", Vimage_fit_option_alist, | |
+ doc: /* Alist of (IMAGE-TYPE . FIT-OPTION) pairs used by image loader to specify image size. | |
+the FIT-OPTION is one of 'never, 'frame, 'width-or-height, 'width or 'height. | |
+Note: All image loaders are not supporting this `fit' capability. */); | |
+ Vimage_fit_option_alist = Qnil; | |
+ | |
DEFSYM (Qpbm, "pbm"); | |
ADD_IMAGE_TYPE (Qpbm); | |
DEFSYM (Qxbm, "xbm"); | |
ADD_IMAGE_TYPE (Qxbm); | |
+ Qnever = intern_c_string("never"); | |
+ staticpro (&Qnever); | |
+ Qframe = intern_c_string("frame"); | |
+ staticpro (&Qframe); | |
+ Qwidth_or_height = intern_c_string("width-or-height"); | |
+ staticpro (&Qwidth_or_height); | |
+ | |
+ | |
#if defined (HAVE_XPM) || defined (HAVE_NS) | |
DEFSYM (Qxpm, "xpm"); | |
ADD_IMAGE_TYPE (Qxpm); | |
@@ -9523,7 +9739,7 @@ | |
#if defined (HAVE_RSVG) | |
DEFSYM (Qsvg, "svg"); | |
ADD_IMAGE_TYPE (Qsvg); | |
-#ifdef HAVE_NTGUI | |
+#if defined HAVE_NTGUI && !defined CYGWIN | |
/* Other libraries used directly by svg code. */ | |
DEFSYM (Qgdk_pixbuf, "gdk-pixbuf"); | |
DEFSYM (Qglib, "glib"); | |
--- ./src/keyboard.c.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./src/keyboard.c 2015-04-11 07:27:30.625123200 +0900 | |
@@ -4779,7 +4779,11 @@ | |
"junja", /* VK_JUNJA 0x17 */ | |
"final", /* VK_FINAL 0x18 */ | |
"kanji", /* VK_KANJI/VK_HANJA 0x19 */ | |
+#ifdef USE_W32_IME | |
+ "compend", /* VK_COMPEND 0x1A */ | |
+#else | |
0, /* 0x1A */ | |
+#endif /* USE_W32_IME */ | |
"escape", /* VK_ESCAPE 0x1B */ | |
"convert", /* VK_CONVERT 0x1C */ | |
"non-convert", /* VK_NONCONVERT 0x1D */ | |
@@ -8851,6 +8855,13 @@ | |
{ | |
ptrdiff_t count = SPECPDL_INDEX (); | |
+ /* To control IME */ | |
+#ifdef USE_W32_IME | |
+ extern Lisp_Object Fime_force_on (), Fime_force_off (), Fime_get_mode (); | |
+ Lisp_Object VIME_command_off_flag = Qnil; | |
+ Lisp_Object IME_command_loop_flag = Qnil; | |
+#endif /* USE_W32_IME */ | |
+ | |
/* How many keys there are in the current key sequence. */ | |
int t; | |
@@ -8966,6 +8977,12 @@ | |
keybuf[0..mock_input] holds the sequence we should reread. */ | |
replay_sequence: | |
+#ifdef USE_W32_IME | |
+/* If key sequences are to replay, IME_loop_flag should not be set. | |
+ Because event has never been occured. */ | |
+ IME_command_loop_flag = Qnil; | |
+#endif /* USE_W32_IME */ | |
+ | |
starting_buffer = current_buffer; | |
first_unbound = bufsize + 1; | |
@@ -9045,6 +9062,16 @@ | |
goto replay_sequence; | |
} | |
+#ifdef USE_W32_IME | |
+ if (!NILP (IME_command_loop_flag) && NILP (VIME_command_off_flag)) | |
+ { | |
+ VIME_command_off_flag = Fime_get_mode (); | |
+ if (!NILP (VIME_command_off_flag)) | |
+ Fime_force_off (Qnil); | |
+ } | |
+ IME_command_loop_flag = Qt; | |
+#endif /* USE_W32_IME */ | |
+ | |
if (t >= bufsize) | |
error ("Key sequence too long"); | |
@@ -9708,6 +9735,12 @@ | |
? Fcommand_remapping (read_key_sequence_cmd, Qnil, Qnil) | |
: Qnil; | |
+ /* to control IME */ | |
+#ifdef USE_W32_IME | |
+ if (!NILP (VIME_command_off_flag)) | |
+ Fime_force_on (Qnil); | |
+#endif /* USE_W32_IME */ | |
+ | |
unread_switch_frame = delayed_switch_frame; | |
unbind_to (count, Qnil); | |
--- ./src/lisp.h.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./src/lisp.h 2015-04-11 07:27:30.637122000 +0900 | |
@@ -286,6 +286,17 @@ | |
# define USE_LSB_TAG true | |
# endif | |
# endif | |
+# if defined (_MSC_VER) | |
+# define ALIGN_BITS_0 1 | |
+# define ALIGN_BITS_1 2 | |
+# define ALIGN_BITS_2 4 | |
+# define ALIGN_BITS_3 8 | |
+# define ALIGN_BITS_4 16 | |
+# define ALIGN_BITS_(x) ALIGN_BITS_ ## x | |
+# define ALIGN_BITS(x) ALIGN_BITS_(x) | |
+# define DECL_ALIGN(type, var) \ | |
+ type __declspec (align(ALIGN_BITS(GCTYPEBITS))) var | |
+# endif | |
# endif | |
#endif | |
#ifdef USE_LSB_TAG | |
@@ -3652,7 +3663,26 @@ | |
#endif | |
extern const char *pending_malloc_warning; | |
extern Lisp_Object zero_vector; | |
+#if !defined(USE_W32_CALL_LISP_THREAD) | |
extern Lisp_Object *stack_base; | |
+#else /* USE_W32_CALL_LISP_THREAD */ | |
+#ifndef TLS | |
+#ifdef _MSC_VER | |
+#define TLS __declspec( thread ) | |
+#else | |
+#ifdef __GNUC__ | |
+#define TLS __thread | |
+#else | |
+#define TLS | |
+#endif | |
+#endif | |
+#endif | |
+#ifdef __GNUC__ | |
+extern TLS Lisp_Object *stack_base; | |
+#else | |
+TLS extern Lisp_Object *stack_base; | |
+#endif | |
+#endif /* USE_W32_CALL_LISP_THREAD */ | |
extern EMACS_INT consing_since_gc; | |
extern EMACS_INT gc_relative_threshold; | |
extern EMACS_INT memory_full_cons_threshold; | |
--- ./src/lisp.mk.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./src/lisp.mk 2015-04-11 07:27:30.646122500 +0900 | |
@@ -152,6 +152,7 @@ | |
$(lispsource)/term/w32-win.elc \ | |
$(lispsource)/ls-lisp.elc \ | |
$(lispsource)/disp-table.elc \ | |
+ $(lispsource)/international/w32-ime.elc \ | |
$(lispsource)/w32-common-fns.elc \ | |
$(lispsource)/dos-w32.elc \ | |
$(lispsource)/w32-fns.elc \ | |
--- ./src/Makefile.in.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./src/Makefile.in 2015-04-11 07:27:30.650126500 +0900 | |
@@ -355,7 +355,7 @@ | |
process.o gnutls.o callproc.o \ | |
region-cache.o sound.o atimer.o \ | |
doprnt.o intervals.o textprop.o composite.o xml.o $(NOTIFY_OBJ) \ | |
- profiler.o decompress.o \ | |
+ profiler.o decompress.o cmigemo.o \ | |
$(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ | |
$(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ) | |
obj = $(base_obj) $(NS_OBJC_OBJ) | |
--- ./src/w32.c.orig 2015-04-02 16:23:06.000000000 +0900 | |
+++ ./src/w32.c 2015-04-11 07:27:30.658123200 +0900 | |
@@ -332,7 +332,7 @@ | |
GetProcessTimes_Proc get_process_times_fn = NULL; | |
-#ifdef _UNICODE | |
+#if defined(_UNICODE) || defined(UNICODE) | |
const char * const LookupAccountSid_Name = "LookupAccountSidW"; | |
#else | |
const char * const LookupAccountSid_Name = "LookupAccountSidA"; | |
@@ -2030,7 +2030,7 @@ | |
Otherwise, the default group name was already set to | |
"None" in globals_of_w32. */ | |
if (lookup_account_sid (NULL, group_token.PrimaryGroup, | |
- gname, &glength, NULL, &dlength, | |
+ gname, &glength, domain, &dlength, | |
&user_type)) | |
strcpy (dflt_group_name, gname); | |
} | |
@@ -2530,6 +2530,7 @@ | |
for (i = 0; i < imax ; i++) | |
{ | |
const char *tmp = tempdirs[i]; | |
+ struct stat b; | |
if (*tmp == '$') | |
tmp = getenv (tmp + 1); | |
@@ -2809,6 +2810,8 @@ | |
filename_from_ansi (astartup_dir, startup_dir); | |
} | |
+ dostounix_filename (startup_dir); | |
+ | |
{ | |
static char modname[MAX_PATH]; | |
@@ -3216,7 +3219,7 @@ | |
while (name < path) | |
*str++ = *name++; /* skip past UNC header */ | |
- while ((c = *name++)) | |
+ for (; c = *name; name = _mbsinc(name)) | |
{ | |
switch ( c ) | |
{ | |
@@ -3235,9 +3238,9 @@ | |
but leave . and .. as they are. This allows .emacs | |
to be read as _emacs, for example. */ | |
- if (! *name || | |
- *name == '.' || | |
- IS_DIRECTORY_SEP (*name)) | |
+ if (! name[1] || | |
+ name[1] == '.' || | |
+ IS_DIRECTORY_SEP (name[1])) | |
{ | |
*str++ = '.'; | |
dots--; | |
@@ -3263,11 +3266,20 @@ | |
break; | |
case '~': | |
case '#': /* don't lose these, they're important */ | |
- if ( ! left ) | |
- str[-1] = c; /* replace last character of part */ | |
+ if ( ! left ) { | |
+ char *p = _mbsdec(shortname, str); | |
+ left += str - p; | |
+ *p++ = c; /* replace last character of part */ | |
+ str = p; | |
+ } | |
/* FALLTHRU */ | |
default: | |
- if ( left && 'A' <= c && c <= 'Z' ) | |
+ if (IsDBCSLeadByte(c) && left > 1) { | |
+ *str++ = c; | |
+ *str++ = name[1]; | |
+ left -= 2; | |
+ dots = 0; /* started a path component */ | |
+ } else if ( left && 'A' <= c && c <= 'Z' ) | |
{ | |
*str++ = tolower (c); /* map to lower case (looks nicer) */ | |
left--; | |
@@ -3293,13 +3305,19 @@ | |
static int | |
is_exec (const char * name) | |
{ | |
+ char * ext = getenv("PATHEXT"); | |
char * p = strrchr (name, '.'); | |
+ size_t l; | |
+ | |
+ ext = ext | |
+ ? (char *) _mbslwr(strcpy(alloca(strlen(ext) + 1), ext)) | |
+ : ".exe;.com;.bat;.cmd"; | |
+ | |
return | |
(p != NULL | |
- && (xstrcasecmp (p, ".exe") == 0 || | |
- xstrcasecmp (p, ".com") == 0 || | |
- xstrcasecmp (p, ".bat") == 0 || | |
- xstrcasecmp (p, ".cmd") == 0)); | |
+ && (p = _mbslwr(strcpy(alloca((l = strlen(p)) + 1), p))) != NULL | |
+ && (p = strstr(ext, p)) != NULL | |
+ && (p[l] == ';' || p[l] == 0)); | |
} | |
/* Emulate the Unix directory procedures opendir, closedir, and | |
@@ -6853,7 +6871,7 @@ | |
dlength = sizeof (domain); | |
result = | |
lookup_account_sid (NULL, group_token.PrimaryGroup, | |
- gname, &glength, NULL, &dlength, | |
+ gname, &glength, domain, &dlength, | |
&user_type); | |
if (result) | |
w32_add_to_cache (group_token.PrimaryGroup, | |
@@ -7290,7 +7308,11 @@ | |
static int socket_to_fd (SOCKET s); | |
+#ifdef __MINGW64__ | |
+SOCKET | |
+#else | |
int | |
+#endif | |
sys_socket (int af, int type, int protocol) | |
{ | |
SOCKET s; | |
@@ -8081,7 +8103,7 @@ | |
{ | |
int nchars; | |
int to_read; | |
- DWORD waiting; | |
+ unsigned long waiting; | |
char * orig_buffer = buffer; | |
if (fd < 0) | |
@@ -8155,8 +8177,10 @@ | |
if (fd_info[fd].flags & FILE_PIPE) | |
{ | |
- PeekNamedPipe ((HANDLE) _get_osfhandle (fd), NULL, 0, NULL, &waiting, NULL); | |
- to_read = min (waiting, (DWORD) count); | |
+ DWORD w; | |
+ PeekNamedPipe ((HANDLE) _get_osfhandle (fd), NULL, 0, NULL, &w, NULL); | |
+ waiting = w; /* avoid cast, because cast to DWORD is danger */ | |
+ to_read = min (waiting, count); | |
if (to_read > 0) | |
nchars += _read (fd, buffer, to_read); | |
@@ -8823,14 +8847,14 @@ | |
int needed; | |
sprintf (buffer, | |
- "The Emacs Windows initialization file \"%s.el\" " | |
+ TEXT ("The Emacs Windows initialization file \"%s.el\" " | |
"could not be found in your Emacs installation. " | |
"Emacs checked the following directories for this file:\n" | |
"\n%s\n\n" | |
"When Emacs cannot find this file, it usually means that it " | |
"was not installed properly, or its distribution file was " | |
"not unpacked properly.\nSee the README.W32 file |