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

  • SEARCH
  • Home
  • 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 8743991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:46:22+00:00 2026-06-13T11:46:22+00:00

I use this as reference: Emacs comment/uncomment current line My question is whether I

  • 0

I use this as reference:
Emacs comment/uncomment current line

My question is whether I can perform the same task using defadvice (which seems more appropriate to me)?
Something along the lines of

(defadvice comment-or-uncomment-region (before mark-whole-line (arg beg end) activate)
  (unless (region-active-p)
    (setq beg (line-beginning-position) end (line-end-position))))
(ad-activate 'comment-or-uncomment-region) 
  • 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-13T11:46:23+00:00Added an answer on June 13, 2026 at 11:46 am

    This answer is based on my comments above.

    defadvice is not more appropriate than another solution. It is never more
    appropriate than another solution.


    defadvice is a last resort for when you can’t fix your problem any other
    way
    .

    PERIOD.


    Keeping in mind that whenever you use defadvice you are fundamentally modifying
    the Emacs API which package developers rely upon.

    When you subtly changing these behaviours, you cause lots of problems for you
    and eventually for the package developers when you report “bugs” because
    your Emacs API was broken with defadvice.

    So when you want to change functionality locally, the
    way to do it is to define a new command using existing functionality and remap
    to it.

    To wit (from the answer you referred to):

    (defun comment-or-uncomment-region-or-line ()
        "Comments or uncomments the region or the current line if there's no active region."
        (interactive)
        (let (beg end)
            (if (region-active-p)
                (setq beg (region-beginning) end (region-end))
                (setq beg (line-beginning-position) end (line-end-position)))
            (comment-or-uncomment-region beg end)
            (next-line)))
    
    (global-set-key [remap comment-dwim] 'comment-or-uncomment-region-or-line)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing pass-by-reference like this: use strict; use warnings; sub repl { local
I try to use the boolean in my class and get this message reference
i use this line of code : [self parseXMLFileAtURL:url]; And i get this error
When writing emails with Emacs, I like to use this format with numbers between
I learned that using a reference variable is faster than using $() every line
I am accessing the gData Api on YouTube. I'll use this xml for reference.
I'm using a library which returns a reference to me. I need to use
I try to use this function in my code: https://developers.google.com/drive/v2/reference/files/list Here below: /** *
https://developers.google.com/drive/v2/reference/children/list I use this php function taken from the documentation /** * Print files
I'm having this issue when trying to use an ASPX page from a referenced

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.