diredでディレクトリを開くときにバッファを複数作成しないTIPS

dired-modeにおいて,RETでディレクトリを開くと,デフォルトではdiredバッファが複数作成される.
ディレクトリ階層を移動すると,あっという間にバッファが氾濫してしまい,邪魔だと思う人もいることだろう.
以下の記事でその解決法の一つが示されている:
dired の RET を同じバッファでディレクトリを開くように変更する - あじーん-0.0.2-SNAPSHOT

(defun dired-open-in-accordance-with-situation ()
  (interactive)
  (let ((file (dired-get-filename)))
    (if (file-directory-p file)
        (dired-find-alternate-file)
      (dired-find-file))))

同記事で紹介されている上記の関数をRETにバインドして使用するわけなのだが,
'.'(カレントディレクトリ)と'..'(ペアレントディレクトリ)のところで使用すると,
dired-get-filenameがエラーを吐いてしまう.
そこで自分は以下のように関数を書きなおしてみた:

(defun dired-open-in-accordance-with-situation ()
    (interactive)
    (cond ((string-match "\\(?:\\.\\.?\\)"
                         (format "%s" (thing-at-point 'filename)))
           (dired-find-alternate-file))
          ((file-directory-p (dired-get-filename))
           (dired-find-alternate-file))
          (t
           (dired-find-file))))

これならエラーなしで使える.