cat function
This commit is contained in:
parent
b12c9de2ad
commit
b5c13c5b3d
37
config.el
37
config.el
|
@ -162,3 +162,40 @@
|
||||||
("C-TAB" . 'copilot-accept-completion-by-word)
|
("C-TAB" . 'copilot-accept-completion-by-word)
|
||||||
("C-<tab>" . 'copilot-accept-completion-by-word)))
|
("C-<tab>" . 'copilot-accept-completion-by-word)))
|
||||||
(whole-line-or-region-global-mode 1)
|
(whole-line-or-region-global-mode 1)
|
||||||
|
|
||||||
|
;; very clean me like
|
||||||
|
;; (defun concatenate-org-files (directory)
|
||||||
|
;; "Concatenate all .org files in DIRECTORY into a new buffer."
|
||||||
|
;; (interactive "DDirectory: ")
|
||||||
|
;; (let ((output-buffer (generate-new-buffer "*Concatenated Org Files*"))
|
||||||
|
;; (org-files (directory-files-recursively directory "\\.org$")))
|
||||||
|
;; (with-current-buffer output-buffer
|
||||||
|
;; (dolist (file org-files)
|
||||||
|
;; (insert-file-contents file)
|
||||||
|
;; (insert "\n\n"))
|
||||||
|
;; (org-mode)
|
||||||
|
;; (goto-char (point-min)))
|
||||||
|
;; (switch-to-buffer output-buffer)))
|
||||||
|
|
||||||
|
(defun concatenate-files-by-extension (directory extension)
|
||||||
|
"Concatenate all files with EXTENSION in DIRECTORY into a new buffer."
|
||||||
|
(interactive
|
||||||
|
(list
|
||||||
|
(read-directory-name "Directory: ")
|
||||||
|
(read-string "File extension (without dot): ")))
|
||||||
|
(let* ((file-regex (concat "\\." (regexp-quote extension) "$"))
|
||||||
|
(output-buffer-name (format "*Concatenated %s Files*" (upcase extension)))
|
||||||
|
(output-buffer (generate-new-buffer output-buffer-name))
|
||||||
|
(files (directory-files-recursively directory file-regex)))
|
||||||
|
(if (null files)
|
||||||
|
(message "No %s files found in the specified directory." extension)
|
||||||
|
(with-current-buffer output-buffer
|
||||||
|
(dolist (file files)
|
||||||
|
(unless (= (point-min) (point))
|
||||||
|
(insert "\n\n"))
|
||||||
|
(insert-file-contents file))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(when (string= extension "org")
|
||||||
|
(org-mode)))
|
||||||
|
(switch-to-buffer output-buffer)
|
||||||
|
(message "Concatenated %d %s files." (length files) extension))))
|
||||||
|
|
Loading…
Reference in New Issue