;;emacs date and time (November 30,2011 16:18)
;;insert-current-data and time
(defun insert-current-date()
"Insert the current date & time"
(interactive "*")
;(insert (format-time-string "%Y-%m-%d %H:%M:%S" (current-time))))
(insert (format-time-string "%Y-%m-%d %H:%M:%S" (current-time))))
(global-set-key "\C-xj" 'insert-current-date)
(defun qiang-comment-dwim-line (&optional arg)
"Replacement for the comment-dwim command.
If no region is selected and current line is not blank and we are not at the end of the line,
then comment current line.
Replaces default behaviour of comment-dwim, when it inserts comment at the end of the line."
(interactive "*P")
(comment-normalize-vars)
(if (and (not (region-active-p)) (not (looking-at "[ \t]*$")))
(comment-or-uncomment-region (line-beginning-position) (line-end-position))
(comment-dwim arg)))
(global-set-key "\M-;" 'qiang-comment-dwim-line)
本文介绍如何在 Emacs 编辑器中使用自定义函数快速插入当前日期时间,并实现智能注释行功能。通过设置快捷键,提升编程效率。
1525

被折叠的 条评论
为什么被折叠?



