修訂 | 315 (tree) |
---|---|
時間 | 2014-11-01 21:29:24 |
作者 | mhayashi1120 |
improve fancy mode-line
@@ -793,7 +793,7 @@ | ||
793 | 793 | ;; |
794 | 794 | |
795 | 795 | (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 | |
797 | 797 | (defvar fsvn-ui-image-directory |
798 | 798 | (condition-case nil |
799 | 799 | (let ((validator (lambda (file) (and (eq (car (file-attributes file)) t) file)))) |
@@ -809,16 +809,16 @@ | ||
809 | 809 | :type 'boolean |
810 | 810 | :group 'fsvn) |
811 | 811 | |
812 | -(defvar fsvn-ui-fancy-object-picture-alist nil) | |
812 | +(defvar fsvn-ui-fancy--object-picture-alist nil) | |
813 | 813 | |
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))) | |
816 | 816 | (cond |
817 | 817 | (cell (cdr cell)) |
818 | 818 | (t |
819 | 819 | (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)) | |
822 | 822 | (when fsvn-ui-image-directory |
823 | 823 | (let ((file (expand-file-name (concat color ".xpm") fsvn-ui-image-directory))) |
824 | 824 | (when (file-exists-p file) |
@@ -827,8 +827,8 @@ | ||
827 | 827 | (setcdr cell (buffer-string)))))) |
828 | 828 | (cdr cell))))) |
829 | 829 | |
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) | |
832 | 832 | (format "/* XPM */ |
833 | 833 | static char * data[] = { |
834 | 834 | \"18 13 3 1\", |
@@ -850,23 +850,23 @@ | ||
850 | 850 | \" \"};" |
851 | 851 | color))) |
852 | 852 | |
853 | -(defun fsvn-ui-fancy-modeline-picture (color) | |
853 | +(defun fsvn-ui-fancy--modeline-picture (color) | |
854 | 854 | (propertize " " |
855 | - 'help-echo 'fsvn-ui-fancy-tooltip | |
855 | + 'help-echo 'fsvn-ui-fancy--tooltip | |
856 | 856 | 'display |
857 | 857 | `(image :type xpm |
858 | - :data ,(fsvn-ui-fancy-get-picture color) | |
858 | + :data ,(fsvn-ui-fancy--get-picture color) | |
859 | 859 | :ascent center))) |
860 | 860 | |
861 | -(defun fsvn-ui-fancy-install-state-mark (color) | |
861 | +(defun fsvn-ui-fancy--install-state-mark (color) | |
862 | 862 | (add-hook 'after-revert-hook 'fsvn-ui-fancy-redraw nil t) |
863 | 863 | (let ((mode `(fsvn-ui-fancy-modeline |
864 | - ,(fsvn-ui-fancy-modeline-picture color)))) | |
864 | + ,(fsvn-ui-fancy--modeline-picture color)))) | |
865 | 865 | (unless (assq 'fsvn-ui-fancy-modeline mode-line-format) |
866 | 866 | (setq mode-line-format (cons mode mode-line-format))) |
867 | 867 | (force-mode-line-update t))) |
868 | 868 | |
869 | -(defun fsvn-ui-fancy-uninstall-state-mark () | |
869 | +(defun fsvn-ui-fancy--uninstall-state-mark () | |
870 | 870 | (remove-hook 'after-revert-hook 'fsvn-ui-fancy-redraw t) |
871 | 871 | (when (listp mode-line-format) |
872 | 872 | (setq mode-line-format |
@@ -874,19 +874,49 @@ | ||
874 | 874 | mode-line-format))) |
875 | 875 | (force-mode-line-update t)) |
876 | 876 | |
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)) | |
879 | 879 | |
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)))))) | |
883 | 888 | |
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))) | |
889 | 896 | |
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 | + | |
890 | 920 | (defadvice vc-find-file-hook (after fsvn-ui-fancy-vc-find-file-hook disable) |
891 | 921 | "vc-find-file-hook advice for synchronizing psvn with vc-svn interface" |
892 | 922 | (fsvn-ui-fancy-redraw)) |
@@ -899,40 +929,32 @@ | ||
899 | 929 | (around fsvn-ui-fancy-ediff-modeline-fixup disable compile) |
900 | 930 | "Fixup svn file status in the modeline when using ediff" |
901 | 931 | (ediff-with-current-buffer ediff-buffer-A |
902 | - (fsvn-ui-fancy-uninstall-state-mark)) | |
932 | + (fsvn-ui-fancy--uninstall-state-mark)) | |
903 | 933 | (ediff-with-current-buffer ediff-buffer-B |
904 | - (fsvn-ui-fancy-uninstall-state-mark)) | |
934 | + (fsvn-ui-fancy--uninstall-state-mark)) | |
905 | 935 | ad-do-it |
906 | 936 | (ediff-with-current-buffer ediff-buffer-A |
907 | - (fsvn-ui-fancy-update-modeline)) | |
937 | + (fsvn-ui-fancy--update-modeline)) | |
908 | 938 | (ediff-with-current-buffer ediff-buffer-B |
909 | - (fsvn-ui-fancy-update-modeline))) | |
939 | + (fsvn-ui-fancy--update-modeline))) | |
910 | 940 | |
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 () | |
921 | 942 | (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)) | |
933 | 946 | (t |
934 | - "GreenYellow"))) | |
947 | + (fsvn-ui-fancy--uninstall-state-mark)))) | |
935 | 948 | |
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 | + | |
936 | 958 | |
937 | 959 | |
938 | 960 | (defmacro fsvn-cmd-read-subcommand-args (subcommand var) |
@@ -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 | + | |
1 | 15 | 2014-09-12 Masahiro Hayashi (林 雅博) <mhayashi1120@gmail.com> |
2 | 16 | |
3 | 17 | * Fix: before 1.7, handle meta directory. |
@@ -625,11 +625,15 @@ | ||
625 | 625 | nil))) |
626 | 626 | |
627 | 627 | (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)))) | |
632 | 631 | |
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 | + | |
633 | 637 | (defun fsvn-open-logview-mode (urlrev directory-p &optional rev-range count) |
634 | 638 | "Open URLREV log buffer. |
635 | 639 | Argument REV-RANGE revision range cons cell `(start . end)' |
@@ -412,6 +412,9 @@ | ||
412 | 412 | (stringp vc-mode) |
413 | 413 | (string-match "\\` SVN" vc-mode))) |
414 | 414 | |
415 | +(defun fsvn-vc-registered (file) | |
416 | + (vc-registered file)) | |
417 | + | |
415 | 418 | |
416 | 419 | |
417 | 420 | (defun fsvn-lisp-save (value file) |
@@ -975,7 +975,9 @@ | ||
975 | 975 | (defun fsvn-parse-result-cmd-delete (buffer &optional min) |
976 | 976 | (fsvn-parse-result-modify-cmd-wrapper-internal |
977 | 977 | (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)))) | |
979 | 981 | |
980 | 982 | (defun fsvn-parse-result-cmd-add (buffer &optional min) |
981 | 983 | (let (files info) |
@@ -982,11 +984,13 @@ | ||
982 | 984 | (setq files |
983 | 985 | (fsvn-parse-result-modify-cmd-wrapper-internal |
984 | 986 | (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)))) | |
986 | 990 | (when (> (length files) 0) |
987 | 991 | (setq info (fsvn-get-info-entry (car files))) |
988 | 992 | (when (fsvn-config-tortoise-property-use (fsvn-xml-info->entry=>repository=>root$ info)) |
989 | - ;; todo asynchronous | |
993 | + ;; FIXME TODO asynchronous | |
990 | 994 | (fsvn-tortoise-tsvn:autoprops-set files buffer))) |
991 | 995 | files)) |
992 | 996 |
@@ -1055,7 +1059,7 @@ | ||
1055 | 1059 | (defun fsvn-parse-result-cmd-commit-added (file) |
1056 | 1060 | (fsvn-save-browse-file-excursion file |
1057 | 1061 | (fsvn-browse-draw-status-this-line)) |
1058 | - (fsvn-redraw-file-fancy-status file)) | |
1062 | + (fsvn-install-file-fancy-status-maybe file)) | |
1059 | 1063 | |
1060 | 1064 | (defconst fsvn-parse-result-cmd-commit-behavior-alist |
1061 | 1065 | '( |
@@ -1172,8 +1176,6 @@ | ||
1172 | 1176 | |
1173 | 1177 | |
1174 | 1178 | |
1175 | - | |
1176 | - | |
1177 | 1179 | (provide 'fsvn-deps) |
1178 | 1180 | |
1179 | 1181 | ;;; fsvn-deps.el ends here |