emacs中组织模式与c模式的混合

emacs中组织模式与c模式的混合,emacs,org-mode,c-mode,Emacs,Org Mode,C Mode,我想在Emacs中混合使用组织模式和c模式。里面的一切 评论应该是组织模式,其余的应该是默认的主要模式 c模式: 我尝试使用nXhtml多主模式,我想还有其他模式 这也支持多模式。我现在的问题是,如果我键入TAB 在“第2节”上,将折叠“第2节”下面的所有内容并 隐形的。但我想包含组织模式下的区域 折叠/展开到“注释”部分。该选项卡只能折叠/展开 直到“*/”为止 我想知道如何实现这一点?您可以尝试M-x orgstruct mode RET我找到了一个解决方案: 列出组织模式的修补程序: --

我想在Emacs中混合使用组织模式和c模式。里面的一切 评论应该是组织模式,其余的应该是默认的主要模式 c模式:

我尝试使用nXhtml多主模式,我想还有其他模式 这也支持多模式。我现在的问题是,如果我键入TAB 在“第2节”上,将折叠“第2节”下面的所有内容并 隐形的。但我想包含组织模式下的区域 折叠/展开到“注释”部分。该选项卡只能折叠/展开 直到“*/”为止


我想知道如何实现这一点?

您可以尝试
M-x orgstruct mode RET

我找到了一个解决方案: 列出组织模式的修补程序:

--- emacs-23.2/lisp/org/org.el  2010-04-04 00:26:08.000000000 +0200
+++ src/c51/mk/org.el   2011-01-02 20:26:10.266860827 +0100
@@ -5245,6 +5245,8 @@
 (defun org-cycle-internal-local ()
   "Do the local cycling action."
   (org-back-to-heading)
+  (cond 
+   ((not (looking-at (concat outline-regexp "\s*#" )))
   (let ((goal-column 0) eoh eol eos level has-children children-skipped)
     ;; First, some boundaries
     (save-excursion
@@ -5318,7 +5320,7 @@
       (hide-subtree)
       (message "FOLDED")
       (setq org-cycle-subtree-status 'folded)
-      (run-hook-with-args 'org-cycle-hook 'folded)))))
+      (run-hook-with-args 'org-cycle-hook 'folded)))))))

 ;;;###autoload
 (defun org-global-cycle (&optional arg)
--- emacs-23.2/lisp/outline.el  2010-04-04 00:26:04.000000000 +0200
+++ src/c51/mk/outline.el   2011-01-02 20:35:17.303609833 +0100
@@ -913,8 +913,15 @@
       ;; Then unhide the top level headers.
       (outline-map-region
        (lambda ()
-    (if (<= (funcall outline-level) levels)
-        (outline-show-heading)))
+    (if (<= (funcall outline-level) level)
+          (if (looking-at (concat outline-regexp "\s*#" ))
+          (progn
+            (outline-show-heading )
+            (show-entry ))
+        (outline-show-heading))))
+;;       (lambda ()
+;;  (if (<= (funcall outline-level) levels)
+;;      (outline-show-heading)))
        beg end)))
   (run-hooks 'outline-view-change-hook))

@@ -994,7 +1001,11 @@
       (outline-map-region
        (lambda ()
     (if (<= (funcall outline-level) level)
-        (outline-show-heading)))
+          (if (looking-at (concat outline-regexp "\s*#" ))
+          (progn
+            (outline-show-heading )
+            (show-entry ))
+          (outline-show-heading))))
        (point)
        (progn (outline-end-of-subtree)
          (if (eobp) (point-max) (1+ (point)))))))

我将在注释中使用组织模式,第1节和第2节将折叠到
*#
标记。

您不能完全使用我想要的:整个文件应保持常规c文件。我想要c-comments中的组织模式功能。谢谢你的提示。我通过修补组织模式并使用orgstruct模式(而不是多主模式)得到了一个解决方案,它运行得非常好。我张贴了答案。
--- emacs-23.2/lisp/org/org.el  2010-04-04 00:26:08.000000000 +0200
+++ src/c51/mk/org.el   2011-01-02 20:26:10.266860827 +0100
@@ -5245,6 +5245,8 @@
 (defun org-cycle-internal-local ()
   "Do the local cycling action."
   (org-back-to-heading)
+  (cond 
+   ((not (looking-at (concat outline-regexp "\s*#" )))
   (let ((goal-column 0) eoh eol eos level has-children children-skipped)
     ;; First, some boundaries
     (save-excursion
@@ -5318,7 +5320,7 @@
       (hide-subtree)
       (message "FOLDED")
       (setq org-cycle-subtree-status 'folded)
-      (run-hook-with-args 'org-cycle-hook 'folded)))))
+      (run-hook-with-args 'org-cycle-hook 'folded)))))))

 ;;;###autoload
 (defun org-global-cycle (&optional arg)
--- emacs-23.2/lisp/outline.el  2010-04-04 00:26:04.000000000 +0200
+++ src/c51/mk/outline.el   2011-01-02 20:35:17.303609833 +0100
@@ -913,8 +913,15 @@
       ;; Then unhide the top level headers.
       (outline-map-region
        (lambda ()
-    (if (<= (funcall outline-level) levels)
-        (outline-show-heading)))
+    (if (<= (funcall outline-level) level)
+          (if (looking-at (concat outline-regexp "\s*#" ))
+          (progn
+            (outline-show-heading )
+            (show-entry ))
+        (outline-show-heading))))
+;;       (lambda ()
+;;  (if (<= (funcall outline-level) levels)
+;;      (outline-show-heading)))
        beg end)))
   (run-hooks 'outline-view-change-hook))

@@ -994,7 +1001,11 @@
       (outline-map-region
        (lambda ()
     (if (<= (funcall outline-level) level)
-        (outline-show-heading)))
+          (if (looking-at (concat outline-regexp "\s*#" ))
+          (progn
+            (outline-show-heading )
+            (show-entry ))
+          (outline-show-heading))))
        (point)
        (progn (outline-end-of-subtree)
          (if (eobp) (point-max) (1+ (point)))))))
/*
Org-mode here
** Section 1
  text
** Section 2
  text
*#
Org-mode should end here
*/