有人可以帮我删除标题为 :event
的标签吗?或:event:
,可能出现也可能不出现在标记为已完成的特定待办事项中。
如果不存在其他标签,则要删除的表单为 :event:
。如果右侧附加了附加标签,则要删除的表单为 :event
-- 因为连接到另一个标签的冒号需要保留 -- 例如 :smith_john:
我想对所有待办事项使用此函数,即使某些待办事项不包含 event
标签。
这有点棘手,因为正常的搜索和替换不会仅限于待办事项列表中的这一特定任务。我知道与状态更改相关的标签删除功能,但我更愿意使用我自己的删除功能。
这是 :event
的示例附加到另一个标签:
** Reference [#A] smith @ meeting; 08/09/2013; 8:30 a.m. :event:smith_john:
DEADLINE: <2013-08-09 Fri 08:30 > SCHEDULED: <2013-08-09 Fri >
:PROPERTIES:
:ToodledoID: 335265357
:ToodledoFolder: EVENTS
:Hash: 4a6b6cc7fbefa9b7695b12247bf84d15
:END:
These are some notes relating to the client named John Smith.
这是一个不包含 :event
的任务示例或:event:
标签。 none
尽管如此,函数应该能够像上面的任务一样关闭它。
** Next Action [#D] 0 @ kid's birthday -- 07/18/1993 :lawlist:
DEADLINE: <2014-07-18 Fri >
:PROPERTIES:
:ToodledoID: 332902470
:ToodledoFolder: TASKS
:Hash: e7cf177f187d47c8fa8ca882f2725305
:END:
These are some notes relating to a task without an event tag.
以下是我用来将待办事项标记为 None
的函数,当与 Toodledo 同步时,将被理解为相当于更常见的 completed
或done
。字Reference
上面的任务中是我选择用于日历上的事件的 Toodledo 待办事项状态,以及单词 Next Action
我用它来处理有 future 截止日期的任务。
(defun none (&optional default-heading)
(interactive)
(let ((lawlist-item default-heading)
result)
(unless lawlist-item
(condition-case nil
(progn
(org-back-to-heading t)
(setq lawlist-item (elt (org-heading-components) 4)))
)
)
(org-todo "None")
(org-priority ?E)
(org-schedule 'remove)
(org-deadline 'remove)
(org-set-property "ToodledoFolder" "DONE")
(setq org-archive-save-context-info nil)
(setq org-archive-location "/Users/HOME/.0.data/*TODO*::* DONE")
(org-archive-subtree)
(goto-char (point-min))
(re-search-forward "^\* DONE" nil t)
(condition-case err
(progn
(org-sort-entries t ?a)
(lawlist-org-cleanup) ) ;; a custom pagination function.
(error nil))
(re-search-forward lawlist-item nil t)
(beginning-of-visual-line)
(org-cycle-hide-drawers 'all)
))
编辑:以下是上面 none
中使用的清理函数函数,以防万一有人对以这种方式结束特定待办事项的完整解决方案感兴趣:
(defun delete-trailing-blank-lines-at-end-of-file ()
"Deletes all blank lines at the end of the file, even the last one"
(interactive)
(save-excursion
(save-restriction
(widen)
(goto-char (point-max))
(delete-blank-lines)
(let ((trailnewlines (abs (skip-chars-backward "\n\t"))))
(if (> trailnewlines 0)
(progn
(delete-char trailnewlines)))))))
(defun lawlist-org-cleanup ()
(interactive)
(save-excursion
(replace-regexp "\n+\\*\\* " "\n\n** " nil (point-min) (point-max))
(replace-regexp "\n+\\* " "\n\n\n* " nil (point-min) (point-max))
(replace-regexp "\n\t\s*" "\n " nil (point-min) (point-max)) )
(delete-trailing-blank-lines-at-end-of-file) )
最佳答案
只要标题上有要点,以下内容就应该有效:
(when (search-forward-regexp ":event\\|event:" (line-end-position) t)
(replace-match "")
(when (and (looking-at ":$\\|: ") (looking-back " "))
(delete-char 1)))
关于emacs - 如何使用自定义函数在组织模式下仅删除一些标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18168146/