summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryuzu-eva <stevenhu@web.de>2023-09-09 00:46:10 +0200
committeryuzu-eva <stevenhu@web.de>2023-09-09 00:46:10 +0200
commit19ea9c29fd924b7c023abd99e76fcdd3c6c3f66a (patch)
treefb30da73623f307fd99551b01679f451fee24e6f
parent4aff02df2d621bd8267b75473430393d0e867a6b (diff)
added a find-next-file function. useful for viewing images or skimming through text files
-rw-r--r--.gitignore1
-rw-r--r--config.org24
2 files changed, 22 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index fd06c94..9fb1ee5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,7 @@ auto-save-list/
eln-cache/
elpa/
games/
+image-dired/
irony/
lisp/
transient/
diff --git a/config.org b/config.org
index d0fa8a8..0c95f9b 100644
--- a/config.org
+++ b/config.org
@@ -319,11 +319,10 @@ My preferred org-mode defaults
(set-frame-parameter
nil 'alpha
(if (eql (cond ((numberp alpha) alpha)
- ((numberp (cdr alpha)) (cdr alpha))
- ;; Also handle undocumented (<active> <inactive>) form.
- ((numberp (cadr alpha)) (cadr alpha)))
+ ((numberp (cdr alpha)) (cdr alpha)))
100)
'(90 . 90) '(100 . 100)))))
+
(global-set-key (kbd "C-c t") 'toggle-transparency)
#+end_src
@@ -385,6 +384,25 @@ My preferred org-mode defaults
(global-set-key (kbd "C-M-s-k") 'kill-all-buffers)
#+end_src
+** Find-next-file
+
+#+begin_src emacs-lisp
+ (defun find-next-file (&optional backward)
+ "Find the next file (by name) in the current directory.
+
+ With prefix arg, find the previous file."
+ (interactive "P")
+ (when buffer-file-name
+ (let* ((file (expand-file-name buffer-file-name))
+ (files (cl-remove-if (lambda (file) (cl-first (file-attributes file)))
+ (sort (directory-files (file-name-directory file) t nil t) 'string<)))
+ (pos (mod (+ (cl-position file files :test 'equal) (if backward -1 1))
+ (length files))))
+ (find-file (nth pos files)))))
+
+ (global-set-key (kbd "C-c C-j") 'find-next-file)
+ (global-set-key (kbd "C-c C-k") (lambda () (interactive) (find-next-file :backward)))
+#+end_src
* Use-Package section
** Initialize =dashboard=