misc: update

master
Zhang Yueqian 2 years ago
commit 60a4393fa3
  1. 565
      elisp/cygwin-mount.el
  2. 1592
      elisp/format-all.el
  3. 40
      elisp/icons/close.xpm
  4. 34
      elisp/icons/leaf.xpm
  5. 39
      elisp/icons/open.xpm
  6. 89
      elisp/inheritenv.el
  7. 276
      elisp/language-id.el
  8. 113
      elisp/loaddefs.el
  9. 9968
      elisp/markdown-mode.el
  10. 25
      elisp/my-minor-mode.el
  11. 2225
      elisp/neotree.el
  12. 278
      elisp/setup-cygwin.el
  13. 491
      elisp/yaml-mode.el
  14. 25
      emacs.vbs
  15. 190
      init.el

@ -0,0 +1,565 @@
;;; cygwin-mount.el --- Teach EMACS about cygwin styles and mount points.
;; Copyright (C) 1997 Michael Cook <mcook@xemacs.org>.
;; 2001 Klaus Berndl <berndl@sdm.de>
;; Author: Michael Cook <mcook@xemacs.org>
;; Keywords: files, mount, cygwin
;; This file is *NOT* (yet?) part of GNU Emacs.
;;
;; 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 2, 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., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;; Additional info:
;; $Date: 2004-01-14 07:35:04 -0800 (Wed, 14 Jan 2004) $
;; Maintenance: Eric Hanchrow <offby1@blarg.net>
;; Additional code by: Stephane Rollandin <hepta@zogotounga.net>
;; Michael Mauger <mmaug@yahoo.com>
;; Keisuke Mori <ksk@ntts.com>
;; Drew Moseley (drewmoseley@mindspring.com)
;; James Ganong (jeg@bigseal.ucsc.edu)
;; Jeff Juliano <juliano@cs.unc.edu>
;; Klaus Berndl <berndl@sdm.de>
;; Nick Sieger <nsieger@bitstream.net>
;; Richard Y. Kim <ryk@dspwiz.com>
;; Karel Sprenger <karel.sprenger@compaq.com>
;;
;; When submitting patches, please try to also submit an automated
;; test that demonstrates the need for the patch -- i.e., one that
;; fails with the unpatched code, but passes with the patched code.
;; This will make is easier for the maintainer to decide if your patch
;; duplicates functionality from other patches. Patching `tests.el'
;; would be good.
;;; Availabilty
;; The latest version of cygwin-mount.el can always be found at
;; http://www.blarg.net/~offby1/cygwin-mount/
;; ----------------------------------------------------------------------
;;; Commentary
;; This package lets you use cygwin-style filenames like
;; "//D/any/path/to/file" or "/cygdrive/D/any/path/to/file" in exactly
;; the same manner as the normal Windows-style filenames like
;; "D:\any\path\to\file" or "D:/any/path/to/file". NOTE: "/cygdrive/"
;; is only an example for the cygdrive-prefix \(see
;; `cygwin-mount-cygdrive-prefix--internal'). cygwin-mount can handle
;; every cygdrive-prefix set by "mount --change-cygdrive-prefix"
;; (e.g. "/" is also a valid cygdrive-prefix). UNC paths work
;; too. Furthermore, this package lets you use all your cygwin mounts
;; in file operations. For example, you can use (e.g. find-file) for
;; a file named "/usr/bin/anyfile" if you have mounted the related
;; Windows-path to /usr/bin. Ange-ftp also works correctly.
;;; Installation:
;; Put in your .emacs or site-start.el file the following lines:
;; (require 'cygwin-mount)
;; (cygwin-mount-activate)
;;; Customization and using
;; + All customization is done in the customize-group `cygwin-mount'.
;; Do not set the user-options via `setq' but only via customize because
;; otherwise the package will not work correct!!
;; Important: Now the cygwin mountpoints are stored in the variable
;; `cygwin-mount-table--internal'. This variable must not be set by the user
;; but it is only set by customizing `cygwin-mount-table'!
;; + Activating: cygwin-mount-activate
;; + Deactivating: cygwin-mount-deactivate
;;; Compatibility
;; The cygwin-mount.el package is only tested with NTEmacs >= 20.6.1.
;; It has also been tested with the native port of XEmacs 21.1 but not
;; very intensive! The package has been tested with Cygwin 1.1.8 and
;; >= 1.3.1. It reportedly also works with at least some versions of
;; MinGW.
;; How it works:
;; basically we push some functions onto file-name-handler-alist.
;; They detect filenames expressed in cygwin style, and translate
;; those names into native Win32 style.
;;; Code:
(defconst cygwin-mount-version "1.4.8")
(defgroup cygwin-mount nil
"Proper handling of cygwin mounts and filenames."
:prefix "cygwin-"
:group 'files)
;; some constants
(defconst cygwin-mount-program "mount.exe")
(defconst cygwin-mount-uname-program "uname.exe")
(defconst cygwin-mount-buffername " *mount*")
;; internal variables. These variables are only set by calling
;; `cygwin-mount-activate' or by customizing `cygwin-mount-table'.
(defvar cygwin-mount-table--internal nil
"Do not set this variable directly but customize `cygwin-mount-table'!")
(defvar cygwin-mount-cygdrive-prefix--internal ""
"Prefix for the \"/cygdrive/X/\" style of cygwin.
A cygwin-user can change the \"/cygdrive\" to whatever he wants to access
files at MS-DOS drives. For example many people seem to like to have the
drives accessible as a directory so that c: == /c, which means the
cygdrive-prefix is \"/\" instead of \"/cygdrive\". This prefix must end
with a '/'! Do not set this variable because the value of this variable is
determined at activation-time of cygwin-mount \(see
`cygwin-mount-activate')")
;; user options
(defcustom cygwin-mount-cygwin-bin-directory nil
"*The directory where the cygwin binaries reside.
If nil then the cygwin-binary-directory must be into the PATH."
:group 'cygwin-mount
:type '(radio (const :tag "Cygwin is into PATH" :value nil)
(directory :tag "Cygwin-Binary-Dir" :value "")))
(defcustom cygwin-mount-build-mount-table-asynch nil
"*When non-nil, `cygwin-mount-table' is built at load-time.
If you change the value via customize you must deactivate and activate the
package again to take effect."
:group 'cygwin-mount
:type 'boolean)
(defcustom cygwin-mount-table t
"*Alist of custom cygwin mount points or t.
If t if all the current mount-points returned by the cygwin mount-program
should be used. If set to nil then there are no mount-points. An element of
the alist has the form \(<mounted windows-device> . <cygwin-directory>),
e.g. \(\"D:\\\\programs\\\\cygwin\\\\bin\" . \"/usr/bin/\") or
\(\"D:/programs/cygwin\" . \"/\")."
:group 'cygwin-mount
:set (function (lambda (symbol value)
(set symbol value)
(if (equal value t)
(cygwin-mount-build-table-internal)
(setq cygwin-mount-table--internal value))))
:initialize 'custom-initialize-default
:type '(radio (const :tag "Automatic"
:value t)
(repeat :tag "Custom mounts"
(cons (directory :tag "Mounted device")
(string :tag "Cygwin directory")))))
;; copied from executable.el because this library is not included in all
;; Emacsen by default.
(defvar cygwin-mount-executable-binary-suffixes
(if (memq system-type '(ms-dos windows-nt))
'(".exe" ".com" ".bat" ".cmd" ".btm" "")
'("")))
(defun cygwin-mount-executable-find (command)
"Search for COMMAND in `exec-path' and return the absolute file name.
Return nil if COMMAND is not found anywhere in `exec-path'."
(let ((list exec-path)
file)
(while list
(setq list
(if (and (setq file (expand-file-name command (car list)))
(let ((suffixes cygwin-mount-executable-binary-suffixes)
candidate)
(while suffixes
(setq candidate (concat file (car suffixes)))
(if (and (file-executable-p candidate)
(not (file-directory-p candidate)))
(setq suffixes nil)
(setq suffixes (cdr suffixes))
(setq candidate nil)))
(setq file candidate)))
nil
(setq file nil)
(cdr list))))
file))
;; functions
(defun cygwin-mount-get-full-progname (program)
"Return the full path of PROGRAM if possible or nil."
(let ((fullname
(if (and cygwin-mount-cygwin-bin-directory
(stringp cygwin-mount-cygwin-bin-directory)
(file-directory-p cygwin-mount-cygwin-bin-directory))
(concat (file-name-as-directory cygwin-mount-cygwin-bin-directory)
program)
(expand-file-name (or (cygwin-mount-executable-find program)
program)))))
(if (file-executable-p fullname)
fullname
nil)))
(defun cygwin-mount-get-cygdrive-prefix ()
"Return prefix used for the \"/cygdrive/X/\" style of cygwin.
This is done by calling \"mount --show-cygdrive-prefixes\".
The result is either \"/\" or \"/<string>/\"."
(let ((buf (get-buffer-create " *cygdrive*"))
(fullname (cygwin-mount-get-full-progname cygwin-mount-program)))
(if (null fullname)
(error "Cannot find program '%s'. Check `cygwin-mount-cygwin-bin-directory'"
cygwin-mount-program)
(with-current-buffer buf
(or
(progn
(erase-buffer)
(zerop (call-process fullname nil buf nil "--show-cygdrive-prefix")))
(progn
(erase-buffer)
(zerop (call-process fullname nil buf nil "--show-cygdrive-prefixes")))
(error "Cannot run %s" fullname))
(goto-char (point-min))
(prog1
(let ((regexp-prefix "\\(/[^ \t]*\\)[ \t]+")
cygdrive-prefix)
;; we search first for the user prefix and if there isn't any we
;; search for the system prefix.
(if (or (search-forward-regexp (concat regexp-prefix "user") nil t)
(search-forward-regexp (concat regexp-prefix "system") nil t))
(progn
(setq cygdrive-prefix (match-string 1))
(if (string= cygdrive-prefix "/")
cygdrive-prefix
(concat cygdrive-prefix "/")))
"/cygdrive/"))
(kill-buffer buf))))))
(defun trim-trailing-whitespace (str)
(string-match "^\\(.*\\S-\\)\\s-*$" str )
(replace-match "\\1" nil nil str))
(defun cygwin-mount-parse-one-line (line)
"Parse the output from one line of the Cygwin `mount' command;
return a pair containing the windows directory and the corresponding
Cygwin path."
;; can't use non-greedy regular expressions because versions of
;; Emacs older than 21.1 lack them.
(if (or (string-match "\\(.*\\) on \\(/.*\\) type .* (.*)" line)
(string-match "\\(.*\\)\\s-+\\(/.*\\)\\s-+\\(user\\|system\
\\|vfat\\)\\s-+\\(textmode\\|binmode\\)"
line))
(let ((win (match-string 1 line))
(cyg (match-string 2 line)))
(setq win (trim-trailing-whitespace win))
(setq cyg (trim-trailing-whitespace cyg))
(cons win cyg))
(error "Cannot parse output from `mount': %s" line)))
(defun cygwin-mount-parse-mount ()
"Parse buffer `cygwin-mount-buffername' and return alist of
mount-points, sorted with longest \"device\" names first. For the
format of this alist see `cygwin-mount-table'. Precondition of this
function is current buffer must be the buffer named
`cygwin-mount-buffername'."
(if (equal (current-buffer) (get-buffer cygwin-mount-buffername))
(let ((case-fold-search t)
mounts)
(goto-char (point-min))
(while (not (eobp))
(let* ((parsed (cygwin-mount-parse-one-line
(buffer-substring
(progn (beginning-of-line) (point))
(progn (end-of-line) (point)))))
(device (car parsed))
(direct (cdr parsed)))
(setq mounts (cons (cons (file-name-as-directory device)
(file-name-as-directory direct))
mounts))
(forward-line 1)))
;; now sort the alist so that the longest directories come first.
(setq mounts (sort mounts (function (lambda (pair1 pair2)
(> (length (cdr pair1))
(length (cdr pair2)))))) )
mounts)))
(defun cygwin-mount-sentinel (proc msg)
"Process sentinel for PROC with MSG."
(if (or (eq (process-status proc) 'exit)
(eq (process-status proc) 'signal))
(let ((buf (get-buffer-create cygwin-mount-buffername)))
(with-current-buffer buf
(setq cygwin-mount-table--internal (cygwin-mount-parse-mount)))
(kill-buffer buf)
(message "Build of mount table completed"))))
(defun cygwin-mount-build-table-internal ()
"Determine cygwin mount points.
This function sets `cygwin-mount-table--internal'
either synchronously or asynchronously \(see
`cygwin-mount-build-mount-table-asynch'). If asynchronously then the set is
really done by `cygwin-mount-sentinel'."
(let ((fullname (cygwin-mount-get-full-progname cygwin-mount-program)))
(if (null fullname)
(error "Cannot find program '%s'. Check `cygwin-mount-cygwin-bin-directory'"
cygwin-mount-program)
(if cygwin-mount-build-mount-table-asynch
;; asynchron building
(let ((proc (start-process "mount" cygwin-mount-buffername fullname)))
(set-process-sentinel proc 'cygwin-mount-sentinel)
;; 2013-10-21, TunaFish5 (EmacsWiki): Use `set-process-query-on-exit-flag'.
;; D. Adams: Use only if defined. Keep older code for older Emacs.
(if (fboundp 'set-process-query-on-exit-flag)
(set-process-query-on-exit-flag proc nil)
(process-kill-without-query proc)))
;; synchron building
(let ((buf (get-buffer-create cygwin-mount-buffername)))
(with-current-buffer buf
(erase-buffer)
(call-process fullname nil buf)
(prog1
(setq cygwin-mount-table--internal (cygwin-mount-parse-mount))
(kill-buffer buf))))))))
(defun cygwin-mount-name-hook-function (operation &rest args)
"Run OPERATION with ARGS."
(let ((fn (get operation 'cygwin-mount-name)))
(if fn (apply fn operation args)
(cygwin-mount-run-real-handler operation args))))
(defun cygwin-mount-map-drive-hook-function (operation &rest args)
"Run OPERATION with ARGS."
(let ((fn (get operation 'cygwin-mount-map-drive)))
(if fn (apply fn operation args)
(cygwin-mount-run-real-handler operation args))))
(defun cygwin-mount-run-real-handler (operation args)
"Run OPERATION with ARGS."
(let ((inhibit-file-name-handlers
(append '(cygwin-mount-name-hook-function
cygwin-mount-map-drive-hook-function)
(and (eq inhibit-file-name-operation operation)
inhibit-file-name-handlers)))
(inhibit-file-name-operation operation))
(apply operation args)))
(defun cygwin-mount-name-expand (operation name &rest args)
"Run OPERATION NAME with ARGS.
first ARG is either nil or a file name"
(when (and args (car args))
(setq args (copy-sequence args)) ; TODO: determine if this call is necessary
(setcar args (cygwin-mount-substitute-longest-mount-name (car args))))
(cygwin-mount-run-real-handler
operation
(cons (cygwin-mount-substitute-longest-mount-name name) args)))
(defun cygwin-mount-substitute-longest-mount-name (name)
"Substitute NAME with mount device or return NAME."
(and name
(save-match-data
(if (or (string-match "^//.+" name) (string-match "/\\[.+\\]" name))
;; Added by Klaus: if name beginns with "//" then it can never contain
;; a cygwin mount point! Therefore we must not check for contained
;; mount points because if / is mounted then this will always match
;; and we get an incorrect substitution for network devices like
;; //Host/path
name
(let ((mounts cygwin-mount-table--internal)
(len (length (file-name-as-directory name)))
match)
(while mounts
(let ((mount (file-name-as-directory (cdar mounts))))
(and (>= len (length mount))
(string= mount
(file-name-as-directory
(substring (file-name-as-directory name)
0 (length mount))))
(or (null match)
(> (length (cdar mounts)) (length (cdr match))))
(setq match (car mounts))))
(setq mounts (cdr mounts)))
(if match
(concat (file-name-as-directory (car match))
(if (>= (length (file-name-as-directory (cdr match))) len)
""
(substring name (length (file-name-as-directory (cdr match))))))
name))))))
;; Added by Klaus
(defconst cygwin-mount-cygwin-style1-regexp "^/[^:@]*$\\|^/|/[^/:]+\\(\\'\\|/\\)")
;; This appears to work with ancient versions of cygwin, on which the
;; cygwin path `//x' was shorthand for the Win32 path `x:'.
(defconst cygwin-mount-cygwin-style2-regexp "^//[A-Za-z]/")
;; will be set by `cygwin-mount-activate'.
(defvar cygwin-mount-cygwin-style3-regexp nil)
;; We cannot assume that NAME matched cygwin-mount-cygwin-style1-regexp,
;; cygwin-mount-cygwin-style2-regexp nor cygwin-mount-cygwin-style3-regexp,
;; because this function could be called with either argument to
;; `expand-file-name', but only one argument to `expand-file-name' may
;; have matched a regexp.
;; For example, `(expand-file-name ".." "/cygdrive/c/")' will trigger
;; `(cygwin-mount-convert-file-name "..")' and
;; `(cygwin-mount-convert-file-name "/cygdrive/c/")' to be called.
(defun cygwin-mount-convert-file-name ( name )
"Convert file NAME, to cygwin format.
`//x/' to `x:/' and `/cygdrive/x/' to `x:/'.
NOTE: \"/cygdrive/\" is only an example for the cygdrive-prefix \(see
`cygwin-mount-cygdrive-prefix--internal')."
(let ((cygdrive-prefix-len (length cygwin-mount-cygdrive-prefix--internal)))
(save-match-data
(cond ((string-match cygwin-mount-cygwin-style2-regexp name)
(concat (substring name 2 3) ":" (substring name 3)))
((string-match cygwin-mount-cygwin-style3-regexp name)
(concat (substring name cygdrive-prefix-len
(1+ cygdrive-prefix-len))
":" (substring name (1+ cygdrive-prefix-len) nil)))
(t name)))))
(defun cygwin-mount-map-drive (operation name &rest args)
"Run OPERATION on cygwin NAME with ARGS.
Map cygwin name to the dos-style \"[A-Za-z]:/\" and call
OPERATION with the mapped filename\(s). NAME must have the format looks like
\"^//[A-Za-z]/\" or \"/cygdrive/[A-Za-z]/\" here. Note that at least the first
element of ARGS could be a filename too \(then it must have the same syntax
like NAME!) which must be converted \(e.g. `expand-file-name' can be called
with two filenames).
NOTE: \"/cygdrive/\" is only an example for the cygdrive-prefix \(see
`cygwin-mount-cygdrive-prefix--internal')."
(cygwin-mount-run-real-handler
operation
(cons (cygwin-mount-convert-file-name name)
(if (stringp (car args))
(cons (cygwin-mount-convert-file-name (car args))
(cdr args))
args))))
;;; TODO -- see if we need to do stuff for Tramp that is similar to
;;; what we're about to do for ange-ftp. If so, perhaps we can use
;;; `advice' to clean up those forms below whose comments describe
;;; them as "real hacks".
;;; ange-ftp
(if (locate-library "ange-ftp")
(require 'ange-ftp))
;;; save the original function definition of ange-ftp-run-real-handler
(defconst cygwin-mount-original-ange-ftp-handler
(if (featurep 'ange-ftp)
(symbol-function 'ange-ftp-run-real-handler)
nil))
;;; This version of ange-ftp-run-real-handler also inhibits the
;;; cygwin file name expansion when we are doing ange-ftp expansion.
;;;
;;; This is a real hack. If the real definition of this function
;;; changes, we have to modify this function
(defun cygwin-mount-ange-ftp-run-real-handler (operation args)
"Run OPERATION with ARGS."
(let ((inhibit-file-name-handlers
(append '(ange-ftp-hook-function
ange-ftp-completion-hook-function
cygwin-mount-name-hook-function
cygwin-mount-map-drive-hook-function)
(and (eq inhibit-file-name-operation
operation)
inhibit-file-name-handlers)))
(inhibit-file-name-operation operation))
(apply operation args)))
;; Added by Klaus
(defvar cygwin-mount-activated nil)
(defun cygwin-mount-activate ()
"Activate cygwin-mount- and cygwin-style-handling."
(interactive)
(if (not (eq system-type 'windows-nt))
(message "cygwin-mount is only available for Emacs for NT!")
(unless cygwin-mount-activated
;; initialize the internal variables
(if (equal cygwin-mount-table t)
(cygwin-mount-build-table-internal)
(setq cygwin-mount-table--internal cygwin-mount-table))
(setq cygwin-mount-cygdrive-prefix--internal
(cygwin-mount-get-cygdrive-prefix))
(setq cygwin-mount-cygwin-style3-regexp
(concat "^" cygwin-mount-cygdrive-prefix--internal "[A-Za-z]/"))
;; add the cygwin-filehandlers
(or (assoc cygwin-mount-cygwin-style1-regexp file-name-handler-alist)
(setq file-name-handler-alist
(cons `(,cygwin-mount-cygwin-style1-regexp
. cygwin-mount-name-hook-function)
file-name-handler-alist)))
(or (assoc cygwin-mount-cygwin-style2-regexp file-name-handler-alist)
(setq file-name-handler-alist
(cons `(,cygwin-mount-cygwin-style2-regexp
. cygwin-mount-map-drive-hook-function)
file-name-handler-alist)))
(or (assoc cygwin-mount-cygwin-style3-regexp file-name-handler-alist)
(setq file-name-handler-alist
(cons `(,cygwin-mount-cygwin-style3-regexp
. cygwin-mount-map-drive-hook-function)
file-name-handler-alist)))
;; add cygwin-properties
(put 'substitute-in-file-name 'cygwin-mount-name
'cygwin-mount-name-expand)
(put 'expand-file-name 'cygwin-mount-name 'cygwin-mount-name-expand)
(put 'substitute-in-file-name
'cygwin-mount-map-drive 'cygwin-mount-map-drive)
(put 'expand-file-name 'cygwin-mount-map-drive
'cygwin-mount-map-drive)
;; rebind ange-ftp-run-real-handler to our version
(if (featurep 'ange-ftp)
(fset 'ange-ftp-run-real-handler 'cygwin-mount-ange-ftp-run-real-handler))
(setq cygwin-mount-activated t))))
;; Added by Klaus
(defun cygwin-mount-deactivate ()
"Deactivate cygwin-mount- and cygwin-style-handling."
(interactive)
(if (not (eq system-type 'windows-nt))
(message "cygwin-mount is only available for (X)Emacs for NT!")
(unless (not cygwin-mount-activated)
;; reset the internal variables
(setq cygwin-mount-table--internal nil)
(setq cygwin-mount-cygdrive-prefix--internal "")
;; remove the cygwin-filehandlers
(setq file-name-handler-alist
(delete (assoc cygwin-mount-cygwin-style1-regexp file-name-handler-alist)
file-name-handler-alist))
(setq file-name-handler-alist
(delete (assoc cygwin-mount-cygwin-style2-regexp file-name-handler-alist)
file-name-handler-alist))
(setq file-name-handler-alist
(delete (assoc cygwin-mount-cygwin-style3-regexp file-name-handler-alist)
file-name-handler-alist))
;; remove the cygwin properties
(put 'substitute-in-file-name 'cygwin-mount-name nil)
(put 'expand-file-name 'cygwin-mount-name nil)
(put 'substitute-in-file-name 'cygwin-mount-map-drive nil)
(put 'expand-file-name 'cygwin-mount-map-drive nil)
;; rebind ange-ftp-run-real-handler to its original definition.
(if (featurep 'ange-ftp)
(fset 'ange-ftp-run-real-handler cygwin-mount-original-ange-ftp-handler))
(setq cygwin-mount-activated nil))))
(provide 'cygwin-mount)
;;; cygwin-mount.el ends here

File diff suppressed because it is too large Load Diff

@ -0,0 +1,40 @@
/* XPM */
static char * close_xpm[] = {
"16 22 15 1",
" c None",
". c #848400",
"+ c #E7E79C",
"@ c #E7E794",
"# c #DEDE8C",
"$ c #ADAD39",
"% c #ADAD42",
"& c #B5B54A",
"* c #B5B552",
"= c #BDBD5A",
"- c #9C9C29",
"; c #A5A531",
"> c #C6C663",
", c #C6C66B",
"' c #CECE73",
" ",
" ",
" ",
" ",
" ",
" ",
" .... ",
".+@@#....... ",
".....$%%&&*=. ",
".-;;$%%&&*==. ",
".;;$%%&&*===. ",
".;$%%&&*===>. ",
".$%%&&*===>,. ",
".%%&&*===>,,. ",
".%&&*===>,,'. ",
"............. ",
" ",
" ",
" ",
" ",
" ",
" "};

@ -0,0 +1,34 @@
/* XPM */
static char * leaf_xpm[] = {
"16 22 9 1",
" c None",
". c #424242",
"+ c #949494",
"@ c #9C9C9C",
"# c #A5A5A5",
"$ c #ADADAD",
"% c #848484",
"& c #B5B5B5",
"* c #BDBDBD",
" ",
" ",
" ",
" ",
" ",
"....... ",
".++@@#.. ",
".+@@##.$. ",
".@@###.... ",
".@%%%+%$&. ",
".###$$$&&. ",
".#%+%%%&*. ",
".#$$$&&**. ",
".$%%+%%**. ",
".$$&&****. ",
".$&&*****. ",
".......... ",
" ",
" ",
" ",
" ",
" "};

@ -0,0 +1,39 @@
/* XPM */
static char * open_xpm[] = {
"16 22 14 1",
" c None",
". c #848400",
"+ c #D6D67B",
"@ c #CECE7B",
"# c #CECE73",
"$ c #C6C66B",
"% c #BDBD5A",
"& c #BDBD52",
"* c #ADAD39",
"= c #ADAD42",
"- c #B5B54A",
"; c #C6C663",
"> c #CECE6B",
", c #A5A5C6",
" ",
" ",
" ",
" ",
" ",
" ",
" .... ",
".+@@#..... ",
".@@##$$%%&. ",
".@#.......... ",
".#.*==--&%%;;. ",
".#.==--&%%;;. ",
"..==--&%%;;$. ",
"..=--&%%;;$. ",
".=--&%%;;$>. ",
"........... ",
" ",
" ",
" ",
" ",
" ",
" "};

@ -0,0 +1,89 @@
;;; inheritenv.el --- Make temp buffers inherit buffer-local environment variables -*- lexical-binding: t; -*-
;; Copyright (C) 2021 Steve Purcell
;; Author: Steve Purcell <steve@sanityinc.com>
;; URL: https://github.com/purcell/inheritenv
;; Package-Version: 20210204.354
;; Package-Commit: c2c879acf89682559b157fb069e1da008f4912ea
;; Package-Requires: ((emacs "24.4"))
;; Version: 0.1-pre
;; Keywords: unix
;; 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 of the License, 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 this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Environment variables in Emacs can be set buffer-locally, like many
;; Emacs preferences, which allows users to have different buffer-local
;; paths for executables in different projects, specified by a
;; ".dir-locals.el" file or via a "direnv" integration like
;; envrc (see https://github.com/purcell/envrc).
;; However, there's a fairly common pitfall when Emacs libraries run
;; background processes on behalf of a user: many such libraries run
;; processes in temporary buffers that do not inherit the calling
;; buffer's environment. This can result in executables not being found,
;; or the wrong versions of executables being picked up.
;; An example is the Emacs built-in command
;; `shell-command-to-string'. Whatever buffer-local `process-environment'
;; (or `exec-path') the user has set, that command will always use the
;; Emacs-wide default. This is *specified* behaviour, but not *expected*
;; or *helpful*.
;; `inheritenv' provides a couple of tools for dealing with this
;; issue:
;; 1. Library authors can wrap code that plans to execute processes in
;; temporary buffers with the `inheritenv' macro.
;; 2. End users can modify commands like `shell-command-to-string' using
;; the `inheritenv-add-advice' macro.
;;; Code:
(require 'cl-lib)
;;;###autoload
(defun inheritenv-apply (func &rest args)
"Apply FUNC such that the environment it sees will match the current value.
This is useful if FUNC creates a temp buffer, because that will
not inherit any buffer-local values of variables `exec-path' and
`process-environment'.
This function is designed for convenient use as an \"around\" advice.
ARGS is as for ORIG."
(cl-letf* (((default-value 'process-environment) process-environment)
((default-value 'exec-path) exec-path))
(apply func args)))
(defmacro inheritenv (&rest body)
"Wrap BODY so that the environment it sees will match the current value.
This is useful if BODY creates a temp buffer, because that will
not inherit any buffer-local values of variables `exec-path' and
`process-environment'."
`(inheritenv-apply (lambda () ,@body)))
(defmacro inheritenv-add-advice (func)
"Advise function FUNC with `inheritenv-apply'.
This will ensure that any buffers (including temporary buffers)
created by FUNC will inherit the caller's environment."
`(advice-add ,func :around 'inheritenv-apply))
(provide 'inheritenv)
;;; inheritenv.el ends here

@ -0,0 +1,276 @@
;;; language-id.el --- Library to work with programming language identifiers -*- lexical-binding: t -*-
;; Author: Lassi Kortela <lassi@lassi.io>
;; URL: https://github.com/lassik/emacs-language-id
;; Package-Version: 20220613.1156
;; Package-Commit: cbd5b8fffa8c09f86d8b77f8d3f5e6f4ccd82bc4
;; Version: 0.19
;; Package-Requires: ((emacs "24.3"))
;; Keywords: languages util
;; SPDX-License-Identifier: ISC
;; This file is not part of GNU Emacs.
;;; Commentary:
;; language-id is a small, focused library that helps other Emacs
;; packages identify the programming languages and markup languages
;; used in Emacs buffers. The main point is that it contains an
;; evolving table of language definitions that doesn't need to be
;; replicated in other packages.
;; Right now there is only one public function, `language-id-buffer'.
;; It looks at the major mode and other variables and returns the
;; language's GitHub Linguist identifier. We can add support for
;; other kinds of identifiers if there is demand.
;; This library does not do any statistical text matching to guess the
;; language.
;;; Code:
(require 'cl-lib)
(defvar language-id--file-name-extension nil
"Internal variable for file name extension during lookup.")
;; <https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml>
(defconst language-id--definitions
'(
;;; Definitions that need special attention to precedence order.
;; It is not uncommon for C++ mode to be used when writing Cuda.
;; In this case, the only way to correctly identify Cuda is by
;; looking at the extension.
("Cuda"
(c++-mode
(language-id--file-name-extension ".cu"))
(c++-mode
(language-id--file-name-extension ".cuh")))
;; json-mode is derived from javascript-mode.
("JSON5"
(json-mode
(language-id--file-name-extension ".json5"))
(web-mode
(web-mode-content-type "json")
(web-mode-engine "none")
(language-id--file-name-extension ".json5")))
("JSON"
json-mode
jsonian-mode
(web-mode
(web-mode-content-type "json")
(web-mode-engine "none")))
;; php-mode is derived from c-mode.
("PHP" php-mode)
;; scss-mode is derived from css-mode.
("SCSS" scss-mode)
;; solidity-mode is derived from c-mode.
("Solidity" solidity-mode)
;; svelte-mode is derived from html-mode.
("Svelte"
svelte-mode
(web-mode
(web-mode-content-type "html")
(web-mode-engine "svelte")))
;; terraform-mode is derived from hcl-mode.
("Terraform" terraform-mode)
;; TypeScript/TSX need to come before JavaScript/JSX because in
;; web-mode we can tell them apart by file name extension only.
;;
;; This implies that we inconsistently classify unsaved temp
;; buffers using TypeScript/TSX as JavaScript/JSX.
("TSX"
typescript-tsx-mode
(web-mode
(web-mode-content-type "jsx")
(web-mode-engine "none")
(language-id--file-name-extension ".tsx")))
("TypeScript"
typescript-mode
(web-mode
(web-mode-content-type "javascript")
(web-mode-engine "none")
(language-id--file-name-extension ".ts")))
;; ReScript needs to come before Reason because in reason-mode
;; we can tell them apart by file name extension only.
("ReScript"
(reason-mode
(language-id--file-name-extension ".res")))
("ReScript"
(reason-mode
(language-id--file-name-extension ".resi")))
("Reason" reason-mode)
;; vue-html-mode is derived from html-mode.
("Vue"
vue-mode
vue-html-mode
(web-mode
(web-mode-content-type "html")
(web-mode-engine "vue")))
;;; The rest of the definitions are in alphabetical order.
("Assembly" asm-mode nasm-mode)
("ATS" ats-mode)
("Awk" awk-mode)
("Bazel" bazel-mode)
("BibTeX" bibtex-mode)
("C" c-mode)
("C#" csharp-mode)
("C++" c++-mode)
("Cabal Config" haskell-cabal-mode)
("Clojure" clojurescript-mode clojurec-mode clojure-mode)
("CMake" cmake-mode)
("Common Lisp" lisp-mode)
("Crystal" crystal-mode)
("CSS"
css-mode
(web-mode
(web-mode-content-type "css")
(web-mode-engine "none")))
("Cuda" cuda-mode)
("D" d-mode)
("Dart" dart-mode)
("Dhall" dhall-mode)
("Dockerfile" dockerfile-mode)
("EJS"
(web-mode
(web-mode-content-type "html")
(web-mode-engine "ejs")))
("Elixir" elixir-mode)
("Elm" elm-mode)
("Emacs Lisp" emacs-lisp-mode)
("Erlang" erlang-mode)
("F#" fsharp-mode)
("Fish" fish-mode)
("Fortran" fortran-mode)
("Fortran Free Form" f90-mode)
("GLSL" glsl-mode)
("Go" go-mode)
("GraphQL" graphql-mode)
("Haskell" haskell-mode)
("HCL" hcl-mode)
("HTML"
html-helper-mode
mhtml-mode
html-mode
nxhtml-mode
(web-mode
(web-mode-content-type "html")
(web-mode-engine "none")))
("Java" java-mode)
("JavaScript"
(js-mode
(flow-minor-mode nil))
(js2-mode
(flow-minor-mode nil))
(js3-mode
(flow-minor-mode nil))
(web-mode
(web-mode-content-type "javascript")
(web-mode-engine "none")))
("JSON"
json-mode
(web-mode
(web-mode-content-type "json")
(web-mode-engine "none")))
("Jsonnet" jsonnet-mode)
("JSX"
js2-jsx-mode
jsx-mode
rjsx-mode
react-mode
(web-mode
(web-mode-content-type "jsx")
(web-mode-engine "none")))
("Kotlin" kotlin-mode)
("LaTeX" latex-mode)
("Less" less-css-mode)
("Literate Haskell" literate-haskell-mode)
("Lua" lua-mode)
("Markdown" gfm-mode markdown-mode)
("Nix" nix-mode)
("Objective-C" objc-mode)
("OCaml" caml-mode tuareg-mode)
("Perl" cperl-mode perl-mode)
("Protocol Buffer" protobuf-mode)
("PureScript" purescript-mode)
("Python" python-mode)
("R"
ess-r-mode
(ess-mode
(ess-dialect "R")))
("Racket" racket-mode)
("Ruby" enh-ruby-mode ruby-mode)
("Rust" rust-mode rustic-mode)
("Scala" scala-mode)
("Scheme" scheme-mode)
("Shell" sh-mode)
("SQL" sql-mode)
("Swift" swift-mode swift3-mode)
("TOML" toml-mode conf-toml-mode)
("V" v-mode)
("Verilog" verilog-mode)
("XML"
nxml-mode
xml-mode
(web-mode
(web-mode-content-type "xml")
(web-mode-engine "none")))
("YAML" yaml-mode)
("Zig" zig-mode))
"Internal table of programming language definitions.")
(defun language-id--mode-match-p (mode)
"Interal helper to match current buffer against MODE."
(let ((mode (if (listp mode) mode (list mode))))
(cl-destructuring-bind (wanted-major-mode &rest variables) mode
(and (derived-mode-p wanted-major-mode)
(cl-every
(lambda (variable)
(cl-destructuring-bind (symbol wanted-value) variable
(equal wanted-value
(if (boundp symbol) (symbol-value symbol) nil))))
variables)))))
(defun language-id-buffer ()
"Get GitHub Linguist language name for current buffer.
Return the name of the programming language or markup language
used in the current buffer. The name is a string from the GitHub
Linguist language list. The language is determined by looking at
the active `major-mode'. Some major modes support more than one
language. In that case minor modes and possibly other variables
are consulted to disambiguate the language.
In addition to the modes bundled with GNU Emacs, many third-party
modes are recognized. No statistical text matching or other
heuristics are used in detecting the language.
The language definitions live inside the language-id library and
are updated in new releases of the library.
If the language is not unambiguously recognized, the function
returns nil."
(let ((language-id--file-name-extension
(downcase (file-name-extension (or (buffer-file-name) "") t))))
(cl-some (lambda (definition)
(cl-destructuring-bind (language-id &rest modes) definition
(when (cl-some #'language-id--mode-match-p modes)
language-id)))
language-id--definitions)))
(provide 'language-id)
;;; language-id.el ends here

@ -0,0 +1,113 @@
;;; loaddefs.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads nil "markdown-mode" "markdown-mode.el" (25089 49515
;;;;;; 0 0))
;;; Generated autoloads from markdown-mode.el
(autoload 'markdown-mode "markdown-mode" "\
Major mode for editing Markdown files.
\(fn)" t nil)
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode) t)
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode) t)
(autoload 'gfm-mode "markdown-mode" "\
Major mode for editing GitHub Flavored Markdown files.
\(fn)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "markdown-mode" '("gfm-" "markdown")))
;;;***
;;;### (autoloads nil "my-minor-mode" "my-minor-mode.el" (0 0 0 0))
;;; Generated autoloads from my-minor-mode.el
(autoload 'my-keys-mode "my-minor-mode" "\
Custom minor mode mainly to make keybindings.
If called interactively, enable My-Keys mode if ARG is positive,
and disable it if ARG is zero or negative. If called from Lisp,
also enable the mode if ARG is omitted or nil, and toggle it if
ARG is `toggle'; disable the mode otherwise.
\(fn &optional ARG)" t nil)
(put 'global-my-keys-mode 'globalized-minor-mode t)
(defvar global-my-keys-mode nil "\
Non-nil if Global My-Keys mode is enabled.
See the `global-my-keys-mode' command
for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `global-my-keys-mode'.")
(custom-autoload 'global-my-keys-mode "my-minor-mode" nil)
(autoload 'global-my-keys-mode "my-minor-mode" "\
Toggle My-Keys mode in all buffers.
With prefix ARG, enable Global My-Keys mode if ARG is positive;
otherwise, disable it. If called from Lisp, enable the mode if
ARG is omitted or nil.
My-Keys mode is enabled in all buffers where
`(lambda nil (progn (my-keys-mode t) (column-number-mode t)))' would do it.
See `my-keys-mode' for more information on My-Keys mode.
\(fn &optional ARG)" t nil)
;;;***
;;;### (autoloads nil "neotree" "neotree.el" (0 0 0 0))
;;; Generated autoloads from neotree.el
(autoload 'neotree-find "neotree" "\
Quick select node which specified PATH in NeoTree.
If path is nil and no buffer file name, then use DEFAULT-PATH,
\(fn &optional PATH DEFAULT-PATH)" t nil)
(autoload 'neotree-projectile-action "neotree" "\
Integration with `Projectile'.
Usage:
(setq projectile-switch-project-action 'neotree-projectile-action).
When running `projectile-switch-project' (C-c p p), `neotree' will change root
automatically." t nil)
(autoload 'neotree-toggle "neotree" "\
Toggle show the NeoTree window." t nil)
(autoload 'neotree-show "neotree" "\
Show the NeoTree window." t nil)
(autoload 'neotree-hide "neotree" "\
Close the NeoTree window." t nil)
(autoload 'neotree-dir "neotree" "\
Show the NeoTree window, and change root to PATH.
\(fn PATH)" t nil)
(defalias 'neotree 'neotree-show "\
Show the NeoTree window.")
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "neotree" '("neo" "off-p")))
;;;***
(provide 'loaddefs)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; loaddefs.el ends here

File diff suppressed because it is too large Load Diff

@ -0,0 +1,25 @@
;;; Custom keybindings made in minor mode so they won't be override by major modes.
;;;###autoload
(define-minor-mode my-keys-mode
"Custom minor mode mainly to make keybindings."
:lighter " MK" ; show chars on modeline.
:init-value t ; set init-value to `t' to make it enabled in Fundamental mode.
:keymap (let ((map (make-sparse-keymap)))
(define-key map (kbd "M-h") 'windmove-left)
(define-key map (kbd "M-l") 'windmove-right)
(define-key map (kbd "M-j") 'windmove-down)
(define-key map (kbd "M-k") 'windmove-up)
; (define-key map (kbd "C-c C-n") 'tabbar-forward)
; (define-key map (kbd "C-c C-p") 'tabbar-backward)
map)
;; set command as alt on Mac
(when (eq system-type 'darwin)
(setq mac-command-modifier 'meta)))
;;;###autoload
(define-globalized-minor-mode global-my-keys-mode my-keys-mode
(lambda () (progn (my-keys-mode t)
(column-number-mode t))))
(provide 'my-minor-mode)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,278 @@
;;; setup-cygwin.el --- Set up Emacs for using Cygwin
;;
;; Filename: setup-cygwin.el
;; Description:
;; Author: Markus Hoenika
;; Maintainer: Drew Adams (concat "drew.adams" "@" "oracle" ".com")
;; Copyright (C) 2004-2018, Drew Adams, all rights reserved.
;; Created: Thu Jan 15 11:13:38 2004
;; Version: 0
;; Package-Requires: ((cygwin-mount "0"))
;; Last-Updated: Mon Jan 1 15:39:51 2018 (-0800)
;; By: dradams
;; Update #: 185
;; URL: https://www.emacswiki.org/emacs/download/setup-cygwin.el
;; Doc URL: https://www.emacswiki.org/emacs/NTEmacsWithCygwin
;; Keywords: os, unix, cygwin
;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x, 25.x, 26.x
;;
;; Features that might be required by this library:
;;
;; `ange-ftp', `backquote', `comint', `cygwin-mount', `ring'.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; Set up Emacs for using Cygwin. From Markus Hoenika's paper "SGML
;; for Windows NT" <hoenika_markus@compuserve.com>
;;
;; NOTE:
;;
;; When using precompiled GNU Emacs (all versions, at least 20-25)
;; with a Cygwin installation with Cygwin1.dll version 1.7.11-1, you
;; have trouble running bash in emacs. On `M-x shell` you get:
;;
;; bash: cannot set terminal process group (-1):
;; Inappropriate ioctl for device
;; bash: no job control in this shell
;;
;; This shell then is rather useless, because apart from the missing
;; job control some commands called in that shell just hang.
;;
;; People on the Cygwin mailing list have apparently suggested that
;; it is a GNU Emacs problem. This issue is still not resolved yet.
;;
;; Workarounds some people have tried:
;;
;; * Use Cygwin Emacs (package emacs-w32 uses the windows GUI, there
;; are also X11 and console packages)
;;
;; * Don't upgrade Cygwin above Cygwin1.dll, version 1.7.9.
;;
;; See also https://www.emacswiki.org/emacs/NTEmacsWithCygwin.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change Log:
;;
;; 2016/04/29 dadams
;; Better defgroup.
;; Added note to commentary about bash problem with Cygwin.
;; 2016/01/15 dadams
;; setcyg-dir-p: Return nil if arg is not a string.
;; 2015/10/31 dadams
;; buffer-file-coding-system: Use suggestions from Emacs bug #21780.
;; 2014/01/30 dadams
;; Added: setcyg-dir-p.
;; cygwin-root-directory: Look for "C:/cygwin64/" first, then "C:/cygwin/".
;; 2014/01/14 dadams
;; Added: add-to-list definition with APPEND, for Emacs 20.
;; 2013/06/02 dadams
;; Set env var CYGWIN to nodosfilewarning, to workaround ediff-buffers problem with names of temp files.
;; Set null-device to /dev/null.
;; 2013/04/27 dadams
;; Put Cygwin path stuff before the stuff from getenv.
;; 2013/03/08 dadams
;; Added: defgroup setup-cygwin, option cygwin-root-directory.
;; Use cygwin-root-directory instead of hardcoding root dir. Thx to Gabor Vida.
;; 2011/08/11 dadams
;; Made settings that are based on Cygwin install directory conditional, per input from Tom Popovich.
;; 2011/01/04 dadams
;; Added autoload cookies for commands.
;; 2009/10-15 dadams
;; Set ediff-shell to shell-file-name.
;; 2007/12/08 dadams
;; Use absolute file name for shell-file-name.
;; 2006/11/16 dadams
;; Replace add-to-list by setq, for Emacs -q prior to Emacs 21.
;; 2006/08/14 dadams
;; Append, not prepend "c:/cygwin/usr/info/" to Info-default-directory-list.
;; 2004/10/01 dadams
;; Changed Info-directory-list to Info-default-directory-list
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; 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 2, 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 this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(require 'cygwin-mount)
(when (< emacs-major-version 21)
(defun add-to-list (list-var element &optional append)
"Add to the value of LIST-VAR the element ELEMENT if it isn't there yet.
The test for presence of ELEMENT is done with `equal'.
If ELEMENT is added, it is added at the beginning of the list,
unless the optional argument APPEND is non-nil, in which case
ELEMENT is added at the end.
If you want to use `add-to-list' on a variable that is not defined
until a certain package is loaded, you should put the call to `add-to-list'
into a hook function that will be run only after loading the package.
`eval-after-load' provides one way to do this. In some cases
other hooks, such as major mode hooks, can do the job."
(if (member element (symbol-value list-var))
(symbol-value list-var)
(set list-var
(if append
(append (symbol-value list-var) (list element))
(cons element (symbol-value list-var)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgroup setup-cygwin nil
"Set up Emacs to use Cygwin."
:group 'files
:group 'processes
:link `(url-link :tag "Send Bug Report"
,(concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=\
setup-cygwin.el bug: \
&body=Describe bug here, starting with `emacs -Q'. \
Don't forget to mention your Emacs and library versions."))
:link '(url-link :tag "Download" "https://www.emacswiki.org/emacs/download/setup-cygwin.el")
:link '(url-link :tag "Description" "https://www.emacswiki.org/emacs/NTEmacsWithCygwin")
:link '(emacs-commentary-link :tag "Commentary" "setup-cygwin"))
(defun setcyg-dir-p (directory)
"Return DIRECTORY if DIRECTORY is a readable directory, nil otherwise."
(and (stringp directory) (file-directory-p directory) (file-readable-p directory) directory))
(defcustom cygwin-root-directory (or (setcyg-dir-p "C:/cygwin64/") (setcyg-dir-p "C:/cygwin/"))
"Root directory of Cygwin installation.
It should have subdirectories `bin' and `usr/info'.
Subdirectory `bin' should have file `bin/bash.exe'."
:group 'setup-cygwin :type 'directory)
(unless (setcyg-dir-p cygwin-root-directory)
(error "Cannot find Cygwin. Please customize option `cygwin-root-directory'"))
;;; Make Cygwin paths accessible
(cygwin-mount-activate)
;;; Follow Cygwin symlinks.
;;; Handles old-style (text file) symlinks and new-style (.lnk file) symlinks.
;;; (Non-Cygwin-symlink .lnk files, such as desktop shortcuts, are still loaded as such.)
(defun follow-cygwin-symlink ()
"Follow Cygwin symlinks.
Handles old-style (text file) and new-style (.lnk file) symlinks.
\(Non-Cygwin-symlink .lnk files, such as desktop shortcuts, are still
loaded as such.)"
(save-excursion
(goto-char 0)
(if (looking-at
"L\x000\x000\x000\x001\x014\x002\x000\x000\x000\x000\x000\x0C0\x000\x000\x000\x000\x000\x000\x046\x00C")
(progn
(re-search-forward
"\x000\\([-A-Za-z0-9_\\.\\\\\\$%@(){}~!#^'`][-A-Za-z0-9_\\.\\\\\\$%@(){}~!#^'`]+\\)")
(find-alternate-file (match-string 1)))
(when (looking-at "!<symlink>")
(re-search-forward "!<symlink>\\(.*\\)\0")
(find-alternate-file (match-string 1))))))
(add-hook 'find-file-hooks 'follow-cygwin-symlink)
;;; Use Unix-style line endings.
;; Per Eli Z. https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21780#40:
;;
;; $$$$$$ (setq-default buffer-file-coding-system 'undecided-unix)
(setq-default buffer-file-coding-system (coding-system-change-eol-conversion
(default-value 'buffer-file-coding-system)
'unix))
;;; Use /dev/null, not NUL.
(setq null-device "/dev/null")
;;; Without this env var setting, Cygwin causes `ediff-buffers', at least, to raise an error.
;;; Making this setting here might have no effect, as the env var is checked only by the first Cygwin process
;;; invoked during your Windows session. For best results, set this env var globally, in Windows itself.
;;; An alternative might be to use `cygpath' to change from MS Windows file names to POSIX.
(setenv "CYGWIN" "nodosfilewarning")
;;; Add Cygwin Info pages
(add-to-list 'Info-default-directory-list (expand-file-name "usr/info" cygwin-root-directory) 'APPEND)
;;; Use `bash' as the default shell in Emacs.
(add-to-list 'exec-path (expand-file-name "bin" cygwin-root-directory))
(setq shell-file-name (expand-file-name "bin/bash.exe" cygwin-root-directory)) ; Subprocesses invoked by shell.
(setenv "SHELL" shell-file-name)
;; (setenv "PATH" (concat (getenv "PATH") ";" (expand-file-name "bin" cygwin-root-directory)))
(setenv "PATH" (concat (expand-file-name "bin" cygwin-root-directory) ";" (getenv "PATH")))
(setq explicit-shell-file-name shell-file-name) ; Interactive shell
(setq ediff-shell shell-file-name) ; Ediff shell
(setq explicit-shell-args '("--login" "-i"))
;;;;; (setq shell-command-switch "-ic") ; SHOULD THIS BE "-c" or "-ic"?
(setq w32-quote-process-args ?\") ;; " @@@ IS THIS BETTER? ;@@@ WAS THIS BEFORE: (setq w32-quote-process-args t)
;; These don't seem to be needed.
;; They were recommended by http://www.khngai.com/emacs/cygwin.php
;;;;; (add-hook 'comint-output-filter-functions
;;;;; 'shell-strip-ctrl-m nil t)
;;;;; ;; Removes unsightly ^M characters that would otherwise appear in output of java applications.
;;;;; (add-hook 'comint-output-filter-functions
;;;;; 'comint-watch-for-password-prompt nil t)
;;;;; (setq explicit-shell-file-name "bash.exe")
;;;;; ;; For subprocesses invoked via the shell
;;;;; ;; (e.g., "shell -c command")
;;;;; (setq shell-file-name explicit-shell-file-name)
;;;###autoload
(defun bash ()
"Start `bash' shell."
(interactive)
(let ((binary-process-input t)
(binary-process-output nil))
(shell)))
(setq process-coding-system-alist
(cons '("bash" . (raw-text-dos . raw-text-unix)) process-coding-system-alist))
;; From: http://www.dotfiles.com/files/6/235_.emacs
;;;###autoload
(defun set-shell-bash()
"Enable on-the-fly switching between the bash shell and DOS."
(interactive)
;; (setq binary-process-input t)
(setq shell-file-name "bash")
(setq shell-command-switch "-c") ; SHOULD IT BE (setq shell-command-switch "-ic")?
(setq explicit-shell-file-name "bash")
(setenv "SHELL" explicit-shell-file-name)
;;;;;(setq explicit-sh-args '("-login" "-i")) ; Undefined?
(setq w32-quote-process-args ?\") ;; "
;;;;;(setq mswindows-quote-process-args t)) ; Undefined?
)
;;;###autoload
(defun set-shell-cmdproxy()
"Set shell to `cmdproxy'."
(interactive)
(setq shell-file-name "cmdproxy")
(setq explicit-shell-file-name "cmdproxy")
(setenv "SHELL" explicit-shell-file-name)
;;;;;(setq explicit-sh-args nil) ; Undefined?
(setq w32-quote-process-args nil))
;;;;;;;;;;;;;;;;;;;;;;;
(provide 'setup-cygwin)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; setup-cygwin.el ends here

@ -0,0 +1,491 @@
;;; yaml-mode.el --- Major mode for editing YAML files -*- lexical-binding: t -*-
;; Copyright (C) 2010-2014 Yoshiki Kurihara
;; Author: Yoshiki Kurihara <clouder@gmail.com>
;; Marshall T. Vandegrift <llasram@gmail.com>
;; Maintainer: Vasilij Schneidermann <mail@vasilij.de>
;; URL: https://github.com/yoshiki/yaml-mode
;; Package-Requires: ((emacs "24.1"))
;; Keywords: data yaml
;; Version: 0.0.15
;; This file is not part of Emacs
;; 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 of the License, 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 this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This is a major mode for editing files in the YAML data
;; serialization format. It was initially developed by Yoshiki
;; Kurihara and many features were added by Marshall Vandegrift. As
;; YAML and Python share the fact that indentation determines
;; structure, this mode provides indentation and indentation command
;; behavior very similar to that of python-mode.
;;; Installation:
;; To install, just drop this file into a directory in your
;; `load-path' and (optionally) byte-compile it. To automatically
;; handle files ending in '.yml', add something like:
;;
;; (require 'yaml-mode)
;; (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
;;
;; to your .emacs file.
;;
;; Unlike python-mode, this mode follows the Emacs convention of not
;; binding the ENTER key to `newline-and-indent'. To get this
;; behavior, add the key definition to `yaml-mode-hook':
;;
;; (add-hook 'yaml-mode-hook
;; '(lambda ()
;; (define-key yaml-mode-map "\C-m" 'newline-and-indent)))
;;; Known Bugs:
;; YAML is easy to write but complex to parse, and this mode doesn't
;; even really try. Indentation and highlighting will break on
;; abnormally complicated structures.
;;; Code:
;; User definable variables
;;;###autoload
(defgroup yaml nil
"Support for the YAML serialization format"
:group 'languages
:prefix "yaml-")
(defcustom yaml-mode-hook nil
"*Hook run by `yaml-mode'."
:type 'hook
:group 'yaml)
(defcustom yaml-indent-offset 2
"*Amount of offset per level of indentation."
:type 'integer
:safe 'natnump
:group 'yaml)
(defcustom yaml-backspace-function 'backward-delete-char-untabify
"*Function called by `yaml-electric-backspace' when deleting backwards.
It will receive one argument, the numeric prefix value."
:type 'function
:group 'yaml)
(defcustom yaml-block-literal-search-lines 100
"*Maximum number of lines to search for start of block literals."
:type 'integer
:group 'yaml)
(defcustom yaml-block-literal-electric-alist
'((?| . "") (?> . "-"))
"*Characters for which to provide electric behavior.
The association list key should be a key code and the associated value
should be a string containing additional characters to insert when
that key is pressed to begin a block literal."
:type 'alist
:group 'yaml)
(defface yaml-tab-face
'((((class color)) (:background "red" :foreground "red" :bold t))
(t (:reverse-video t)))
"Face to use for highlighting tabs in YAML files."
:group 'faces
:group 'yaml)
(defcustom yaml-imenu-generic-expression
'((nil "^\\(:?[a-zA-Z_-]+\\):" 1))
"The imenu regex to parse an outline of the yaml file."
:type 'string
:group 'yaml)
;; Constants
(defconst yaml-mode-version "0.0.15" "Version of `yaml-mode'.")
(defconst yaml-blank-line-re "^ *$"
"Regexp matching a line containing only (valid) whitespace.")
(defconst yaml-directive-re "^\\(?:--- \\)? *%\\(\\w+\\)"
"Regexp matching a line contatining a YAML directive.")
(defconst yaml-document-delimiter-re "^\\(?:---\\|[.][.][.]\\)"
"Rexexp matching a YAML document delimiter line.")
(defconst yaml-node-anchor-alias-re "[&*][a-zA-Z0-9_-]+"
"Regexp matching a YAML node anchor or alias.")
(defconst yaml-tag-re "!!?[^ \n]+"
"Rexexp matching a YAML tag.")
(defconst yaml-bare-scalar-re
"\\(?:[^-:,#!\n{\\[ ]\\|[^#!\n{\\[ ]\\S-\\)[^#\n]*?"
"Rexexp matching a YAML bare scalar.")
(defconst yaml-hash-key-re
(concat "\\(?:^\\(?:--- \\)?\\|{\\|\\(?:[-,] +\\)+\\) *"
"\\(?:" yaml-tag-re " +\\)?"
"\\(" yaml-bare-scalar-re "\\) *:"
"\\(?: +\\|$\\)")
"Regexp matching a single YAML hash key.")
(defconst yaml-scalar-context-re
(concat "\\(?:^\\(?:--- \\)?\\|{\\|\\(?: *[-,] +\\)+\\) *"
"\\(?:" yaml-bare-scalar-re " *: \\)?")
"Regexp indicating the beginning of a scalar context.")
(defconst yaml-nested-map-re
(concat "[^#\n]*: *\\(?:&.*\\|{ *\\|" yaml-tag-re " *\\)?$")
"Regexp matching a line beginning a YAML nested structure.")
(defconst yaml-block-literal-base-re " *[>|][-+0-9]* *\\(?:\n\\|\\'\\)"
"Regexp matching the substring start of a block literal.")
(defconst yaml-block-literal-re
(concat yaml-scalar-context-re
"\\(?:" yaml-tag-re "\\)?"
yaml-block-literal-base-re)
"Regexp matching a line beginning a YAML block literal.")
(defconst yaml-nested-sequence-re
(concat "^\\(?:\\(?: *- +\\)+\\|\\(:? *-$\\)\\)"
"\\(?:" yaml-bare-scalar-re " *:\\(?: +.*\\)?\\)?$")
"Regexp matching a line containing one or more nested YAML sequences.")
(defconst yaml-constant-scalars-re
(concat "\\(?:^\\|\\(?::\\|-\\|,\\|{\\|\\[\\) +\\) *"
(regexp-opt
'("~" "null" "Null" "NULL"
".nan" ".NaN" ".NAN"
".inf" ".Inf" ".INF"
"-.inf" "-.Inf" "-.INF"
"y" "Y" "yes" "Yes" "YES" "n" "N" "no" "No" "NO"
"true" "True" "TRUE" "false" "False" "FALSE"
"on" "On" "ON" "off" "Off" "OFF") t)
" *$")
"Regexp matching certain scalar constants in scalar context.")
;; Mode setup
(defvar yaml-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "|" 'yaml-electric-bar-and-angle)
(define-key map ">" 'yaml-electric-bar-and-angle)
(define-key map "-" 'yaml-electric-dash-and-dot)
(define-key map "." 'yaml-electric-dash-and-dot)
(define-key map (kbd "DEL") 'yaml-electric-backspace)
map)
"Keymap used in `yaml-mode' buffers.")
(defvar yaml-mode-syntax-table
(let ((syntax-table (make-syntax-table)))
(modify-syntax-entry ?\' "\"" syntax-table)
(modify-syntax-entry ?\" "\"" syntax-table)
(modify-syntax-entry ?# "<" syntax-table)
(modify-syntax-entry ?\n ">" syntax-table)
(modify-syntax-entry ?\\ "\\" syntax-table)
(modify-syntax-entry ?- "_" syntax-table)
(modify-syntax-entry ?_ "_" syntax-table)
(modify-syntax-entry ?& "." syntax-table)
(modify-syntax-entry ?* "." syntax-table)
(modify-syntax-entry ?\( "." syntax-table)
(modify-syntax-entry ?\) "." syntax-table)
(modify-syntax-entry ?\{ "(}" syntax-table)
(modify-syntax-entry ?\} "){" syntax-table)
(modify-syntax-entry ?\[ "(]" syntax-table)
(modify-syntax-entry ?\] ")[" syntax-table)
syntax-table)
"Syntax table in use in `yaml-mode' buffers.")
;;;###autoload
(define-derived-mode yaml-mode text-mode "YAML"
"Simple mode to edit YAML.
\\{yaml-mode-map}"
:syntax-table yaml-mode-syntax-table
(set (make-local-variable 'comment-start) "# ")
(set (make-local-variable 'comment-start-skip) "#+ *")
(set (make-local-variable 'indent-line-function) 'yaml-indent-line)
(set (make-local-variable 'indent-tabs-mode) nil)
(set (make-local-variable 'fill-paragraph-function) 'yaml-fill-paragraph)
(set (make-local-variable 'syntax-propertize-function)
'yaml-mode-syntax-propertize-function)
(setq font-lock-defaults '(yaml-font-lock-keywords)))
;; Font-lock support
(defvar yaml-font-lock-keywords
`((yaml-font-lock-block-literals 0 font-lock-string-face)
(,yaml-constant-scalars-re . (1 font-lock-constant-face))
(,yaml-tag-re . (0 font-lock-type-face))
(,yaml-node-anchor-alias-re . (0 font-lock-function-name-face))
(,yaml-hash-key-re . (1 font-lock-variable-name-face))
(,yaml-document-delimiter-re . (0 font-lock-comment-face))
(,yaml-directive-re . (1 font-lock-builtin-face))
("^[\t]+" 0 'yaml-tab-face t))
"Additional expressions to highlight in YAML mode.")
(defun yaml-mode-syntax-propertize-function (beg end)
"Override buffer's syntax table for special syntactic constructs."
;; Unhighlight foo#bar tokens between BEG and END.
(save-excursion
(goto-char beg)
(while (search-forward "#" end t)
(save-excursion
(forward-char -1)
;; both ^# and [ \t]# are comments
(when (and (not (bolp))
(not (memq (preceding-char) '(?\s ?\t))))
(put-text-property (point) (1+ (point))
'syntax-table (string-to-syntax "_"))))))
(save-excursion
(goto-char beg)
(while (and
(> end (point))
(re-search-forward "['\"]" end t))
(when (get-text-property (point) 'yaml-block-literal)
(put-text-property (1- (point)) (point)
'syntax-table (string-to-syntax "w")))
(let* ((pt (point))
(sps (save-excursion (syntax-ppss (1- pt)))))
(when (not (nth 8 sps))
(cond
((and (char-equal ?' (char-before (1- pt)))
(char-equal ?' (char-before pt)))
(put-text-property (- pt 2) pt
'syntax-table (string-to-syntax "w"))
;; Workaround for https://debbugs.gnu.org/41195.
(let ((syntax-propertize--done syntax-propertize--done))
;; Carefully invalidate the last cached ppss.
(syntax-ppss-flush-cache (- pt 2))))
;; If quote is detected as a syntactic string start but appeared
;; after a non-whitespace character, then mark it as syntactic word.
((and (char-before (1- pt))
(char-equal ?w (char-syntax (char-before (1- pt)))))
(put-text-property (1- pt) pt
'syntax-table (string-to-syntax "w")))
(t
;; We're right after a quote that opens a string literal.
;; Skip over it (big speedup for long JSON strings).
(goto-char (1- pt))
(condition-case nil
(forward-sexp)
(scan-error
(goto-char end))))))))))
(defun yaml-font-lock-block-literals (bound)
"Find lines within block literals.
Find the next line of the first (if any) block literal after point and
prior to BOUND. Returns the beginning and end of the block literal
line in the match data, as consumed by `font-lock-keywords' matcher
functions. The function begins by searching backwards to determine
whether or not the current line is within a block literal. This could
be time-consuming in large buffers, so the number of lines searched is
artificially limited to the value of
`yaml-block-literal-search-lines'."
(if (eolp) (goto-char (1+ (point))))
(unless (or (eobp) (>= (point) bound))
(let ((begin (point))
(end (min (1+ (point-at-eol)) bound)))
(goto-char (point-at-bol))
(while (and (looking-at yaml-blank-line-re)
(not (bobp)))
(forward-line -1))
(let ((nlines yaml-block-literal-search-lines)
(min-level (current-indentation)))
(forward-line -1)
(while (and (/= nlines 0)
(/= min-level 0)
(not (looking-at yaml-block-literal-re))
(not (bobp)))
(setq nlines (1- nlines))
(unless (looking-at yaml-blank-line-re)
(setq min-level (min min-level (current-indentation))))
(forward-line -1))
(when (looking-at-p " *- ")
(setq min-level (- min-level 2)))
(cond
((and (< (current-indentation) min-level)
(looking-at yaml-block-literal-re))
(goto-char end)
(put-text-property begin end 'yaml-block-literal t)
(set-match-data (list begin end))
t)
((progn
(goto-char begin)
(re-search-forward (concat yaml-block-literal-re
" *\\(.*\\)\n")
bound t))
(let ((range (nthcdr 2 (match-data))))
(put-text-property (car range) (cadr range) 'yaml-block-literal t)
(set-match-data range))
t))))))
;; Indentation and electric keys
(defun yaml-compute-indentation ()
"Calculate the maximum sensible indentation for the current line."
(save-excursion
(beginning-of-line)
(if (looking-at yaml-document-delimiter-re) 0
(forward-line -1)
(while (and (looking-at yaml-blank-line-re)
(> (point) (point-min)))
(forward-line -1))
(+ (current-indentation)
(if (looking-at yaml-nested-map-re) yaml-indent-offset 0)
(if (looking-at yaml-nested-sequence-re) yaml-indent-offset 0)
(if (looking-at yaml-block-literal-re) yaml-indent-offset 0)))))
(defun yaml-indent-line ()
"Indent the current line.
The first time this command is used, the line will be indented to the
maximum sensible indentation. Each immediately subsequent usage will
back-dent the line by `yaml-indent-offset' spaces. On reaching column
0, it will cycle back to the maximum sensible indentation."
(interactive "*")
(let ((ci (current-indentation))
(need (yaml-compute-indentation)))
(save-excursion
(beginning-of-line)
(delete-horizontal-space)
(if (and (equal last-command this-command) (/= ci 0))
(indent-to (* (/ (- ci 1) yaml-indent-offset) yaml-indent-offset))
(indent-to need)))
(if (< (current-column) (current-indentation))
(forward-to-indentation 0))))
(defun yaml-electric-backspace (arg)
"Delete characters or back-dent the current line.
If invoked following only whitespace on a line, will back-dent to the
immediately previous multiple of `yaml-indent-offset' spaces."
(interactive "*p")
(if (or (/= (current-indentation) (current-column)) (bolp))
(funcall yaml-backspace-function arg)
(let ((ci (current-column)))
(beginning-of-line)
(delete-horizontal-space)
(indent-to (* (/ (- ci (* arg yaml-indent-offset))
yaml-indent-offset)
yaml-indent-offset)))))
(defun yaml-electric-bar-and-angle (arg)
"Insert the bound key and possibly begin a block literal.
Inserts the bound key. If inserting the bound key causes the current
line to match the initial line of a block literal, then inserts the
matching string from `yaml-block-literal-electric-alist', a newline,
and indents appropriately."
(interactive "*P")
(self-insert-command (prefix-numeric-value arg))
(let ((extra-chars
(assoc last-command-event
yaml-block-literal-electric-alist)))
(cond
((and extra-chars (not arg) (eolp)
(save-excursion
(beginning-of-line)
(looking-at yaml-block-literal-re)))
(insert (cdr extra-chars))
(newline-and-indent)))))
(defun yaml-electric-dash-and-dot (arg)
"Insert the bound key and possibly de-dent line.
Inserts the bound key. If inserting the bound key causes the current
line to match a document delimiter, de-dent the line to the left
margin."
(interactive "*P")
(self-insert-command (prefix-numeric-value arg))
(save-excursion
(beginning-of-line)
(when (and (not arg) (looking-at yaml-document-delimiter-re))
(delete-horizontal-space))))
(defun yaml-narrow-to-block-literal ()
"Narrow the buffer to block literal if the point is in it,
otherwise do nothing."
(interactive)
(save-excursion
(goto-char (point-at-bol))
(while (and (looking-at-p yaml-blank-line-re) (not (bobp)))
(forward-line -1))
(let ((nlines yaml-block-literal-search-lines)
(min-level (current-indentation))
beg)
(forward-line -1)
(while (and (/= nlines 0)
(/= min-level 0)
(not (looking-at-p yaml-block-literal-re))
(not (bobp)))
(setq nlines (1- nlines))
(unless (looking-at-p yaml-blank-line-re)
(setq min-level (min min-level (current-indentation))))
(forward-line -1))
(when (and (< (current-indentation) min-level)
(looking-at-p yaml-block-literal-re))
(setq min-level (current-indentation))
(forward-line)
(setq beg (point))
(while (and (not (eobp))
(or (looking-at-p yaml-blank-line-re)
(> (current-indentation) min-level)))
(forward-line))
(narrow-to-region beg (point))))))
(defun yaml-fill-paragraph (&optional justify region)
"Fill paragraph.
Outside of comments, this behaves as `fill-paragraph' except that
filling does not cross boundaries of block literals. Inside comments,
this will do usual adaptive fill behaviors."
(interactive "*P")
(save-restriction
(yaml-narrow-to-block-literal)
(let ((fill-paragraph-function nil))
(or (fill-comment-paragraph justify)
(fill-paragraph justify region)))))
(defun yaml-set-imenu-generic-expression ()
(make-local-variable 'imenu-generic-expression)
(make-local-variable 'imenu-create-index-function)
(setq imenu-create-index-function 'imenu-default-create-index-function)
(setq imenu-generic-expression yaml-imenu-generic-expression))
(add-hook 'yaml-mode-hook 'yaml-set-imenu-generic-expression)
(defun yaml-mode-version ()
"Display version of `yaml-mode'."
(interactive)
(message "yaml-mode %s" yaml-mode-version)
yaml-mode-version)
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.\\(e?ya?\\|ra\\)ml\\'" . yaml-mode))
;;;###autoload
(add-to-list 'magic-mode-alist
'("^%YAML\\s-+[0-9]+\\.[0-9]+\\(\\s-+#\\|\\s-*$\\)" . yaml-mode))
(provide 'yaml-mode)
;;; yaml-mode.el ends here

@ -0,0 +1,25 @@
Set objShell = WScript.CreateObject("WScript.Shell")
' objShell.Run "runemacs.exe -q --load E:\WorkSpace\Emacs\init.el", 0, false
' 先获取vbs所在目录, 然后利用相对路径获取到Emacs初始文件
' 目录结构
' X:\BaiduSync\Emacs\init.el
' X:\Software\Emacs\bin\runemacs.exe
' X:\Software\Emacs\bin\emacs.vbs
' 获取当前运行脚本(emacs.vbs)的所在路径
scriptPath = WScript.ScriptFullName
' 根据脚本路径和约定的目录结构, 获取Emacs主程序及init.el文件路径
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
basePath = fso.GetParentFolderName(fso.GetParentFolderName(fso.getParentFolderName(scriptPath)))
baiduSyncPath = fso.BuildPath(basePath, "BaiduSyncdisk")
softwarePath = fso.BuildPath(basePath, "Software")
emacsPath = fso.BuildPath(softwarePath, "Emacs\bin\runemacs.exe")
initelPath = fso.BuildPath(baiduSyncPath, "Emacs\init.el")
' 启动Emacs
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run emacsPath & " -q --load " & initelPath, 0, false

@ -0,0 +1,190 @@
;;; --------------------
;; 界面定制
;; 禁用菜单栏、滚动条和工具栏
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)
;; 禁用启动首屏并设置最大化
(setq inhibit-startup-screen t)
(toggle-frame-maximized)
;; 全局高亮当前行
(global-hl-line-mode t)
;; 高亮匹配括号
(show-paren-mode t)
;; 获取当前显示器的DPI
(defun my-dpi ()
(let* ((attrs (car (display-monitor-attributes-list)))
(size (assoc 'mm-size attrs))
(sizex (cadr size))
(res (cdr (assoc 'geometry attrs)))
(resx (- (caddr res) (car res)))
dpi)
(catch 'exit
;; in terminal
(unless sizex
(throw 'exit 10))
;; on big screen
(when (> sizex 1000)
(throw 'exit 10))
;; DPI
(* (/ (float resx) sizex) 25.4))))
;; 设置中英文字体大小,使两者字体宽度相等
;; shzhzhyiwezitidaxi, shlizhzitikuduxide
(defun zos/font/seperate-font (default-size cjk-size high-dpi-cjk-size)
(let* ((z/default-size default-size)
; 判断DPI, 如果DPI<=120, 使用cjk-size(较小的值)作为cjk字体大小, 否则使用high-dpi-cjk-size(较大的值)作为cjk字体大小
(z/cjk-size (if (<= (my-dpi) 145) cjk-size high-dpi-cjk-size)))
(progn
;; 设置默认的字体大小,由于height表示 1/10pt,所以要*10
(set-face-attribute 'default nil
:family "Sarasa Mono SC"
:height (* z/default-size 10)
:weight 'normal
:width 'normal)
(set-face-attribute 'fixed-pitch nil
:family "Sarasa Mono SC")
;; 给相应的字符集设置中文字体,这里的字体是冬青黑体简体中文 W3。
(dolist (charset '(han cjk-misc chinese-gbk))
(set-fontset-font "fontset-default" charset (font-spec :name "Sarasa Mono SC" :size z/cjk-size))))))
(zos/font/seperate-font 12 16 24)
;; 设置默认编码
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
;; 设置主题
(load-theme 'wombat)
;; 包仓库
; (require 'package)
; (add-to-list 'package-archives
; '("melpa-stable" . "https://stable.melpa.org/packages/"))
; (package-initialize)
;;; --------------------
;; 功能定制
;; 修改询问函数为 y or n
(fset 'yes-or-no-p 'y-or-n-p)
;; 不要自动补全和备份文件
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq create-lockfiles nil)
;; 粘贴的文字替换选中region而不是追加到region最后
(delete-selection-mode 1)
;; 保存文件时删除尾部空行
(setq delete-traling-lines t)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; 某些模式显示行号
(defun zos/enable-linum-mode ()
(linum-mode t))
(dolist (mode '(prog-mode-hook
text-mode-hook))
(add-hook mode 'zos/enable-linum-mode))
;; 高级echo补全
(icomplete-mode t)
;; minibuffer文件名补全忽略大小写
(setq read-file-name-completion-ignore-case t)
;; dired 排序将 . 开头的文件排前面
(setq ls-lisp-UCA-like-collation nil)
;;; --------------------
;; 快捷键定制
;; 窗口操作 M-h/j/k/l 上下左右移动焦点
(dolist (key-func-bind '(("M-h" . windmove-left)
("M-l" . windmove-right)
("M-j" . windmove-down)
("M-k" . windmove-up)))
(let ((key (car key-func-bind))
(func (cdr key-func-bind)))
(global-set-key (kbd key) func)))
(global-unset-key (kbd "C-M-l"))
(global-set-key (kbd "C-M-l") 'format-all-buffer)
;;; --------------------
;; 文件关联
;; (add-to-list 'auto-mode-alist
;; ("\\.vbs\\'" . vbs-mode))
;;; --------------------
;; 扩展功能
;; 扩展目录
(let* ((z/arg-pos (seq-position command-line-args "--load"))
(z/initel-path (if (number-or-marker-p z/arg-pos) (nth (+ z/arg-pos 1) command-line-args))))
(if (char-or-string-p z/initel-path)
(progn
(message z/initel-path)
(add-to-list 'load-path (file-name-concat (file-name-directory z/initel-path) "elisp")))
))
;; Cygwin 配置
(setq cygwin-mount-cygwin-bin-directory "C:/cygwin64/bin")
(if
(and (require 'cygwin-mount nil t) (require 'setup-cygwin nil t))
(progn
(add-to-list 'exec-path (expand-file-name "/stlink-1.7.0-x86_64-w64-mingw32/bin" cygwin-root-directory))
(setenv "PATH" (concat (expand-file-name "/stlink-1.7.0-x86_64-w64-mingw32/bin" cygwin-root-directory) ";" (getenv "PATH")))
(add-to-list 'exec-path (expand-file-name "/openocd-v0.11.0-i686-w64-mingw32/bin" cygwin-root-directory))
(setenv "PATH" (concat (expand-file-name "/openocd-v0.11.0-i686-w64-mingw32/bin" cygwin-root-directory) ";" (getenv "PATH")))
(add-to-list 'exec-path (expand-file-name "/gcc-arm-11.2-2022.02-mingw-w64-i686-arm-none-eabi/bin" cygwin-root-directory))
(setenv "PATH" (concat (expand-file-name "/gcc-arm-11.2-2022.02-mingw-w64-i686-arm-none-eabi/bin" cygwin-root-directory) ";" (getenv "PATH")))))
;; 文件浏览
(require 'neotree)
;; 格式化
(require 'format-all)
(defun z/format-all-enable ()
"Enable format-all on some mode"
(progn
(format-all-ensure-formatter)
(format-all-mode)))
(add-hook 'prog-mode-hook
'z/format-all-enable)
;; Latex格式化
(defun zos/latex/format-file ()
"在保存时格式化LaTeX文件"
(interactive)
(let ((latex-indent "d:/texlive/2021/bin/win32/latexindent.exe")
(buffer-encoding buffer-file-coding-system)
(filepath (buffer-file-name)))
(call-process latex-indent nil "*scratch*" nil
"-w" "-y=defaultIndent:' '" filepath)
(let ((coding-system-for-read buffer-encoding))
(revert-buffer t t t))))
;; Markdown mode
(require 'markdown-mode)
(add-to-list 'process-coding-system-alist ; 修复prettier乱码问题
'("prettier" utf-8-auto))
(add-hook 'markdown-mode-hook
'z/format-all-enable)
;; YAML mode
(require 'yaml-mode)
Loading…
Cancel
Save