From 78965651d3618df368c49ced6bac601abeb5cec5 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sun, 22 Dec 2024 13:22:35 +0100 Subject: [PATCH] update wfnames Signed-off-by: Andreas Gerler --- elpa/wfnames-20230712.1154/wfnames-pkg.el | 12 --- .../wfnames-autoloads.el | 27 +++--- elpa/wfnames-20240820.906/wfnames-pkg.el | 10 ++ .../wfnames.el | 92 ++++++++++++------- 4 files changed, 83 insertions(+), 58 deletions(-) delete mode 100644 elpa/wfnames-20230712.1154/wfnames-pkg.el rename elpa/{wfnames-20230712.1154 => wfnames-20240820.906}/wfnames-autoloads.el (50%) create mode 100644 elpa/wfnames-20240820.906/wfnames-pkg.el rename elpa/{wfnames-20230712.1154 => wfnames-20240820.906}/wfnames.el (83%) diff --git a/elpa/wfnames-20230712.1154/wfnames-pkg.el b/elpa/wfnames-20230712.1154/wfnames-pkg.el deleted file mode 100644 index e3a7b054..00000000 --- a/elpa/wfnames-20230712.1154/wfnames-pkg.el +++ /dev/null @@ -1,12 +0,0 @@ -(define-package "wfnames" "20230712.1154" "Edit filenames" - '((emacs "24.3")) - :commit "4447417c58b063df1fca1ba4bec9cb650c7beb60" :authors - '(("Thierry Volpiatto" . "thievol@posteo.net")) - :maintainers - '(("Thierry Volpiatto" . "thievol@posteo.net")) - :maintainer - '("Thierry Volpiatto" . "thievol@posteo.net") - :url "https://github.com/thierryvolpiatto/wfnames") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/wfnames-20230712.1154/wfnames-autoloads.el b/elpa/wfnames-20240820.906/wfnames-autoloads.el similarity index 50% rename from elpa/wfnames-20230712.1154/wfnames-autoloads.el rename to elpa/wfnames-20240820.906/wfnames-autoloads.el index 050f8881..c7e28041 100644 --- a/elpa/wfnames-20230712.1154/wfnames-autoloads.el +++ b/elpa/wfnames-20240820.906/wfnames-autoloads.el @@ -1,12 +1,14 @@ -;;; wfnames-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- -;; +;;; wfnames-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + ;;; Code: -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + -;;;### (autoloads nil "wfnames" "wfnames.el" (0 0 0 0)) ;;; Generated autoloads from wfnames.el (autoload 'wfnames-setup-buffer "wfnames" "\ @@ -15,20 +17,19 @@ Initialize wfnames buffer with FILES and display it with DISPLAY-FN. Arg DISPLAY-FN default to `switch-to-buffer' if unspecified. When APPEND is specified, append FILES to existing `wfnames-buffer'. -\(fn FILES &optional (DISPLAY-FN #\\='switch-to-buffer) APPEND)" nil nil) - +(fn FILES &optional (DISPLAY-FN #\\='switch-to-buffer) APPEND)") (register-definition-prefixes "wfnames" '("wfnames-")) - -;;;*** -;;;### (autoloads nil nil ("wfnames-pkg.el") (0 0 0 0)) +;;; End of scraped data + +(provide 'wfnames-autoloads) -;;;*** - ;; Local Variables: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t -;; coding: utf-8 +;; no-native-compile: t +;; coding: utf-8-emacs-unix ;; End: + ;;; wfnames-autoloads.el ends here diff --git a/elpa/wfnames-20240820.906/wfnames-pkg.el b/elpa/wfnames-20240820.906/wfnames-pkg.el new file mode 100644 index 00000000..b7ce770c --- /dev/null +++ b/elpa/wfnames-20240820.906/wfnames-pkg.el @@ -0,0 +1,10 @@ +;; -*- no-byte-compile: t; lexical-binding: nil -*- +(define-package "wfnames" "20240820.906" + "Edit filenames." + '((emacs "24.4")) + :url "https://github.com/thierryvolpiatto/wfnames" + :commit "3652cbd131b23df541e306b9c20a65111f05806d" + :revdesc "3652cbd131b2" + :keywords '("wfnames" "convenience" "files" "editing" "helm") + :authors '(("Thierry Volpiatto" . "thievol@posteo.net")) + :maintainers '(("Thierry Volpiatto" . "thievol@posteo.net"))) diff --git a/elpa/wfnames-20230712.1154/wfnames.el b/elpa/wfnames-20240820.906/wfnames.el similarity index 83% rename from elpa/wfnames-20230712.1154/wfnames.el rename to elpa/wfnames-20240820.906/wfnames.el index 54e2d7a7..2aacb60a 100644 --- a/elpa/wfnames-20230712.1154/wfnames.el +++ b/elpa/wfnames-20240820.906/wfnames.el @@ -4,9 +4,11 @@ ;; Copyright (C) 2022 Thierry Volpiatto, all rights reserved. ;; URL: https://github.com/thierryvolpiatto/wfnames -;; Compatibility: GNU Emacs 24.3+" -;; Package-Requires: ((emacs "24.3")) -;; Version: 1.1 +;; Compatibility: GNU Emacs 24.4+" +;; Package-Requires: ((emacs "24.4")) +;; Package-Version: 20240820.906 +;; Package-Revision: 3652cbd131b2 +;; Keywords: wfnames, convenience, files, editing, helm ;; 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 @@ -34,20 +36,20 @@ ;; Usage: ;; Once in the Wfnames buffer, edit your filenames and hit C-c C-c to -;; save your changes. You have completion on filenames and directories +;; save your changes. You have completion on filenames and directories ;; with TAB but if you are using Iedit package and it is in action use =M-TAB=. ;;; Code: -(require 'cl-lib) +(eval-when-compile (require 'cl-lib)) ;; Internal. -(defvar wfnames-buffer "*Wfnames*") -(defvar wfnames--modified nil) +(defconst wfnames-buffer "*Wfnames*") +(defvar-local wfnames--modified nil) (defgroup wfnames nil "A mode to edit filenames." - :group 'wfnames) + :group 'convenience) (defcustom wfnames-create-parent-directories t "Create parent directories when non nil." @@ -57,14 +59,16 @@ "Ask confirmation when overwriting." :type 'boolean) -(defvar wfnames-after-commit-hook nil) +(defcustom wfnames-after-commit-hook nil + "Hook that run after `wfnames-commit-buffer'." + :type 'hook) (defcustom wfnames-after-commit-function #'kill-buffer "A function to call on `wfnames-buffer' when done." :type 'function) (defcustom wfnames-make-backup nil - "Backup files before overwriting when non nil." + "Non-nil means files are backed up before overwriting." :type 'boolean) (defface wfnames-modified @@ -98,11 +102,13 @@ ;; This override ispell completion in iedit map which is useless ;; here. (define-key map (kbd "C-M-i") #'completion-at-point) + (define-key map (kbd "M-p") #'wfnames-move-line-up) + (define-key map (kbd "M-n") #'wfnames-move-line-down) map)) (defun wfnames-capf () "Provide filename completion in wfnames buffer." - (let ((beg (point-at-bol)) + (let ((beg (line-beginning-position)) (end (point))) (list beg end #'completion-file-name-table :exit-function (lambda (str _status) @@ -110,16 +116,14 @@ (eq (char-after) ?/)) (delete-char -1)))))) -(define-derived-mode wfnames-mode - text-mode "wfnames" +(define-derived-mode wfnames-mode text-mode "wfnames" "Major mode to edit filenames. Special commands: \\{wfnames-mode-map}" (add-hook 'after-change-functions #'wfnames-after-change-hook nil t) - (make-local-variable 'wfnames--modified) - (set (make-local-variable 'completion-at-point-functions) #'wfnames-capf) - (set (make-local-variable 'revert-buffer-function) #'wfnames-revert-changes)) + (setq-local completion-at-point-functions #'wfnames-capf) + (setq-local revert-buffer-function #'wfnames-revert-changes)) (defun wfnames-abort () "Quit and kill wfnames buffer." @@ -133,13 +137,14 @@ Args BEG and END delimit changes on line." (save-excursion (save-match-data (goto-char beg) - (let* ((bol (point-at-bol)) - (eol (point-at-eol)) + (let* ((bol (line-beginning-position)) + (eol (line-end-position)) (old (get-text-property bol 'old-name)) (new (buffer-substring-no-properties bol eol)) - ov face) - (setq face (if (file-exists-p new) - 'wfnames-modified-exists 'wfnames-modified)) + (face (if (file-exists-p new) + 'wfnames-modified-exists + 'wfnames-modified)) + ov) (setq-local wfnames--modified (cons old (delete old wfnames--modified))) (cl-loop for o in (overlays-in bol eol) @@ -187,7 +192,7 @@ When APPEND is specified, append FILES to existing `wfnames-buffer'." (when append (delete-duplicate-lines (point-min) (point-max)))) (unless append ;; Go to beginning of basename on first line. - (while (re-search-forward "/" (point-at-eol) t)) + (re-search-forward "\\(?:/[^/]*\\)*/" (line-end-position) t) (wfnames-mode) (funcall display-fn wfnames-buffer)))) @@ -214,8 +219,8 @@ When APPEND is specified, append FILES to existing `wfnames-buffer'." (with-current-buffer wfnames-buffer (goto-char (point-min)) (while (not (eobp)) - (let* ((beg (point-at-bol)) - (end (point-at-eol)) + (let* ((beg (line-beginning-position)) + (end (line-end-position)) (old (get-text-property (point) 'old-name)) (new (buffer-substring-no-properties beg end)) ow) @@ -252,7 +257,7 @@ When APPEND is specified, append FILES to existing `wfnames-buffer'." (let ((basedir (file-name-directory (directory-file-name new)))) (unless (file-directory-p basedir) - (mkdir basedir 'parents)))) + (make-directory basedir 'parents)))) (if (and ow (wfnames-ask-for-overwrite new)) ;; Direct overwrite i.e. first loop. (progn @@ -281,9 +286,9 @@ When APPEND is specified, append FILES to existing `wfnames-buffer'." "Revert current line to its initial state in a wfnames buffer." (let ((old (get-text-property (point) 'old-name)) (new (buffer-substring-no-properties - (point-at-bol) (point-at-eol)))) + (line-beginning-position) (line-end-position)))) (unless (and old new (string= old new)) - (delete-region (point-at-bol) (point-at-eol)) + (delete-region (line-beginning-position) (line-end-position)) (insert (propertize old 'old-name old 'face 'wfnames-file 'line-prefix (propertize @@ -299,22 +304,43 @@ With a numeric prefix ARG, revert the ARG next lines." (dotimes (_ arg) (wfnames-revert-current-line-1) (when (eobp) (forward-line -1)) - (goto-char (point-at-bol)) - (while (re-search-forward "/" (point-at-eol) t)))) + (goto-char (line-beginning-position)) + (re-search-forward "\\(?:/[^/]*\\)*/" (line-end-position) t))) (defun wfnames-revert-changes (_ignore-auto _no-confirm) "Revert wfnames buffer to its initial state. This is used as `revert-buffer-function' for `wfnames-mode'." (with-current-buffer wfnames-buffer - (cl-loop for o in (overlays-in (point-min) (point-max)) - when (overlay-get o 'hff-changed) - do (delete-overlay o)) + (dolist (o (overlays-in (point-min) (point-max))) + (when (overlay-get o 'hff-changed) + (delete-overlay o))) (goto-char (point-min)) (save-excursion (while (not (eobp)) (wfnames-revert-current-line-1))) - (while (re-search-forward "/" (point-at-eol) t)))) + (re-search-forward "\\(?:/[^/]*\\)*/" (line-end-position) t))) + +(defun wfnames-move-line-1 (arg) + "Move line one line down or up according to ARG. +ARG can be 1 for down or -1 for up." + (beginning-of-line) + (let* ((next (+ 1 (line-end-position))) + (line (buffer-substring (point) next))) + (delete-region (point) next) + (forward-line arg) + (insert-before-markers line) + (forward-line -1))) + +(defun wfnames-move-line-down () + "Move line one line down." + (interactive) + (wfnames-move-line-1 1)) + +(defun wfnames-move-line-up () + "Move line one line up." + (interactive) + (wfnames-move-line-1 -1)) (provide 'wfnames) -- 2.47.3