• R/O
  • SSH
  • HTTPS

fsvn: 提交


Commit MetaInfo

修訂315 (tree)
時間2014-11-01 21:29:24
作者mhayashi1120

Log Message

improve fancy mode-line

Change Summary

差異

--- trunk/fsvn-ui.el (revision 314)
+++ trunk/fsvn-ui.el (revision 315)
@@ -793,7 +793,7 @@
793793 ;;
794794
795795 (defvar fsvn-ui-fancy-modeline t) ; modeline mark display or not
796-(defvar fsvn-ui-fancy-tooltip nil) ; modeline tooltip display
796+(defvar fsvn-ui-fancy--tooltip nil) ; modeline tooltip display
797797 (defvar fsvn-ui-image-directory
798798 (condition-case nil
799799 (let ((validator (lambda (file) (and (eq (car (file-attributes file)) t) file))))
@@ -809,16 +809,16 @@
809809 :type 'boolean
810810 :group 'fsvn)
811811
812-(defvar fsvn-ui-fancy-object-picture-alist nil)
812+(defvar fsvn-ui-fancy--object-picture-alist nil)
813813
814-(defun fsvn-ui-fancy-object-picture (color)
815- (let ((cell (assoc color fsvn-ui-fancy-object-picture-alist)))
814+(defun fsvn-ui-fancy--object-picture (color)
815+ (let ((cell (assoc color fsvn-ui-fancy--object-picture-alist)))
816816 (cond
817817 (cell (cdr cell))
818818 (t
819819 (setq cell (cons color nil))
820- (setq fsvn-ui-fancy-object-picture-alist
821- (cons cell fsvn-ui-fancy-object-picture-alist))
820+ (setq fsvn-ui-fancy--object-picture-alist
821+ (cons cell fsvn-ui-fancy--object-picture-alist))
822822 (when fsvn-ui-image-directory
823823 (let ((file (expand-file-name (concat color ".xpm") fsvn-ui-image-directory)))
824824 (when (file-exists-p file)
@@ -827,8 +827,8 @@
827827 (setcdr cell (buffer-string))))))
828828 (cdr cell)))))
829829
830-(defun fsvn-ui-fancy-get-picture (color)
831- (or (fsvn-ui-fancy-object-picture color)
830+(defun fsvn-ui-fancy--get-picture (color)
831+ (or (fsvn-ui-fancy--object-picture color)
832832 (format "/* XPM */
833833 static char * data[] = {
834834 \"18 13 3 1\",
@@ -850,23 +850,23 @@
850850 \" \"};"
851851 color)))
852852
853-(defun fsvn-ui-fancy-modeline-picture (color)
853+(defun fsvn-ui-fancy--modeline-picture (color)
854854 (propertize " "
855- 'help-echo 'fsvn-ui-fancy-tooltip
855+ 'help-echo 'fsvn-ui-fancy--tooltip
856856 'display
857857 `(image :type xpm
858- :data ,(fsvn-ui-fancy-get-picture color)
858+ :data ,(fsvn-ui-fancy--get-picture color)
859859 :ascent center)))
860860
861-(defun fsvn-ui-fancy-install-state-mark (color)
861+(defun fsvn-ui-fancy--install-state-mark (color)
862862 (add-hook 'after-revert-hook 'fsvn-ui-fancy-redraw nil t)
863863 (let ((mode `(fsvn-ui-fancy-modeline
864- ,(fsvn-ui-fancy-modeline-picture color))))
864+ ,(fsvn-ui-fancy--modeline-picture color))))
865865 (unless (assq 'fsvn-ui-fancy-modeline mode-line-format)
866866 (setq mode-line-format (cons mode mode-line-format)))
867867 (force-mode-line-update t)))
868868
869-(defun fsvn-ui-fancy-uninstall-state-mark ()
869+(defun fsvn-ui-fancy--uninstall-state-mark ()
870870 (remove-hook 'after-revert-hook 'fsvn-ui-fancy-redraw t)
871871 (when (listp mode-line-format)
872872 (setq mode-line-format
@@ -874,19 +874,49 @@
874874 mode-line-format)))
875875 (force-mode-line-update t))
876876
877-(defun fsvn-ui-fancy-update-state-mark-tooltip (tooltip)
878- (setq fsvn-ui-fancy-tooltip tooltip))
877+(defun fsvn-ui-fancy--update-state-mark-tooltip (tooltip)
878+ (setq fsvn-ui-fancy--tooltip tooltip))
879879
880-(defun fsvn-ui-fancy-update-state-mark (color)
881- (fsvn-ui-fancy-uninstall-state-mark)
882- (fsvn-ui-fancy-install-state-mark color))
880+(defun fsvn-ui-fancy--update-state-mark (status)
881+ (let ((color (fsvn-ui-fancy--interpret-state-mode-color status))
882+ (mode (assq 'fsvn-ui-fancy-modeline mode-line-format)))
883+ (cond
884+ ((null mode)
885+ (fsvn-ui-fancy--install-state-mark color))
886+ (t
887+ (setcar (cdr mode) (fsvn-ui-fancy--modeline-picture color))))))
883888
884-(defun fsvn-ui-fancy-redraw ()
885- (if (and fsvn-ui-fancy-file-state-in-modeline
886- (fsvn-vc-mode-p))
887- (fsvn-ui-fancy-update-modeline)
888- (fsvn-ui-fancy-uninstall-state-mark)))
889+(defun fsvn-ui-fancy--update-modeline ()
890+ "Update modeline state dot mark properly"
891+ (fsvn-let*
892+ ((buffer-file-name)
893+ ((fsvn-vc-mode-p))
894+ (status (fsvn-ui-fancy--get-status buffer-file-name)))
895+ (fsvn-ui-fancy--update-state-mark status)))
889896
897+(defun fsvn-ui-fancy--get-status (file)
898+ (fsvn-let*
899+ ((status (fsvn-get-file-status file))
900+ (val (fsvn-xml-status->target->entry=>wc-status.item status)))
901+ val))
902+
903+(defun fsvn-ui-fancy--interpret-state-mode-color (val)
904+ "Interpret vc-svn-state symbol to mode line color"
905+ (cond
906+ ((memq val '(deleted))
907+ ;; consider --keep-local
908+ "red")
909+ ((memq val '(replaced))
910+ "blue")
911+ ((memq val '(modified))
912+ "tomato")
913+ ((memq val '(added))
914+ "yellow")
915+ ((memq val '(conflicted incomplete))
916+ "violet")
917+ (t
918+ "GreenYellow")))
919+
890920 (defadvice vc-find-file-hook (after fsvn-ui-fancy-vc-find-file-hook disable)
891921 "vc-find-file-hook advice for synchronizing psvn with vc-svn interface"
892922 (fsvn-ui-fancy-redraw))
@@ -899,40 +929,32 @@
899929 (around fsvn-ui-fancy-ediff-modeline-fixup disable compile)
900930 "Fixup svn file status in the modeline when using ediff"
901931 (ediff-with-current-buffer ediff-buffer-A
902- (fsvn-ui-fancy-uninstall-state-mark))
932+ (fsvn-ui-fancy--uninstall-state-mark))
903933 (ediff-with-current-buffer ediff-buffer-B
904- (fsvn-ui-fancy-uninstall-state-mark))
934+ (fsvn-ui-fancy--uninstall-state-mark))
905935 ad-do-it
906936 (ediff-with-current-buffer ediff-buffer-A
907- (fsvn-ui-fancy-update-modeline))
937+ (fsvn-ui-fancy--update-modeline))
908938 (ediff-with-current-buffer ediff-buffer-B
909- (fsvn-ui-fancy-update-modeline)))
939+ (fsvn-ui-fancy--update-modeline)))
910940
911-(defun fsvn-ui-fancy-update-modeline ()
912- "Update modeline state dot mark properly"
913- (when (and buffer-file-name (fsvn-vc-mode-p))
914- (fsvn-ui-fancy-update-state-mark
915- (fsvn-ui-fancy-interpret-state-mode-color
916- (let ((status (fsvn-get-file-status buffer-file-name)))
917- (fsvn-xml-status->target->entry=>wc-status.item status))))))
918-
919-(defun fsvn-ui-fancy-interpret-state-mode-color (val)
920- "Interpret vc-svn-state symbol to mode line color"
941+(defun fsvn-ui-fancy-redraw ()
921942 (cond
922- ((memq val '(deleted))
923- ;; consider --keep-local
924- "red")
925- ((memq val '(replaced))
926- "blue")
927- ((memq val '(modified))
928- "tomato")
929- ((memq val '(added))
930- "yellow")
931- ((memq val '(conflicted incomplete))
932- "violet")
943+ ((and fsvn-ui-fancy-file-state-in-modeline
944+ (fsvn-vc-mode-p))
945+ (fsvn-ui-fancy--update-modeline))
933946 (t
934- "GreenYellow")))
947+ (fsvn-ui-fancy--uninstall-state-mark))))
935948
949+(defun fsvn-ui-fancy-install ()
950+ (fsvn-let*
951+ ((file buffer-file-name)
952+ (status (fsvn-ui-fancy--get-status file))
953+ (color (fsvn-ui-fancy--interpret-state-mode-color status)))
954+ ;; fancy mode line depend on vc
955+ (fsvn-vc-registered file)
956+ (fsvn-ui-fancy--install-state-mark color)))
957+
936958
937959
938960 (defmacro fsvn-cmd-read-subcommand-args (subcommand var)
--- trunk/ChangeLog (revision 314)
+++ trunk/ChangeLog (revision 315)
@@ -1,3 +1,17 @@
1+2014-10-30 Masahiro Hayashi (林 雅博) <mhayashi1120@gmail.com>
2+
3+ * Fix: Register to vc-mode
4+
5+2014-10-18 Masahiro Hayashi (林 雅博) <mhayashi1120@gmail.com>
6+
7+ * Refactor: cleanup (fancy modeline)
8+
9+ * Refactor: rename function `fsvn-install-file-fancy-status-maybe'
10+
11+2014-10-16 Masahiro Hayashi (林 雅博) <mhayashi1120@gmail.com>
12+
13+ * Refactor Improve: fancy mode line
14+
115 2014-09-12 Masahiro Hayashi (林 雅博) <mhayashi1120@gmail.com>
216
317 * Fix: before 1.7, handle meta directory.
--- trunk/fsvn-pub.el (revision 314)
+++ trunk/fsvn-pub.el (revision 315)
@@ -625,11 +625,15 @@
625625 nil)))
626626
627627 (defun fsvn-redraw-file-fancy-status (file)
628- (let ((buffer (get-file-buffer file)))
629- (when buffer
630- (with-current-buffer buffer
631- (fsvn-ui-fancy-redraw)))))
628+ (fsvn-let* ((buf (get-file-buffer file)))
629+ (with-current-buffer buf
630+ (fsvn-ui-fancy-redraw))))
632631
632+(defun fsvn-install-file-fancy-status-maybe (file)
633+ (fsvn-let* ((buf (get-file-buffer file)))
634+ (with-current-buffer buf
635+ (fsvn-ui-fancy-install))))
636+
633637 (defun fsvn-open-logview-mode (urlrev directory-p &optional rev-range count)
634638 "Open URLREV log buffer.
635639 Argument REV-RANGE revision range cons cell `(start . end)'
--- trunk/fsvn-env.el (revision 314)
+++ trunk/fsvn-env.el (revision 315)
@@ -412,6 +412,9 @@
412412 (stringp vc-mode)
413413 (string-match "\\` SVN" vc-mode)))
414414
415+(defun fsvn-vc-registered (file)
416+ (vc-registered file))
417+
415418
416419
417420 (defun fsvn-lisp-save (value file)
--- trunk/fsvn-deps.el (revision 314)
+++ trunk/fsvn-deps.el (revision 315)
@@ -975,7 +975,9 @@
975975 (defun fsvn-parse-result-cmd-delete (buffer &optional min)
976976 (fsvn-parse-result-modify-cmd-wrapper-internal
977977 (format "^%c[ \t]+\\([^ \t].+\\)$" ?D)
978- buffer min (lambda (f) (fsvn-browse-put-status-1 f ?D))))
978+ buffer min (lambda (f)
979+ (fsvn-browse-put-status-1 f ?D)
980+ (fsvn-redraw-file-fancy-status f))))
979981
980982 (defun fsvn-parse-result-cmd-add (buffer &optional min)
981983 (let (files info)
@@ -982,11 +984,13 @@
982984 (setq files
983985 (fsvn-parse-result-modify-cmd-wrapper-internal
984986 (format "^%c\\(?:[ \t]+(bin)[ \t]+\\|[ \t]+\\)\\([^ \t].+\\)$" ?A)
985- buffer min (lambda (f) (fsvn-browse-put-status-1 f ?A))))
987+ buffer min (lambda (f)
988+ (fsvn-browse-put-status-1 f ?A)
989+ (fsvn-install-file-fancy-status-maybe f))))
986990 (when (> (length files) 0)
987991 (setq info (fsvn-get-info-entry (car files)))
988992 (when (fsvn-config-tortoise-property-use (fsvn-xml-info->entry=>repository=>root$ info))
989- ;; todo asynchronous
993+ ;; FIXME TODO asynchronous
990994 (fsvn-tortoise-tsvn:autoprops-set files buffer)))
991995 files))
992996
@@ -1055,7 +1059,7 @@
10551059 (defun fsvn-parse-result-cmd-commit-added (file)
10561060 (fsvn-save-browse-file-excursion file
10571061 (fsvn-browse-draw-status-this-line))
1058- (fsvn-redraw-file-fancy-status file))
1062+ (fsvn-install-file-fancy-status-maybe file))
10591063
10601064 (defconst fsvn-parse-result-cmd-commit-behavior-alist
10611065 '(
@@ -1172,8 +1176,6 @@
11721176
11731177
11741178
1175-
1176-
11771179 (provide 'fsvn-deps)
11781180
11791181 ;;; fsvn-deps.el ends here
Show on old repository browser