Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add navi2ch-directory.el.

clean up split window.
ikki ni kaesugita kibun...
  • Loading branch information...
commit 256da78b6b1e8b17174e1b13c5f5e52a26ed62eb 1 parent d0af0d9
taiki authored
View
54 ChangeLog
@@ -1,3 +1,57 @@
+2002-06-28 Taiki SUGAWARA <taiki.s@cityfujisawa.ne.jp>
+
+ * navi2ch-directory.el: $B?7%U%!%$%k!#%G%#%l%/%H%j$K$"$k%9%l$rA4$FI=(B
+ $B<($9$k%b!<%I!#(B
+
+ * navi2ch.el (toplevel): navi2ch-directory $B$r(B require $B$9$k$h$&$K!#(B
+ (navi2ch-split-window): $B?74X?t!#(B
+ (navi2ch-goto-url): navi2ch-split-window $B$r;H$&$h$&$K!#(B
+ (navi2ch-find-file): navi2ch-article-find-file $B$+$i%j%M!<%`!#%G%#(B
+ $B%l%/%H%j$r;XDj$7$?>l9g$O(B navi2ch-directory $B$r8F$V$h$&$K!#(B
+ navi2ch-split-window $B$r;H$&$h$&$K!#(B
+
+ * navi2ch-vars.el (navi2ch-global-map): C-cC-f $B$r(B
+ navi2ch-find-file $B$KJQ99!#(B
+
+ * navi2ch-util.el (navi2ch-filename-to-url): $B?74X?t!#(B
+
+ * navi2ch-search.el (navi2ch-search-article-regexp):
+ navi2ch-article-get-first-message $B$r;H$&$h$&$K!#(B
+
+ * navi2ch-list.el (navi2ch-list-select-board):
+ navi2ch-split-window $B$r;H$&$h$&$K!#(B
+ (navi2ch-list-two-pane): $B:o=|!#(B
+
+ * navi2ch-bookmark.el (navi2ch-bookmark-fetch-article):
+ navi2ch-article-get-first-message $B$r;H$&$h$&$K!#(B
+
+ * navi2ch-board.el (navi2ch-board-get-file-name): file:// $B$G$O$8$^$C(B
+ $B$F$$$?$i!"$=$N%U%!%$%kL>$rJV$9$h$&$K!#(B
+ (navi2ch-board-two-pane) $B:o=|!#(B
+
+ * navi2ch-board-misc.el (navi2ch-bm-insert-subject): $B%U%!%$%k$+$i(B
+ $B<hF@$N>l9g$K!"%U%!%$%kL>(B
+ $B$r(B item $B$G$O$J$/(B navi2ch-article-get-file-name() $B$GF@$k$h$&$K!#(B
+ (navi2ch-bm-select-article): navi2ch-split-window $B$r;H$&$h$&$K!#(B
+ $B%U%!%$%k$+$i<hF@$N>l9g$K(B navi2ch-article-view-article-from-file $B$r(B
+ $B;H$&$h$&$K!#(B
+
+ * navi2ch-article.el (navi2ch-article-get-url): $B0z?t$K(B no-kako $B$r(B
+ $B<h$k$h$&$K!#(B
+ (navi2ch-article-get-buffer-name): url $B$r(B buffer $BL>$K$9$k$h$&$K!#(B
+ (navi2ch-article-get-first-message): $B?74X?t!#(Bcurrent-buffer $B$N(B
+ article $B$N:G=i$N(B message $B$rJV$9!#(B
+ (navi2ch-article-get-first-message-from-file): $B?74X?t!#(BFILE $B$G;XDj(B
+ $B$5$l$?(B article $B$N:G=i$N(B message $B$rJV$9!#(B
+ (navi2ch-article-view-article-from-file): $B@8@.$9$k(B board, article
+ $B$N$rIaDL$N$b$N$HF1$8$h$&$J46$8$KJQ99!#(Bsync $B$7$?7k2L$,JV$jCM$K$J$k(B
+ $B$h$&$K!#(B
+ (navi2ch-article-sync-from-file): navi2ch-article-message-list $B$O(B
+ $B$3$3$G:n$k$h$&$K$9$k!#@hF,$K0\F0$9$k$h$&$K!#(B
+ (navi2ch-article-find-file): navi2ch-find-file $B$K%j%M!<%`!#(B
+ navi2ch.el $B$K0\F0!#(B
+ (navi2ch-article-two-pane): $B:o=|(B
+
2002-06-27 Nanashi San <nanashi@users.sourceforge.net>
* navi2ch-bookmark.el (navi2ch-bookmark-get-buffer): $B?74X?t!#(B
View
2  Makefile.am
@@ -6,7 +6,7 @@ lisp_LISP = navi2ch-version.el \
navi2ch-history.el navi2ch-search.el navi2ch-message.el \
navi2ch.el \
navi2ch-head.el navi2ch-mona.el navi2ch-e21.el \
- navi2ch-splash.el
+ navi2ch-splash.el navi2ch-directory
EXTRA_DIST = Makefile.old bcomp.el $(lisp_LISP) \
bcomp.el.in navi2ch-version.el.in
View
112 navi2ch-article.el
@@ -75,7 +75,6 @@
(define-key map "a" 'navi2ch-article-add-important-message)
(define-key map "h" 'navi2ch-article-toggle-hide)
(define-key map "$" 'navi2ch-article-toggle-important)
- ;; (define-key map "2" 'navi2ch-article-two-pane)
(define-key map "A" 'navi2ch-article-add-global-bookmark)
(define-key map "\C-c\C-m" 'navi2ch-message-pop-message-buffer)
(setq navi2ch-article-mode-map map)))
@@ -155,10 +154,11 @@ last $B$,:G8e$+$i$$$/$DI=<($9$k$+!#(B
(navi2ch-article-expunge-buffers 0)))
;;; navi2ch-article functions
-(defun navi2ch-article-get-url (board article)
+(defun navi2ch-article-get-url (board article &optional no-kako)
(let ((artid (cdr (assq 'artid article)))
(url (navi2ch-board-get-uri board)))
- (if (cdr (assq 'kako article))
+ (if (and (not no-kako)
+ (cdr (assq 'kako article)))
(navi2ch-article-get-kako-url board article)
(concat url "dat/" artid ".dat"))))
@@ -188,9 +188,7 @@ LEN $B$O(B RANGE $B$GHO0O$r;XDj$5$l$k(B list $B$ND9$5(B"
(defsubst navi2ch-article-get-buffer-name (board article)
(concat navi2ch-article-buffer-name-prefix
- (cdr (assq 'id board))
- "/"
- (cdr (assq 'artid article))))
+ (navi2ch-article-get-url board article 'no-kako)))
(defsubst navi2ch-article-check-cached (board article)
"BOARD $B$H(B ARTICLE $B$G;XDj$5$l$k%9%l%C%I$,%-%c%C%7%e$5$l$F$k$+!#(B"
@@ -313,6 +311,21 @@ START, END, NOFIRST $B$GHO0O$r;XDj$9$k(B"
" *<> *"
" *, *")))
+(defsubst navi2ch-article-get-first-message ()
+ "current-buffer $B$N(B article $B$N:G=i$N(B message $B$rJV$9!#(B"
+ (goto-char (point-min))
+ (navi2ch-article-parse-message
+ (buffer-substring-no-properties (point)
+ (progn (forward-line 1)
+ (1- (point))))
+ (navi2ch-article-get-separator)))
+
+(defsubst navi2ch-article-get-first-message-from-file (file)
+ "FILE $B$G;XDj$5$l$?(B article $B$N:G=i$N(B message $B$rJV$9!#(B"
+ (with-temp-buffer
+ (navi2ch-insert-file-contents file)
+ (navi2ch-article-get-first-message)))
+
(defun navi2ch-article-apply-filters (board)
(dolist (filter navi2ch-article-filter-list)
(if (stringp (car-safe filter))
@@ -531,14 +544,18 @@ DONT-DISPLAY $B$,(B non-nil $B$N$H$-$O%9%l%P%C%U%!$rI=<($;$:$K<B9T!#(B"
(defun navi2ch-article-view-article-from-file (file)
"FILE $B$+$i%9%l$r8+$k!#(B"
+ (setq file (expand-file-name file))
(let* ((board (list (cons 'id "navi2ch")
- (cons 'name navi2ch-bm-board-name-from-file)))
- (article (list (cons 'artid file)))
+ (cons 'uri (navi2ch-filename-to-url
+ (file-name-directory file)))
+ (cons 'name navi2ch-bm-board-name-from-file)))
+ (article (list (cons 'artid (file-name-sans-extension
+ (file-name-nondirectory file)))))
(buf-name (navi2ch-article-get-buffer-name board article)))
(if (get-buffer buf-name)
(progn
(switch-to-buffer buf-name)
- (navi2ch-article-sync))
+ nil)
(if (and navi2ch-article-auto-expunge
(> navi2ch-article-max-buffers 0))
(navi2ch-article-expunge-buffers (1- navi2ch-article-max-buffers)))
@@ -549,11 +566,10 @@ DONT-DISPLAY $B$,(B non-nil $B$N$H$-$O%9%l%P%C%U%!$rI=<($;$:$K<B9T!#(B"
(when navi2ch-article-auto-range
(setq navi2ch-article-view-range
navi2ch-article-new-message-range))
- (save-excursion
- (setq navi2ch-article-message-list
- (navi2ch-article-sync-from-file file))
- (navi2ch-article-set-mode-line))
- (navi2ch-article-mode))))
+ (prog1
+ (navi2ch-article-sync-from-file file)
+ (navi2ch-article-set-mode-line)
+ (navi2ch-article-mode)))))
(defun navi2ch-article-setup-menu ()
(easy-menu-define navi2ch-article-mode-menu
@@ -761,13 +777,16 @@ state $B$O$"$\!<$s$5$l$F$l$P(B aborn $B$H$$$&%7%s%\%k!#(B
(defun navi2ch-article-sync-from-file (file)
"$B%9%l$r(B FILE $B$+$i99?7$9$k!#(B"
- (when navi2ch-article-from-file-p
+ (when (and navi2ch-article-from-file-p
+ (file-exists-p file))
(let ((list (navi2ch-article-get-message-list file))
- (range navi2ch-article-view-range))
- (let ((buffer-read-only nil))
- (erase-buffer)
- (navi2ch-article-insert-messages list range))
- list)))
+ (range navi2ch-article-view-range)
+ (buffer-read-only nil))
+ (erase-buffer)
+ (navi2ch-article-insert-messages list range)
+ (prog1
+ (setq navi2ch-article-message-list list)
+ (navi2ch-article-goto-number 1)))))
(defun navi2ch-article-set-mode-line ()
(let ((article navi2ch-article-current-article)
@@ -838,29 +857,6 @@ state $B$O$"$\!<$s$5$l$F$l$P(B aborn $B$H$$$&%7%s%\%k!#(B
(navi2ch-article-select-view-range-subr))
(navi2ch-article-redraw))
-(defun navi2ch-article-find-file (file)
- "FILE $B$+$i%9%l$rA*$V(B"
- (interactive "fArtilce File: ")
- (let ((list-win (get-buffer-window navi2ch-list-buffer-name))
- (board-win (get-buffer-window navi2ch-board-buffer-name))
- (art-win (and (navi2ch-article-current-buffer)
- (get-buffer-window (navi2ch-article-current-buffer)))))
- (cond (art-win (select-window art-win))
- (board-win
- (select-window board-win)
- (when navi2ch-bm-stay-board-window
- (condition-case nil
- (enlarge-window (frame-height))
- (error nil))
- (split-window-vertically navi2ch-board-window-height)
- (other-window 1)))
- (list-win
- (select-window list-win)
- (when navi2ch-list-stay-list-window
- (split-window-horizontally navi2ch-list-window-width)
- (other-window 1))))
- (navi2ch-article-view-article-from-file file)))
-
(defun navi2ch-article-save-number ()
(unless (or navi2ch-article-hide-mode
navi2ch-article-important-mode)
@@ -1226,35 +1222,6 @@ NUM $B$,(B 1 $B$N$H$-$O<!!"(B-1 $B$N$H$-$OA0$N%9%l$K0\F0!#(B
(interactive)
(navi2ch-article-through-subr (interactive-p) -1))
-(defun navi2ch-article-two-pane ()
- (interactive)
- (let* ((list-buf (get-buffer navi2ch-list-buffer-name))
- (board-buf (get-buffer navi2ch-board-buffer-name))
- (art-buf (navi2ch-article-current-buffer))
- (list-win (get-buffer-window (or list-buf "")))
- (board-win (get-buffer-window (or board-buf "")))
- buf)
- (when art-buf
- (delete-other-windows)
- (switch-to-buffer art-buf)
- (setq buf
- (cond ((and list-buf board-buf)
- (cond ((and list-win board-win) board-buf)
- (list-win board-buf)
- (board-win list-buf)
- (t board-buf)))
- (list-buf list-buf)
- (board-buf board-buf)))
- (when buf
- (if (eq buf list-buf)
- (split-window-horizontally navi2ch-list-window-width)
- (condition-case nil
- (enlarge-window (frame-height))
- (error nil))
- (split-window-vertically navi2ch-board-window-height))
- (switch-to-buffer buf))
- (other-window 1))))
-
(defun navi2ch-article-get-message (num)
"NUM $BHVL\$N%l%9$rF@$k(B"
(cdr (assq num navi2ch-article-message-list)))
@@ -1684,7 +1651,6 @@ gunzip $B$KDL$7$F$+$iJ8;z%3!<%I$N?dB,$r;n$_$k!#(B"
(point-max))))))
(message msg))
-
;;; hide mode
(navi2ch-set-minor-mode 'navi2ch-article-hide-mode
" Hide"
View
40 navi2ch-board-misc.el
@@ -192,9 +192,12 @@
(state (cond ((string= (cdr (assq 'name board))
navi2ch-bm-board-name-from-file)
; navi2ch-article-check-cached $B$G=hM}$9$Y$-$+!#(B
- (cond ((get-buffer (navi2ch-article-get-buffer-name board article))
+ (cond ((get-buffer (navi2ch-article-get-buffer-name
+ board article))
'view)
- ((and item (file-exists-p item))
+ ((file-exists-p
+ (navi2ch-article-get-file-name
+ board article))
'cache)
(t
nil)))
@@ -263,25 +266,20 @@
(board (navi2ch-bm-get-board-internal item))
(buf (current-buffer)))
(if article
- (if (string= (cdr (assq 'name board))
- navi2ch-bm-board-name-from-file)
- (navi2ch-article-find-file item)
- (dolist (x (navi2ch-article-buffer-list))
- (when x
- (delete-windows-on x)))
- (when navi2ch-bm-stay-board-window
- (condition-case nil
- (enlarge-window (frame-height))
- (error nil))
- (split-window-vertically navi2ch-board-window-height)
- (other-window 1))
- (let (state)
- (setq state (navi2ch-article-view-article
- board article nil nil max-line))
- (save-excursion
- (set-buffer buf)
- (let ((buffer-read-only nil))
- (when (or state
+ (progn
+ (navi2ch-split-window 'article)
+ (let (state)
+ (setq state
+ (if (string= (cdr (assq 'name board))
+ navi2ch-bm-board-name-from-file)
+ (navi2ch-article-view-article-from-file
+ (navi2ch-article-get-file-name board article))
+ (navi2ch-article-view-article
+ board article nil nil max-line)))
+ (save-excursion
+ (set-buffer buf)
+ (let ((buffer-read-only nil))
+ (when (or state
(navi2ch-bm-fetched-article-p board article)
(eq (navi2ch-bm-get-state) 'view))
(navi2ch-bm-remove-fetched-article board article)
View
46 navi2ch-board.el
@@ -40,7 +40,6 @@
(define-key map "+" 'navi2ch-board-toggle-updated)
(define-key map "b" 'navi2ch-board-toggle-bookmark)
(define-key map "w" 'navi2ch-board-write-message)
- ;; (define-key map "2" 'navi2ch-board-two-pane)
(define-key map "\M-e" 'navi2ch-board-expire)
(define-key map "md" 'navi2ch-board-hide-mark-article)
(setq navi2ch-board-mode-map map)))
@@ -169,10 +168,16 @@
(defun navi2ch-board-get-file-name (board &optional file-name)
(let ((uri (navi2ch-board-get-uri board)))
- (when (and uri (string-match "http://\\(.+\\)" uri))
- (setq uri (match-string 1 uri))
- (navi2ch-expand-file-name
- (concat uri (or file-name navi2ch-board-subject-file-name))))))
+ (when uri
+ (cond ((string-match "http://\\(.+\\)" uri)
+ (navi2ch-expand-file-name
+ (concat (match-string 1 uri)
+ (or file-name navi2ch-board-subject-file-name))))
+ ((string-match "file://\\(.+\\)" uri)
+ (expand-file-name (or file-name
+ navi2ch-board-subject-file-name)
+ (match-string 1 uri)))))))
+
(defsubst navi2ch-board-get-matched-article ()
"match $B$7$?7k2L$+$i(B article $B$rF@$k(B"
@@ -436,37 +441,6 @@
(interactive)
(navi2ch-message-write-message navi2ch-board-current-board nil t))
-(defun navi2ch-board-two-pane ()
- (interactive)
- (let* ((list-buf (get-buffer navi2ch-list-buffer-name))
- (board-buf (get-buffer navi2ch-board-buffer-name))
- (art-buf (navi2ch-article-current-buffer))
- (list-win (get-buffer-window (or list-buf "")))
- (art-win (get-buffer-window (or art-buf "")))
- buf)
- (when board-buf
- (delete-other-windows)
- (switch-to-buffer board-buf)
- (setq buf
- (cond ((and list-buf art-buf)
- (cond ((and list-win art-win) art-buf)
- (list-win art-buf)
- (art-win list-buf)
- (t art-buf)))
- (list-buf list-buf)
- (art-buf art-buf)))
- (when buf
- (if (eq buf list-buf)
- (split-window-horizontally navi2ch-list-window-width)
- (condition-case nil
- (enlarge-window (frame-height))
- (error nil))
- (split-window-vertically navi2ch-board-window-height)
- (other-window 1))
- (switch-to-buffer buf))
- (other-window 1))))
-
-
(defun navi2ch-board-save-info (&optional board)
(or board (setq board navi2ch-board-current-board))
(when board
View
14 navi2ch-bookmark.el
@@ -384,21 +384,13 @@ KEY $B$O(B (concat URI ARTID) ")
(setq state (navi2ch-bm-fetch-article max-line))
(unless (assq 'subject article)
(let ((newsubject
- (let ((file (navi2ch-article-get-file-name board article))
- sep)
+ (let ((file (navi2ch-article-get-file-name board article)))
(when (and file
(file-exists-p file))
;; dat $B$r(B $BA4ItFI$^$:!"F,$N(B1$B9T$@$1FI$`$N$O$I$&$9$l$P(B?
;; $B26$bCN$i$J$$$G$9(B:-)
- (with-temp-buffer
- (navi2ch-insert-file-contents file)
- (goto-char (point-min))
- (setq sep (navi2ch-article-get-separator))
- (cdr (assq 'subject (navi2ch-article-parse-message
- (buffer-substring-no-properties
- (point)
- (progn (end-of-line) (point)))
- sep))))))))
+ (cdr (assq 'subject
+ (navi2ch-article-get-first-message-from-file file)))))))
(when newsubject
(setq article (navi2ch-put-alist 'subject newsubject article))
(navi2ch-bookmark-add-subr
View
145 navi2ch-directory.el
@@ -0,0 +1,145 @@
+;;; navi2ch-directory.el --- List directory files Module for Navi2ch
+
+;; Copyright (C) 2002 by Navi2ch Project
+
+;; Author: Taiki SUGAWARA <taiki@users.sourceforge.net>
+;; Keywords: 2ch, network
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+(provide 'navi2ch-directory)
+
+(eval-when-compile (require 'cl))
+
+(require 'navi2ch)
+
+(defvar navi2ch-directory-mode-map nil)
+(unless navi2ch-directory-mode-map
+ (let ((map (make-sparse-keymap)))
+ (set-keymap-parent map navi2ch-bm-mode-map)
+ (setq navi2ch-directory-mode-map map)))
+
+(defvar navi2ch-directory-mode-menu-spec
+ (navi2ch-bm-make-menu-spec
+ "Directory"
+ nil))
+
+(defvar navi2ch-directory-board
+ '((name . "$B%U%!%$%k0lMw(B")
+ (type . directory)
+ (id . "directory")))
+
+(defvar navi2ch-directory-current-board nil)
+(defvar navi2ch-directory-subject-list nil)
+
+;;; navi2ch-bm callbacks
+(defun navi2ch-directory-set-property (begin end item)
+ (put-text-property begin end 'item item))
+
+(defun navi2ch-directory-get-property (point)
+ (get-text-property
+ (save-excursion (goto-char point)
+ (beginning-of-line)
+ (point))
+ 'item))
+
+(defun navi2ch-directory-get-article (item)
+ item)
+
+(defun navi2ch-directory-get-board (item)
+ navi2ch-directory-current-board)
+
+(defun navi2ch-directory-exit ()
+ (run-hooks 'navi2ch-directory-exit-hook))
+
+;; regist board
+(navi2ch-bm-regist-board 'directory 'navi2ch-directory
+ navi2ch-directory-board)
+
+;;; navi2ch-directory functions
+(defun navi2ch-directory-insert-subjects ()
+ (let ((i 1))
+ (dolist (article navi2ch-directory-subject-list)
+ (navi2ch-bm-insert-subject
+ article i
+ (cdr (assq 'subject article))
+ (format "[%s]" (cdr (assq 'artid article))))
+ (setq i (1+ i)))))
+
+(defun navi2ch-directory-set-current-board (directory)
+ (setq directory (expand-file-name directory))
+ (setq navi2ch-directory-current-board
+ (list (cons 'name navi2ch-bm-board-name-from-file)
+ (cons 'uri (navi2ch-filename-to-url directory))
+ (cons 'id "navi2ch"))))
+
+(defun navi2ch-directory-set-subject-list (directory)
+ (setq directory (expand-file-name directory))
+ (setq navi2ch-directory-subject-list
+ (mapcar
+ (lambda (file)
+ (list
+ (cons 'subject
+ (cdr (assq 'subject
+ (navi2ch-article-get-first-message-from-file
+ file))))
+ (cons 'artid
+ (file-name-nondirectory (file-name-sans-extension file)))))
+ (directory-files directory t "\\.dat$"))))
+
+(defun navi2ch-directory-find-directory (directory)
+ (interactive "Ddirectory: ")
+ (when (file-directory-p directory)
+ (setq directory (expand-file-name directory))
+ (setq default-directory directory)
+ (navi2ch-directory-set-current-board directory)
+ (navi2ch-directory-set-subject-list directory)
+ (navi2ch-bm-select-board navi2ch-directory-board)))
+
+(defun navi2ch-directory (&rest args)
+ "directory $B$rI=<($9$k(B"
+ (navi2ch-directory-mode)
+ (navi2ch-bm-setup 'navi2ch-directory)
+ (let ((buffer-read-only nil))
+ (erase-buffer)
+ (save-excursion
+ (navi2ch-directory-insert-subjects))))
+
+(defun navi2ch-directory-setup-menu ()
+ (easy-menu-define navi2ch-directory-mode-menu
+ navi2ch-directory-mode-map
+ "Menu used in navi2ch-directory"
+ navi2ch-directory-mode-menu-spec)
+ (easy-menu-add navi2ch-directory-mode-menu))
+
+(defun navi2ch-directory-mode ()
+ "\\{navi2ch-directory-mode-map}"
+ (interactive)
+ (kill-all-local-variables)
+ (setq major-mode 'navi2ch-directory-mode)
+ (setq mode-name "Navi2ch Directory")
+ (setq buffer-read-only t)
+ (use-local-map navi2ch-directory-mode-map)
+ (navi2ch-directory-setup-menu)
+ (run-hooks 'navi2ch-bm-mode-hook 'navi2ch-directory-mode-hook))
+
+(run-hooks 'navi2ch-directory-load-hook)
+;;; navi2ch-directory.el ends here
View
30 navi2ch-list.el
@@ -48,7 +48,6 @@
(define-key map "/" 'navi2ch-list-toggle-open)
(define-key map "[" 'navi2ch-list-open-all-category)
(define-key map "]" 'navi2ch-list-close-all-category)
- ;; (define-key map "2" 'navi2ch-list-two-pane)
(define-key map "D" 'navi2ch-list-delete-global-bookmark)
(define-key map "C" 'navi2ch-list-change-global-bookmark)
(define-key map "?" 'navi2ch-list-search)
@@ -331,9 +330,7 @@
(dolist (x (navi2ch-article-buffer-list))
(when x
(delete-windows-on x)))
- (when (and flag navi2ch-list-stay-list-window)
- (split-window-horizontally navi2ch-list-window-width)
- (other-window 1))
+ (navi2ch-split-window 'board)
(navi2ch-bm-select-board board force)))
(defun navi2ch-list-setup-menu ()
@@ -554,31 +551,6 @@ changed-list $B$O(B '((board-id old-board new-board) ...) $B$J(B alist$B!#
(setq alist (append (cdr (assq 'child x)) alist))))
alist))
-(defun navi2ch-list-two-pane ()
- (interactive)
- (let* ((list-buf (get-buffer navi2ch-list-buffer-name))
- (board-buf (get-buffer navi2ch-board-buffer-name))
- (art-buf (navi2ch-article-current-buffer))
- (board-win (get-buffer-window (or board-buf "")))
- (art-win (get-buffer-window (or art-buf "")))
- buf)
- (when list-buf
- (delete-other-windows)
- (switch-to-buffer list-buf)
- (setq buf
- (cond ((and board-buf art-buf)
- (cond ((and board-win art-win) board-buf)
- (board-win art-buf)
- (art-win board-buf)
- (t board-buf)))
- (board-buf board-buf)
- (art-buf art-buf)))
- (when buf
- (split-window-horizontally navi2ch-list-window-width)
- (other-window 1)
- (switch-to-buffer buf))
- (other-window 1))))
-
(defun navi2ch-list-save-info ()
(when navi2ch-list-category-list
(let ((list (mapcar (lambda (elt)
View
20 navi2ch-search.el
@@ -134,20 +134,16 @@
(navi2ch-insert-file-contents file)
(goto-char (point-min))
(when (re-search-forward regexp nil t)
- (goto-char (point-min))
(let ((subject
(cdr (assq 'subject
- (navi2ch-article-parse-message
- (buffer-substring-no-properties (point)
- (progn (forward-line 1)
- (1- (point))))
- (navi2ch-article-get-separator))))))
- (string-match "[0-9]+" file)
- (setq alist (cons
- (cons board
- (list (cons 'subject subject)
- (cons 'artid (match-string 0 file))))
- alist))))))))
+ (navi2ch-article-get-first-message)))))
+ (setq alist
+ (cons
+ (cons board
+ (list (cons 'subject subject)
+ (cons 'artid
+ (file-name-sans-extension file))))
+ alist))))))))
(message "searching article...%s" (if alist "done" "not found"))
(nreverse alist)))
View
3  navi2ch-util.el
@@ -600,5 +600,8 @@ TAG $B$O@55,I=8=!#(B"
(mapconcat 'car
navi2ch-replace-html-tag-regexp-alist "\\|"))))
+(defun navi2ch-filename-to-url (filename)
+ (concat "file://" (expand-file-name filename)))
+
(run-hooks 'navi2ch-util-load-hook)
;;; navi2ch-util.el ends here
View
2  navi2ch-vars.el
@@ -896,7 +896,7 @@ X11 $B>e$G8+$k$?$a$K:n$i$l$?%U%j!<$N%U%)%s%H$G$9!#(B
"navi2ch $B$N$I$N%b!<%I$G$b;H$($k(B keymap$B!#(B")
(unless navi2ch-global-map
(let ((map (make-sparse-keymap)))
- (define-key map "\C-c\C-f" 'navi2ch-article-find-file)
+ (define-key map "\C-c\C-f" 'navi2ch-find-file)
;; (define-key map "\C-c\C-g" 'navi2ch-list-goto-board)
(define-key map "\C-c\C-t" 'navi2ch-toggle-offline)
(define-key map "\C-c\C-u" 'navi2ch-goto-url)
View
78 navi2ch.el
@@ -39,6 +39,7 @@
(require 'navi2ch-bookmark)
(require 'navi2ch-history)
(require 'navi2ch-search)
+(require 'navi2ch-directory)
(require 'navi2ch-message)
(and navi2ch-on-emacs21
(require 'navi2ch-e21))
@@ -253,6 +254,33 @@ SUSPEND $B$,(B non-nil $B$J$i(B buffer $B$r>C$5$J$$(B"
(let ((standard-input (current-buffer)))
(read))))))
+(defun navi2ch-split-window (display)
+ "window $B$rJ,3d$9$k!#(B
+DISPLAY $B$,(B `board' $B$N$H$-$O(B board $B$rI=<($9$kMQ$KJ,3d$9$k!#(B
+DISPLAY $B$,(B `article' $B$N$H$-$O(B article $B$rI=<($9$kMQ$KJ,3d$9$k!#(B"
+ (let ((list-win (get-buffer-window navi2ch-list-buffer-name))
+ (board-win (get-buffer-window navi2ch-board-buffer-name))
+ (art-win (and (navi2ch-article-current-buffer)
+ (get-buffer-window (navi2ch-article-current-buffer)))))
+ (cond (art-win
+ (select-window art-win)
+ (when (eq display 'board)
+ (navi2ch-article-exit)))
+ (board-win
+ (select-window board-win)
+ (when (and (eq display 'article)
+ navi2ch-bm-stay-board-window)
+ (condition-case nil
+ (enlarge-window (frame-height))
+ (error nil))
+ (split-window-vertically navi2ch-board-window-height)
+ (other-window 1)))
+ (list-win
+ (select-window list-win)
+ (when navi2ch-list-stay-list-window
+ (split-window-horizontally navi2ch-list-window-width)
+ (other-window 1))))))
+
(defun navi2ch-goto-url (url &optional force)
"URL $B$+$i%9%l$^$?$OHD$rA*$V(B"
(interactive "sURL: ")
@@ -262,31 +290,31 @@ SUSPEND $B$,(B non-nil $B$J$i(B buffer $B$r>C$5$J$$(B"
(get-buffer-window (navi2ch-article-current-buffer))))
(article (navi2ch-article-url-to-article url))
(board (navi2ch-board-url-to-board url)))
- (when board
- (cond (art-win
- (select-window art-win)
- (unless article
- (navi2ch-article-exit)))
- (board-win
- (select-window board-win)
- (when article
- (condition-case nil
- (enlarge-window (frame-height))
- (error nil))
- (split-window-vertically navi2ch-board-window-height)
- (other-window 1)))
- (list-win
- (select-window list-win)
- (when navi2ch-list-stay-list-window
- (split-window-horizontally navi2ch-list-window-width)
- (other-window 1))))
- (if article
- (progn
- (navi2ch-article-view-article board
- article
- force
- (cdr (assq 'number article))))
- (navi2ch-board-select-board board force)))))
+ (cond (article
+ (navi2ch-split-window 'article)
+ (navi2ch-article-view-article board
+ article
+ force
+ (cdr (assq 'number article))))
+ (board
+ (navi2ch-split-window 'board)
+ (navi2ch-board-select-board board force)))))
+
+(defun navi2ch-find-file (file)
+ "FILE $B$+$i%9%l$^$?$OHD$rA*$V(B"
+ (interactive "fFind article file or board directory: ")
+ (let ((list-win (get-buffer-window navi2ch-list-buffer-name))
+ (board-win (get-buffer-window navi2ch-board-buffer-name))
+ (art-win (and (navi2ch-article-current-buffer)
+ (get-buffer-window (navi2ch-article-current-buffer))))
+ (article-p (file-regular-p file))
+ (board-p (file-directory-p file)))
+ (cond (article-p
+ (navi2ch-split-window 'article)
+ (navi2ch-article-view-article-from-file file))
+ (board-p
+ (navi2ch-split-window 'board)
+ (navi2ch-directory-find-directory file)))))
(defun navi2ch-2ch-url-p (url)
"URL $B$,(B 2ch $BFb$N(B url $B$+$rJV$9!#(B"
Please sign in to comment.
Something went wrong with that request. Please try again.