;;; lisp file for xyzzy ver0.2.2.233 or ver0.2.2.234
;;; .xyzzy // crayonzen [2026-04-15]17:13:49(+0900)

;; Copyright (c) 2026 crayonzen

;; global-set-keỹt@Ci.xyzzyjŋLqĎgꍇ̓pX̐ݒĂiǉύXt@C+ȈՐ.txtj
;; lisptH_xxx.lt@C̓oCgRpCȂglobal-set-key@\Ȃ

;; ʐݒ聄fBNg@~/xyzzy/edict  uxyzzydicw肳ꂽpX܂vH
;; /xyzzy/edict  C:/xyzzy/edict ƖăpXw肵Ă

;; ʏ (add-hook '*tbN̕ϐ*
;; (in-package "editor")pbP[W𖾎Ďw̏ꍇ
;; (add-hook 'editor::*tbN̕ϐ*

;; [h load load-library autoload require ;;xxx.l (provide "xxx")Ȃ灄(require "xxx")

;; ~jobt@R}hs M-x (Alt + x)BTabL[œ͕⊮Xg  SpaceL[œ͕⊮BCtrl + g IB

;; cmd.exe R}hgFM-x shell > shell > Enterkey

;; ҏW\͈͂[WɌF narrow-to-regionii[COjC-x n
;; i[CO̎ widenF narrow-to-region(C-x n)iCfBOjC-x w

;;;;;;;;;;;;;;;;[Wi}[NʒuLbgj`̃Rs[ƍ폜 rectangl.l
(defun region-copy-rectangle (p1 p2)
  (interactive "r")
  (copy-rectangle p1 p2)
  (message "Copy-Rectangle >>paste Shift + F9"))

(defun region-kill-rectangle  (p1 p2)
  (interactive "r")
  (kill-rectangle p1 p2)
  (message "Kill-Rectangle >>paste Shift + F9"))

(defun region-clear-rectangle  (p1 p2)
  (interactive "r")
  (clear-rectangle p1 p2)
  (message "Clear-Rectangle >>paste Shift + F9"))

(global-set-key #\C-F9 'region-copy-rectangle) ;Rs[
(global-set-key #\M-F9 'region-kill-rectangle) ;Rs[ā@폜
(global-set-key #\S-C-F9 'region-clear-rectangle) ;Rs[ā@#\SPC ŏ㏑

;;[2026-03-09]10:23:07(+0900)

;;
;;open-rectangle ;\SPC }
;;delete-rectangle ;폜
;;string-rectangle ;폜ā@es STRING }

;;`̃y[XgiShift + F9jF6`F10IiF6LZ@F7ǉ[s]@F8㏑@F9@F10[Wœ[]j
;;#\S-F9 'yank-rectangle-selection

;;`̃y[XgiShift + F9j̓ZNg̋`˂
;;ZNg`̃y[Xg Shift + Ctrl + Insert iiShift + F9jF9 Ɠj

;;;;;;;;;;;;;;;;~jobt@猟@fBNgij@`ς݃L[
;;(global-set-key '(#\M-g #\d) 'grep-files)
;;(global-set-key '(#\M-g #\s) 'grep-files-subdir)

;;;;;;;;;;;;;;;;~jobt@猟Eu@؍EEp
;;@[esc-map #\s]=[#\M-s]
(global-set-key #\M-s 'search-forward)
;; K\
;;(global-set-key #\C-M-s 're-search-forward)

;;u@`ς݃L[
;;(global-set-key #\M-r 'replace-string)
;;u mFȂ@`ς݃L[
;;(global-set-key #\C-M-r 'query-replace)

;;grep@݂̃obt@
(global-set-key '(#\M-g #\b) 'fgrep-buffer-search)
;;grep@݂̃obt@@K\
;;(global-set-key #\C-M-g 'grep-buffer-search)

;;grep@SẴobt@
(global-set-key '(#\M-g #\g) 'fgrep)
;;ugrep@SẴobt@
(global-set-key '(#\M-g #\r) 'gresreg)
;;ugrep@SẴobt@@mFȂ
(global-set-key '(#\M-g #\q) 'query-gresreg)

;;;;;;;;;;;;;;;;R[hw肵ăt@CJBL[ Ctrl+C M (#\C-c #\m)
;;(load-library "mend-encoding");mend-encoding.l@@lisptH_Ɉړ

;;;;;;;;;;;;;;;;;;;;;;Nbv{[hGR[fBÕftHg UTF-16 ɕύX
(setq *clipboard-char-encoding* *encoding-utf16*)

#|
"Unicode"
(defvar *encoding-utf16*
  (make-utf16-encoding "utf16" "Unicode (UTF-16)"
		       :signature t :windows t :cjk :jp))
(defvar *encoding-utf16le-bom*
  (make-utf16-encoding "utf16le-bom" "Unicode (UTF-16LE-BOM)"
		       :signature t :windows t :byte-order :little-endian :cjk :jp))
(defvar *encoding-utf16le*
  (make-utf16-encoding "utf16le" "Unicode (UTF-16LE)"
		       :signature nil :windows t :byte-order :little-endian :cjk :jp))
|#

;;;;;;;;;;;;;;;;;;;;;;ftHgR[hύX
;; VKt@CȂǃftHg̕R[hANSI(Shift_JIS)AUTF-8wb_Ȃ(BOMȂ)ɂiwindwos10̃Ɠj
;; files.l (defun new-file ()(setq *default-fileio-encoding* *encoding-utf8n*)w

;; ݂̃̕R[hϊΉXg
;; *encoding-sjis* ;ANSI --(Shift_JIS)
;; *encoding-utf16le-bom* ;UTF-16LE@--(BOMt)
;; *encoding-utf16be-bom* ;UTF-16BE@--(BOMt)
;; *encoding-utf8n* ;UTF-8@--(BOMȂ)
;; *encoding-utf8* ;UTF-8(BOMt)@--L

;; 2019NȑÕ̕R[hϊΉXg
;; *encoding-sjis* ;ANSI --(Shift_JIS)
;; *encoding-utf16le-bom* ;Unicode@--(BOMt)
;; *encoding-utf16be-bom* ;Unicode big endian@--(BOMt)
;; *encoding-utf8* ;UTF-8@--(BOMt)

;; R[hϊ (set-buffer-fileio-encoding (code &optional buffer))
;; ݂̕R[hԂ (buffer-fileio-encoding (&optional buffer))

;; R[hQƃt@C@encoding.l

;;;;;;;;;;;;;;;;;;;;;;gqɂ镶R[h̕ύX
#|
(add-hook '*find-file-hooks* 'user-file-encoding)
(defun user-file-encoding()
  (setq file-ex (pathname-type (get-buffer-file-name)))
  (if (equalp "bat" file-ex)
      (revert-buffer *encoding-sjis*)) ;ANSI
  (if (equalp "txt" file-ex)
      (revert-buffer *encoding-utf8n*)) ;BOMȂ
  (if (equalp "srt" file-ex)
      (revert-buffer *encoding-utf8*)) ;BOMt
  )
|#

;;;;;;;;;;;;;;;;gqɂă[hύX
;;(setq *auto-mode-alist*
;;      (append '(("\\.txt$" . essay-mode)
;;		("\\.srt$" . essay-mode))
;;	      *auto-mode-alist*))

(setq *auto-mode-alist*
      (append '(("\\.xyzzy$" . lisp-mode)
		("\\.bat$" . essay-mode)
		("\\.srt$" . essay-mode)
		("\\.ssa$" . essay-mode)
		("\\.ini$" . essay-mode)
		("\\.log$" . essay-mode))
	      *auto-mode-alist*))

;;;;;;;;;;;;;;;;;;;;;;ftHg̉sR[hύX@windows(dos) = CR+LF = *eol-crlf* = 1
;; (setq *default-eol-code* *eol-crlf*)

;; sR[h̒萔
;; (defconstant *eol-lf* 0) ;unix
;; (defconstant *eol-crlf* 1) ;dos
;; (defconstant *eol-cr* 2) ;mac
;; (defconstant *eol-guess* 3) ;fauto

;; sR[hϊ (set-buffer-eol-code (code &optional buffer))
;; ݂̉sR[hԂ (buffer-eol-code (&optional buffer))

;;;;;;;;;;;;;;;;;;;;;;⊮|bvAbvꗗ\
;;(setq *popup-completion-list-default* :always)

;;;;;;;;;;;;;;;html쐬BfXNgbvɍ쐬
;(load-library "make-html") ;with menu insert
;(load-library "make-html-lisp") ;with menu insert

;;;;;;;;;;;;;;;;[[ den8 dM
;(require "den8view")
;(setq *den8-directory* "d:/Den8_32.1.5.3_Opt")
;(setq *den8-folder-list* '("IN" "OUT" "Out_Finished" "TRASH"))

;;;;;;;;;;;;;;;;uEŨN
;(load-library "ddwin-search") ;with menu insert
;(load-library "Jamming-search") ;with menu insert

;;;;;;;;;;;;;;;; scan-buffer-en-word (M-x: scan-en-word)(M-x: scan-en-word-back)
;;pp̒P̂݌ [2015-01-14]17:29:44(+0900)
#|
(defun scan-en-word ()
  (interactive "*")
  (stop-selection)
  (if (scan-buffer "\\< *[^0-9]" :regexp t :no-dup t)
      ;;\\([A-Za-z0-9]\\)
      (selection-forward-word))
  )
(global-set-key #\F12 'scan-en-word)

(defun scan-en-word-back ()
  (interactive "*")
  (stop-selection)
  (if (scan-buffer "[^0-9] *\\>" :regexp t :no-dup t :reverse t :tail t)
      (selection-backward-word))
  )
(global-set-key #\S-F12 'scan-en-word-back)
|#

;;;;;;;;;;;;;;;;\[g
#|
(defun sort-region ()
  (interactive)
  (filter-region 'sort (mark) (point)))

(defun sort-selection ()
  (interactive)
  (filter-region 'sort (selection-mark) (selection-point)))

(global-set-key '(#\F8) 'sort-selection)
|#



;;;;;;;;;;;;;;;; eXg ;;;;;;;;;;;;;;;;

;;kill-buffer̕Ԃl@ύXȂFt@ύX_CAOFu͂vt@uvnil

#|
;;;;;;;;;;;;;;;;WikiBGrep_CAOFfBNgQƂw@tH_D&Dxyzzy.exe or xyzzycli.exe
(add-hook 'ed::*process-command-line-hook*
	  #'(lambda (arg) (interactive)
	      (when (file-directory-p arg)
		(require "grepd")
		(let ((ed::*grep-directory-name-hook*
		       #'(lambda () arg)))
		  (declare (special ed::*grep-directory-name-hook*))
		  (setq arg (map-backslash-to-slash arg))
		  (add-history arg 'ed::*grep-directory-history*)
		  (ed::grep-dialog)))))
|#

#|
;;;;;;;;;;;;;;;;ŊJ DeleteL[̎̓Lbgʒu͂ŃY邪IԂƂĎc
(defun open-file-notepad ()
  (interactive)
  (call-process (concat "C:\\Windows\\system32\\notepad.exe " (get-buffer-file-name))))
(global-set-key '(#\F8) 'open-file-notepad)
|#

#|
;;;;;;;;;;;;;;;;Notepad++ŊJ DeleteL[̎悤ɃCT[V|Cg̈ʒuBBB
(defun open-file-notepad-plus ()
  (interactive)
  (call-process (concat "C:\\[Program]\\npp-7.5.1.1-js-171025-2200-bin\\notepad++.exe " (get-buffer-file-name))))
(global-set-key '(#\F8) 'open-file-notepad-plus)
|#

#|
;;;;;;;;;;;;;;;;VSCodeŊJ@concatŌqĂ̂ŔpXy[XĂ
(defun open-file-vscode ()
  (interactive)
  (call-process (concat "C:\\VSCode-win32-x64-1.64.0\\Code.exe /Edit " (get-buffer-file-name))))
(global-set-key '(#\F8) 'open-file-vscode)
|#

#|
;;;;;;;;;;;;;;;;j[ACe̋Lq
;;  (:item nil "ā`S͈(&J)" 'indent-region-all)
;;   get-menu-position œȂ̂Łu:tag-commandvt
;;  (:item :tag-command "ā`S͈(&J)" 'indent-region-all)

(defun get-menu-p ()
  (interactive)
  (setq q (multiple-value-setq (ip menu)
	    (get-menu-position *app-menu* 'ed::help)))
  (setq helpm (get-menu-position *app-menu* 'ed::help))

  (setq test (get-menu-position *lisp-tool-menus* 'ed::comment-out-region-selection))
  ;;  (setq test (get-menu-position *app-menu* 'ed::LispTools))

  (message "test: q~S ip~S help~S test~S" q ip helpm test)
  )
(global-set-key #\F8 'get-menu-p)
|#

#|
;;R[hsR[hw肵ĊJH(message "Old buffer")Âobt@̃bZ[WBJȂ
(when (setq file (get-buffer-file-name))
  ;;(setq *file-dialog-filter-index* index)
  (let ((*expected-fileio-encoding* encoding)
	(*expected-eol-code* eol-code))
    (declare (special *expected-fileio-encoding* *expected-eol-code*))
    (find-file file))
  )
|#

;;;;;;;;;;;;;;;; test (M-x: test)
;(global-set-key #\F8 'test)

#|
;;Jgí݂jobt@̃vZXsR[hAR[hAsR[h
(defun test ()
  (interactive "*")
  ;;(setq buffer (selected-buffer))
  ;;(set-buffer buffer)
  (setq proc-eol-code (let (process-eol-code (buffer-process (selected-buffer)))))
  (setq encoding (buffer-fileio-encoding (selected-buffer)))
  (setq eol-code (buffer-eol-code (selected-buffer)))
  ;;(setq en *expected-fileio-encoding*)
  ;;(setq eol *expected-eol-code*)
  (message "test: encod:~S eol:~S peol:~S" encoding eol-code proc-eol-code)
  )
|#

#|
;;obt@̖OApX܂߂OApX̂݁ĩ݂fBNgj
(defun test ()
  (interactive "*")
  (setq name (buffer-name (selected-buffer)))
  (setq pathname (get-buffer-file-name))
  (setq path (directory-namestring pathname))

  (file-name-dialog :title "Foo"
		    :default pathname
		    :filter '(("ׂẴt@C(*.*)" . "*.*")
			      ("eLXg(*.txt)" . "*.txt"))
		    :initial-directory path
		    :char-encoding (or *expected-fileio-encoding* t)
		    :eol-code *expected-eol-code*
		    )
  (message "test: n:~S p:~S pn:~S" name path pathname)
  )
|#

;;(si:system-root);;xyzzy.exêfBNgł̃pX𓾂
;;(setq a (merge-pathnames "xyzzy.exe" (si:system-root)))
;;=>"C:/Applications/xyzzy/xyzzy.exe"
;;(buffer-name (selected-buffer))

#|
;;obt@xyzzỹAvƓKwɂ鎞
(if (setq pathname (merge-pathnames (buffer-name (selected-buffer)) (si:system-root)))
    (
     ;;鎞
     )
  (
   ;;
   ))
|#

#|
(defun test ()
  (interactive "*")
  (setq cmd *last-command*)
  (message "~S" cmd)
  )
|#

#|
(defun test ()
  (interactive "*")
  (setq q *support-mouse-wheel*)
  (message "~S" q)
  )
|#

#|
(defun test ()
  (interactive "*")
  (setq ip (get-menu-position *app-menu* 'ed::open-file-dialog))
  (msgbox "test: ~S" ip)
  )
|#

#|
(defun test ()
  (interactive "*")
  (setq n (point))
  (scroll-window 1)
  (message "~S" *last-mouse-line*)
  )

;(global-set-key #\F8 'test)

|#

;;;;;;;;;;;;;;;; bZ[We ;;;;;;;;;;;;;;;;
;(message "test: ~S" q)
;(msgbox "̃obt@ ~A ~AłB" xfile xpoint);ok
;(when (no-or-yes-p "uϰ˽ؕϐv폜܂H")
;(msgbox "ESpXT EcSSs܂ŕ\̌̓XN[s")
;(no-or-yes-p "")
;(yes-or-no-p "")
;(message-box MESSAGE &optional TITLE STYLES &key :button1 :button2 :button3 :button4 :button5)

;;;;;;;;;;;;;;;; L[\gp\
;;;#\a#\C-b̂悤ɕ\B
;;;A"'(),;`\| 9͓ʂŁA}邽߂'\'OuB

;;;;;;;;;;;;;;;; t@CɎgȂL
;;;  \/:,;*?"<>|
;;;  \/:*?"<>|

;;@GXP[vV[PX \n \t
;;vOł̎w@#\LFD #\TAB
