Skip to content

Instantly share code, notes, and snippets.

@fatfingererr
Created March 24, 2017 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fatfingererr/1fda91865dd17cf9683750d0b215fa2d to your computer and use it in GitHub Desktop.
Save fatfingererr/1fda91865dd17cf9683750d0b215fa2d to your computer and use it in GitHub Desktop.
The question about "copy" in Emacs
(defun build-variable ()
(interactive)
(let
;; 擷取當前那行程式碼並依照空格分開來
((line-string (split-string (thing-at-point 'line t))))
;; 刪除原本那行
(kill-whole-line)
;; 新的一行會從原本那行第一個元素和剩下元素但首字大寫做合併
(setq new-line-string (apply 'concat (append (list (first line-string)) (mapcar 'capitalize (cdr line-string)))))
;; 插入新的那行
(insert new-line-string)
;; 複製新的那行
(copy new-line-string)
)
)
aaa bbb ddd
;; 在上面這行執行會變成: aaaBbbDdd
;; 但是當我用 C-y 貼上卻還是原本的 aaa bbb ddd
;; 為什麼呢? 謝謝!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment