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 6031237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:09:14+00:00 2026-05-23T05:09:14+00:00

I am involved in python project where tabs are used, however i am not

  • 0

I am involved in python project where tabs are used, however i am not using them in every other code i write, it is vital to use them in that particular project. Projects are located in one directory under specific directories. I.E:

\main_folder
    \project1
    \project2
    \project3
...etc

I have couple functions/hooks on file open and save that untabify and tabify whole buffer i work on.

 ;; My Functions
(defun untabify-buffer ()
            "Untabify current buffer"
        (interactive)
        (untabify (point-min) (point-max)))

(defun tabify-buffer ()
        "Tabify current buffer"
        (interactive)
        (tabify (point-min) (point-max)))

;; HOOKS
; untabify buffer on open
(add-hook 'find-file-hook 'untabify-buffer)
; tabify on save
(add-hook 'before-save-hook 'tabify-buffer)

If i put it in .emacs file it is run on every .py file i open which is not what i want. What i`d like to have is to have these hooks used only in one particular folder with respective subfolders. Tried .dir_locals but it works only for properties not hooks. I can not use hooks in specific modes (i.e. python-mode) as almost all projects are written in python. To be honest i tried writing elisp conditional save but failed.

  • 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-05-23T05:09:14+00:00Added an answer on May 23, 2026 at 5:09 am

    A very easy solution is to just add a configuration variable that can be used to disable the hooks. For example:

    (defvar tweak-tabs t)
    (add-hook 'find-file-hook
              (lambda () (when tweak-tabs (untabify (point-min) (point-max)))))
    (add-hook 'before-save-hook
              (lambda () (when tweak-tabs (tabify (point-min) (point-max)))))
    

    Now you can add a .dir-locals.el file in the relevant directories, setting tweak-tabs to nil, disabling this feature there.

    (But another problem is that this is a pretty bad way to deal with tabs. For example, after you save a file you do see the tabs in it.)

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

Sidebar

Related Questions

I wrote a number crunching python code. The calculations involved can take hours. Is
I'm involved in a project that is attempting to use the Eclipse RCP splash
I'm a C Newb I write lots of code in dynamic languages (javascript, python,
I recently implemented password reset on AD using python ldap module. This involved passing
Suppose I have a python script called my_parallel_script.py that involves using multiprocessing to parallelize
Involved classes : Mage_Sales_Model_Quote_Item and Mage_Catalog_Model_Product . I get both of them as a
Background: I'm trying to build a web app (as a personal project using modern
I'm working on a project that involves uploading an image to tumblr from Python.
I'm programming a pet project in Python, and it involves users A & B
I am attempting to call a C++ API from python. Following is the code

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.