VL
(use-package smart-comment
:ensure t
:bind ("M-;" . smart-comment))
Size: a a a
VL
(use-package smart-comment
:ensure t
:bind ("M-;" . smart-comment))
DL
DL
(defun start-olymp ()
(interactive)
(letrec ((name (read-string "Olymp's name: " "Opencups/"))
(olymp-dir (concat "~/Codes/olymp/" name "/"))
(how-many (string-to-number (read-string "How many tasks: " "13")))
(suffix "-olymp.cpp")
(input "input.txt")
(output "output.txt")
(template "~/.emacs.d/template.cpp") ; template for olympiads
(start-char (string-to-char "A"))
)
(progn
;; creating olymp directory if not exists
(unless (file-exists-p olymp-dir)
(make-directory olymp-dir))
;; creating in-out files
(find-file (concat olymp-dir input))
(save-buffer (concat olymp-dir input))
(find-file (concat olymp-dir output))
(save-buffer (concat olymp-dir output))
;; creating buffers for task files
(dotimes (i how-many)
(find-file (concat olymp-dir (char-to-string (+ i start-char)) suffix))
(when (eq 1 (point-max))
(insert-file-contents template nil))
(save-buffer)
)))
)
DL
(concat olymp-dir input)
и подобное лучше в let завернутьVL
(defun start-olymp ()
(interactive)
(letrec ((name (read-string "Olymp's name: " "Opencups/"))
(olymp-dir (concat "~/Codes/olymp/" name "/"))
(how-many (string-to-number (read-string "How many tasks: " "13")))
(suffix "-olymp.cpp")
(input "input.txt")
(output "output.txt")
(template "~/.emacs.d/template.cpp") ; template for olympiads
(start-char (string-to-char "A"))
)
(progn
;; creating olymp directory if not exists
(unless (file-exists-p olymp-dir)
(make-directory olymp-dir))
;; creating in-out files
(find-file (concat olymp-dir input))
(save-buffer (concat olymp-dir input))
(find-file (concat olymp-dir output))
(save-buffer (concat olymp-dir output))
;; creating buffers for task files
(dotimes (i how-many)
(find-file (concat olymp-dir (char-to-string (+ i start-char)) suffix))
(when (eq 1 (point-max))
(insert-file-contents template nil))
(save-buffer)
)))
)
VL
(use-package smart-comment
:ensure t
:bind ("M-;" . smart-comment))
DL
expand-file-name
DL
S
VL
DL
VL
DL
(defun start-olymp ()
(interactive)
(letrec ((name (read-string "Olymp's name: " "Opencups/"))
(olymp-dir (concat "~/Codes/olymp/" name "/"))
(how-many (string-to-number (read-string "How many tasks: " "13")))
(suffix "-olymp.cpp")
(input "input.txt")
(output "output.txt")
(template "~/.emacs.d/template.cpp") ; template for olympiads
(start-char (string-to-char "A"))
)
(progn
;; creating olymp directory if not exists
(unless (file-exists-p olymp-dir)
(make-directory olymp-dir))
;; creating in-out files
(find-file (concat olymp-dir input))
(save-buffer (concat olymp-dir input))
(find-file (concat olymp-dir output))
(save-buffer (concat olymp-dir output))
;; creating buffers for task files
(dotimes (i how-many)
(find-file (concat olymp-dir (char-to-string (+ i start-char)) suffix))
(when (eq 1 (point-max))
(insert-file-contents template nil))
(save-buffer)
)))
)
VL
(defun start-olymp ()
(interactive)
(letrec ((name (read-string "Olymp's name: " "Opencups/"))
(olymp-dir (concat "~/Codes/olymp/" name "/"))
(how-many (string-to-number (read-string "How many tasks: " "13")))
(suffix "-olymp.cpp")
(input "input.txt")
(output "output.txt")
(template "~/.emacs.d/template.cpp") ; template for olympiads
(start-char (string-to-char "A"))
)
(progn
;; creating olymp directory if not exists
(unless (file-exists-p olymp-dir)
(make-directory olymp-dir))
;; creating in-out files
(find-file (concat olymp-dir input))
(save-buffer (concat olymp-dir input))
(find-file (concat olymp-dir output))
(save-buffer (concat olymp-dir output))
;; creating buffers for task files
(dotimes (i how-many)
(find-file (concat olymp-dir (char-to-string (+ i start-char)) suffix))
(when (eq 1 (point-max))
(insert-file-contents template nil))
(save-buffer)
)))
)
VL
(loop for c from ?A upto (+ ?A how-many))
DL
(make-directory DIR &optional PARENTS)
, можно просто указать parents non-nil, тогда даже проверять на существование не надоPG
(defun start-olymp ()
(interactive)
(letrec ((name (read-string "Olymp's name: " "Opencups/"))
(olymp-dir (concat "~/Codes/olymp/" name "/"))
(how-many (string-to-number (read-string "How many tasks: " "13")))
(suffix "-olymp.cpp")
(input "input.txt")
(output "output.txt")
(template "~/.emacs.d/template.cpp") ; template for olympiads
(start-char (string-to-char "A"))
)
(progn
;; creating olymp directory if not exists
(unless (file-exists-p olymp-dir)
(make-directory olymp-dir))
;; creating in-out files
(find-file (concat olymp-dir input))
(save-buffer (concat olymp-dir input))
(find-file (concat olymp-dir output))
(save-buffer (concat olymp-dir output))
;; creating buffers for task files
(dotimes (i how-many)
(find-file (concat olymp-dir (char-to-string (+ i start-char)) suffix))
(when (eq 1 (point-max))
(insert-file-contents template nil))
(save-buffer)
)))
)
(defcustom olymp-default-directory
"~/Codes/olymp/Opencups/"
"🤔"
:group 'emacs
:type 'file)
(defun start-olymp (&optional olymp-dir how-many)
(interactive
(list
(read-file-name "Olymp's name: " t olymp-default-directory nil)
(read-number "How many tasks: " 13)))
...)
DL
D
G(