.emacs-my
changeset 732 139665dd6ada
parent 731 5b6105640c0e
child 835 bfc9412ed633
equal deleted inserted replaced
731:5b6105640c0e 732:139665dd6ada
   286         0 -1)                           ; -1 for stripping final \0.
   286         0 -1)                           ; -1 for stripping final \0.
   287        ))))
   287        ))))
   288 
   288 
   289 (defun my-dos2cygwin-path (path)
   289 (defun my-dos2cygwin-path (path)
   290   "Convert DOS path to Cygwin according to current mount table."
   290   "Convert DOS path to Cygwin according to current mount table."
   291   (interactive (list (read-directory-name "Enter new path for PYTHONPATH: ")))
   291   (interactive (list (read-directory-name "Enter DOS path: ")))
   292   (setq path (replace-regexp-in-string "\\\\" "/" (expand-file-name path)))
   292   (setq path (replace-regexp-in-string "\\\\" "/" (expand-file-name path)))
   293   (let ( (table cygwin-mount-table--internal) item prefix )
   293   (let ( (table cygwin-mount-table--internal) item prefix )
   294     (while table
   294     (while table
   295       (setq item (car table))
   295       (setq item (car table))
   296       (setq prefix (concat "\\`" (regexp-quote (car item))))
   296       (setq prefix (concat "\\`" (regexp-quote (car item))))
  1627 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1627 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1628 (message "python")
  1628 (message "python")
  1629 
  1629 
  1630 (setq python-indent 4)
  1630 (setq python-indent 4)
  1631 
  1631 
       
  1632 (defun my-python-add-to-path (path)
       
  1633   (interactive (list (read-directory-name "Enter new path for PYTHONPATH: ")))
       
  1634   (when (featurep 'cygwin-mount)
       
  1635     (setq path (my-dos2cygwin-path path))
       
  1636     )
       
  1637   (python-send-string (format "import sys; sys.path.append(\"%s\")" path))
       
  1638   )
       
  1639 
       
  1640 (defun my-python-django-fix (path)
       
  1641   "XXX not work on Cygwin + naive Emacs."
       
  1642   (interactive (list (read-directory-name "Enter new path for PYTHONPATH: ")))
       
  1643   (when (featurep 'cygwin-mount)
       
  1644     (setq path (my-dos2cygwin-path path))
       
  1645     )
       
  1646   (let ((file (concat path "manage.py")))
       
  1647     (if (file-exists-p file)
       
  1648         (python-send-string (format "import os; os.chdir(\"%s\"); execfile(\"%s\")" path file))
       
  1649       (error (format "file '%s' does not exist" file))
       
  1650       )))
       
  1651 
  1632 (when (>= emacs-major-version 22)
  1652 (when (>= emacs-major-version 22)
  1633   (add-hook 'python-mode-hook 'turn-on-eldoc-mode)
  1653   (add-hook 'python-mode-hook 'turn-on-eldoc-mode)
  1634   )
  1654   )
  1635 
  1655 
  1636 (when (equal window-system 'w32)
  1656 (when (equal window-system 'w32)