Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;; `csv-align-fields' の列の幅を設定可能にする
- (defcustom my-csv-column-width 25
- "`csv-align-fields' でCSVテキストを整列表示させたときの列の最小幅。"
- :type 'integer)
- (make-variable-buffer-local 'my-csv-column-width)
- (advice-add 'csv--column-widths :filter-return
- (lambda (widths)
- (mapcar (lambda (width) (max my-csv-column-width width))
- widths)))
- (defun my-csv-align-fields (width hard beg end)
- "CSV列の最小幅設定 `my-csv-column-width' を更新して `csv-align-fields' を呼ぶ。"
- (interactive (cons (read-number "Set my-csv-column-width to: "
- my-csv-column-width)
- (cons current-prefix-arg
- (if (use-region-p)
- (list (region-beginning) (region-end))
- (list (point-min) (point-max))))))
- (message "CSV column width set to %d (was %d)"
- width my-csv-column-width)
- (setq my-csv-column-width width)
- (csv-align-fields hard beg end))
- ;; C-c A で `my-csv-align-fields'。
- (eval-after-load "csv-mode"
- `(define-key csv-mode-map (kbd "C-c A") #'my-csv-align-fields))
Add Comment
Please, Sign In to add comment