.emacs-my
changeset 835 bfc9412ed633
parent 834 07219d4d737e
parent 732 139665dd6ada
child 838 2edffa38b012
child 839 27fac2557f13
equal deleted inserted replaced
834:07219d4d737e 835:bfc9412ed633
   298         (decode-coding-string
   298         (decode-coding-string
   299          (buffer-substring (match-end 0) (point-max))
   299          (buffer-substring (match-end 0) (point-max))
   300          'utf-16-le)
   300          'utf-16-le)
   301         0 -1)                           ; -1 for stripping final \0.
   301         0 -1)                           ; -1 for stripping final \0.
   302        ))))
   302        ))))
       
   303 
       
   304 (defun my-dos2cygwin-path (path)
       
   305   "Convert DOS path to Cygwin according to current mount table."
       
   306   (interactive (list (read-directory-name "Enter DOS path: ")))
       
   307   (setq path (replace-regexp-in-string "\\\\" "/" (expand-file-name path)))
       
   308   (let ( (table cygwin-mount-table--internal) item prefix )
       
   309     (while table
       
   310       (setq item (car table))
       
   311       (setq prefix (concat "\\`" (regexp-quote (car item))))
       
   312       (setq table (cdr table))
       
   313       (when (string-match prefix path)
       
   314         (setq path (replace-regexp-in-string prefix (cdr item) path))
       
   315         (setq table nil)
       
   316         ) )
       
   317     path
       
   318     ))
   303 
   319 
   304 (when (eq system-type 'windows-nt)
   320 (when (eq system-type 'windows-nt)
   305   (ignore-errors
   321   (ignore-errors
   306     (require 'cygwin-mount)
   322     (require 'cygwin-mount)
   307     (cygwin-mount-activate)
   323     (cygwin-mount-activate)
  1919 (add-hook 'c-mode-common-hook 'my-c-mode-style-hook)
  1935 (add-hook 'c-mode-common-hook 'my-c-mode-style-hook)
  1920 
  1936 
  1921 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1937 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1922 (message "python")
  1938 (message "python")
  1923 
  1939 
       
  1940 (setq python-indent 4)
       
  1941 
       
  1942 (defun my-python-add-to-path (path)
       
  1943   (interactive (list (read-directory-name "Enter new path for PYTHONPATH: ")))
       
  1944   (when (featurep 'cygwin-mount)
       
  1945     (setq path (my-dos2cygwin-path path))
       
  1946     )
       
  1947   (python-send-string (format "import sys; sys.path.append(\"%s\")" path))
       
  1948   )
       
  1949 
       
  1950 (defun my-python-django-fix (path)
       
  1951   "XXX not work on Cygwin + naive Emacs."
       
  1952   (interactive (list (read-directory-name "Enter new path for PYTHONPATH: ")))
       
  1953   (when (featurep 'cygwin-mount)
       
  1954     (setq path (my-dos2cygwin-path path))
       
  1955     )
       
  1956   (let ((file (concat path "manage.py")))
       
  1957     (if (file-exists-p file)
       
  1958         (python-send-string (format "import os; os.chdir(\"%s\"); execfile(\"%s\")" path file))
       
  1959       (error (format "file '%s' does not exist" file))
       
  1960       )))
       
  1961 
       
  1962 (when (>= emacs-major-version 22)
       
  1963   (add-hook 'python-mode-hook 'turn-on-eldoc-mode)
       
  1964   )
       
  1965 
  1924 (when (equal window-system 'w32)
  1966 (when (equal window-system 'w32)
  1925   (add-to-list 'process-coding-system-alist '("python" cp1251-unix . cp1251-unix))
  1967   (add-to-list 'process-coding-system-alist '("python" cp1251-unix . cp1251-unix))
  1926   )
  1968   )
  1927 
  1969 
  1928 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1970 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;