, 내가 첫 번째 행을 좀하고 싶습니다 에코,하지만 난 문제가 format
또는 echo
와 경우Elisp : 형식으로 따옴표를 얻을 수/<code>.mailrc</code>에서
alias UIF "UIF Boxning <[email protected]>" # cool (written manually by me)
alias test_alias test_name <test_mail> # no quotation marks (written by below defun)
내가 확실하지 오전 두 번째 행을 얻을. 보라 :
(defun save-mail-address (address name alias)
"add an alias to the .mailrc file"
(interactive "sMail address: \nsFull name: \nsAlias: ")
(let ((compl-alias (format "alias %s \"%s \<%s\>\"" alias name address)))
(shell-command (concat "echo " compl-alias " >> .mailrc"))))
(defalias 'sma 'save-mail-address)
편집 :
: 또한alias long "Long Long <[email protected]>" # 123456
alias s "S S <[email protected]>" # 1
, 내가 중복을 포함하도록 그렇게하지 확인했다 :
OK, 목표는 다음과 같이 유지하다
(defun append-blanks (str len)
(concat str (make-string (- len (length str)) ?)))
(defun save-mail-address (mail name alias phone)
"add an alias to the .mailrc file"
(interactive "sMail mail: \nsFull name: \nsAlias: \nnPhone: ")
(let*(
(alias-alias (format "alias %s" alias))
(alias-alias-blanks (append-blanks alias-alias 16))
(mail-str (append-blanks (format "\"%s \<%s\>\"" name mail) 48))
(line (format "%s%s\# %d\n" alias-alias-blanks mail-str phone))
(file "~/.mailrc"))
(with-temp-buffer
(insert-file file)
(if
(search-forward alias-alias (point-max) t) ; t = return nil on fail
(message (format "Error: The alias %s is already in use." alias))
(progn
(insert line)
(sort-columns nil (point-min) (point-max)) ; nil = not reversed
(write-file file nil)))))) ; nil = inhibit confirm
을 죽이고, 버퍼에 .mailrc의 방문 텍스트를 추가, 버퍼를 저장하는 것이 일의 Lisp 다운 방법 . – tripleee
맞아요, 제 솔루션이 (아래의 도움으로) 작동하지만, 빈'* Shell Command Output * '버퍼가 생성된다는 귀찮은 부작용이 있습니다. 하지만, 모든 것을 다시하기보다는 코드에서 마지막으로 버퍼를 죽이고 다음에 조언을받습니다. –