[logaling-commit] logaling/logalimacs [master] Apply function that is displayed the marked-word to minibuffer

Back to archive index

null+****@clear***** null+****@clear*****
Mon Jul 2 14:48:48 JST 2012


yuta yamada	2012-07-02 14:48:48 +0900 (Mon, 02 Jul 2012)

  New Revision: e5888558400020f085b43cae6ddda5443fdbfb7a
  https://github.com/logaling/logalimacs/commit/e5888558400020f085b43cae6ddda5443fdbfb7a

  Log:
    Apply function that is displayed the marked-word to minibuffer

  Modified files:
    logalimacs.el

  Modified: logalimacs.el (+18 -1)
===================================================================
--- logalimacs.el    2012-07-02 14:39:59 +0900 (2200d0b)
+++ logalimacs.el    2012-07-02 14:48:48 +0900 (04dd0b1)
@@ -224,6 +224,9 @@ Example:
     terminal-output))
 
 (defun loga-add/update (task)
+  (setq loga-marked-words nil)
+  (if mark-active
+      (loga-return-marked-region))
   (let* ((input (loga-input))
          (spew-message (loga-to-shell "\\loga" (concat task " " input))))
     (if (and (string-match "^term '.+' already exists in '.+'" spew-message)
@@ -399,11 +402,25 @@ Because it escape character"
       `(,column))))
 
 (defun loga-query (&optional message)
-  (let* ((input (read-string (or message "types here:"))))
+  (let* ((input (read-string (or message "types here:")
+                             (loga-attach-initial-value message))))
     (case loga-current-command
       ((:add :update) (concat "\"" input "\""))
       (t input))))
 
+(defun loga-attach-initial-value (message)
+  (let ((initial-source (car loga-marked-words))
+        (initial-target (cdr loga-marked-words)))
+    (case loga-current-command
+      ((:add :update)
+       (when (and initial-source
+                  initial-target)
+         (cond ((string-match "source.+" message)
+                initial-source)
+               ((string-match "target.+" message)
+                initial-target)
+               (t nil)))))))
+
 (defun loga-input ()
   (let* ((query (loga-from-symbol-to-string loga-current-command))
          (task loga-current-command)
-------------- next part --------------
An HTML attachment was scrubbed...
下載 



More information about the logaling-commit mailing list
Back to archive index