Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8021863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:06:35+00:00 2026-06-04T22:06:35+00:00

I’d like to mix org-mode and c-mode in Emacs. Everything inside a comment should

  • 0

I’d like to mix org-mode and c-mode in Emacs. Everything inside a
comment should be org-mode, the rests should be default major-mode
c-mode:

/*
Org-mode here
** Section 1
  text
** Section 2
  text
Org-mode should end here
*/

func1()
{
}

I tried using nXhtml multi-major-mode, I guess there are other modes
that support multimodes too. My problem now is that if I type TAB
on “section 2” then all below “Section 2” will be folded and
made invisible. But I would like to contain the region that org-mode
folds/unfolds to the comment section. The TAB should only fold/unfold
till the “*/”.

I wonder how I can achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:06:37+00:00Added an answer on June 4, 2026 at 10:06 pm

    I found a solution:
    http://lists.gnu.org/archive/html/emacs-orgmode/2011-01/msg00036.html
    lists a patch for org-mode:

    --- 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)))))))
    

    This patch has to be applied by hand, its not that difficult.
    It adds the marker *# that will break the indention. @bzg pointed out
    the M-x orgstruct-mode RET mode, credits to him. Now I can write in c.mode with orgstruct-mode in the background (no multi-major-mode needed any more):

    /*
    Org-mode here
    ** Section 1
      text
    ** Section 2
      text
    *#
    Org-mode should end here
    */
    

    And I will have org-mode in comments, The Section 1 and Section 2 will fold until the *# marker.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.