ViewSourceWith 및 Emacs를 사용하여 StackOverflow 응답 및 질문을 편집합니다. 종종, 코드를 포함하고 StackOverflow formatting rules 은 공백으로 들여 쓰기하여 으로 인식되어야한다고 말합니다. 손으로 또는 매크로를 사용해도 고통 스럽습니다.Emacs를 사용하여 들여 쓰기 (shift 4) 코드
나는 이전 게시물에서 검색했지만 아무 것도 발견하지 못했습니다. 파이썬 모드에서 시작
, 내가 쓴 :(defun text-shift-region (start end count)
"Indent lines from START to END by COUNT spaces."
(save-excursion
(goto-char end)
(beginning-of-line)
(setq end (point))
(goto-char start)
(beginning-of-line)
(setq start (point))
(indent-rigidly start end count)))
(defun text-shift-region-right (start end &optional count)
"Shift region of code to the right
Stolen from python-mode.
The lines from the line containing the start of the current region up
to (but not including) the line containing the end of the region are
shifted to the right, by `text-indent-offset' columns.
If a prefix argument is given, the region is instead shifted by that
many columns. With no active region, indent only the current line."
(interactive
(let ((p (point))
(m (mark))
(arg current-prefix-arg))
(if m
(list (min p m) (max p m) arg)
(list p (save-excursion (forward-line 1) (point)) arg))))
(text-shift-region start end (prefix-numeric-value
(or count text-indent-offset)))
)
;; Code in StackOverflow must be marked by four spaces at the
;; beginning of the line
(setq text-indent-offset 4)
(global-set-key "\C-c>" 'text-shift-region-right)
작동하는 것 같다하지만 조언, 대안, 버그 리포트, 등
이것은 거의 질문이 아닙니다. –
빨리 요리 된 솔루션에 대한 대안을 얻거나 흥미로운 패치를 받기를 바랍니다. – bortzmeyer
또한 어딘가에서 문서를 요청하는 데 충분한 관심이 있는지를 확인하는 방법으로 이것을 사용하는 사람들에게 도움이 될 것 같습니다. – bortzmeyer