読者です 読者をやめる 読者になる 読者になる

cpanfileに関するユーティリティ

emacs cpanfile

cpanfile に依存を書き忘れない為に - その手の平は尻もつかめるさ

コード

scan-prereqs-cpanfileを実行しているだけなんですが, scan-prereqs-cpanfileと
いう名前がそもそも忘れがちなので.

(defun cpanfile--check ()
  (let ((file (buffer-file-name)))
    (unless (executable-find "scan-prereqs-cpanfile")
      (error "Please 'cpanm App::scan_prereqs_cpanfile' !!"))
    (unless (and file (string= (file-name-nondirectory file) "cpanfile"))
      (error "This is not 'cpanfile'"))))

(defun cpanfile-insert ()
  (interactive)
  (cpanfile--check)
  (save-buffer)
  (let ((cmd "scan-prereqs-cpanfile"))
    (insert (with-temp-buffer
              (unless (zerop (call-process-shell-command cmd nil t))
                (error "Failed %s" cmd))
              (buffer-string)))))

(defun cpanfile-diff ()
  (interactive)
  (cpanfile--check)
  (let ((cmd (format "scan-prereqs-cpanfile --diff=cpanfile"))
        (curdir default-directory))
    (with-current-buffer (get-buffer-create "*perl-cpanfile*")
      (erase-buffer)
      (let ((default-directory curdir))
        (unless (zerop (call-process-shell-command cmd nil t))
          (error "Failed %s" cmd)))
      (pop-to-buffer (current-buffer))
      (goto-char (point-min)))))

おわりに

たまに書こうとするとそもそもどんな感じだったけってなるので,
自動生成させて, それを見て思い出しつつ調整というのが私には
良さそうです.