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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:09:34+00:00 2026-06-17T14:09:34+00:00

I’m having trouble getting Emacs to behave and set Python (or any environment) to

  • 0

I’m having trouble getting Emacs to behave and set Python (or any environment) to 4-space tabs. Below is my .emacs file, and I’ve tried all the options under ;; --- Set python indent to 4 spaces ---, and none of them have worked. Is it possible there is some conflict or override happening with the indents?

Also, no matter how many times I set the tab-stop-list variables to be multiples of 4, they always end up as multiples of 8 when I use “Customize Emacs” from the menu and set the variables in the .emacs file.

I’m using GNU emacs for Mac OS X (http://emacsformacosx.com/).

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ansi-color-names-vector ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
 '(custom-enabled-themes (quote (deeper-blue)))
 '(indent-tabs-mode nil)
 '(inhibit-startup-screen t)
 '(python-guess-indent nil)
 '(python-honour-comment-indentation t)
 '(python-use-skeletons t)
 '(speedbar-indentation-width 2)
 '(tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :stipple nil :background "#181a26" :foreground "gray80" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 120 :width normal :family "consolas"))))
 '(bold ((t (:foreground "white" :weight bold))))
 '(variable-pitch ((t (:family "Helvetica Neue")))))

(add-to-list 'load-path "~/.emacs.d/el-get/el-get")

(unless (require 'el-get nil 'noerror)
  (with-current-buffer
      (url-retrieve-synchronously
       "https://raw.github.com/dimitri/el-get/master/el-get-install.el")
    (let (el-get-master-branch)
      (goto-char (point-max))
      (eval-print-last-sexp))))

(el-get 'sync)

(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)


;; Yet another snippet extension for emacs -------------------------------------
(add-to-list 'load-path
              "~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)


;; Develop and keep personal snippets under ~/emacs.d/mysnippets
(setq yas/root-directory "~/.emacs.d/mysnippets")

;; Load the snippets
(yas-load-directory yas/root-directory)

;; Auto headers for files ---------------------------------------------------
(add-to-list 'load-path "~/.emacs.d/plugins/")
(require 'header2)
(add-hook 'emacs-lisp-mode-hook 'auto-make-header)


;; Invoke Emacs Speaks Statistics (ESS) for R
(require 'ess-site)

; automatically get the correct mode 
auto-mode-alist (append (list '("\\.c$" . c-mode)
                  '("\\.tex$" . latex-mode)
                  '("\\.S$" . S-mode)
                  '("\\.s$" . S-mode)
                  '("\\.R$" . R-mode)
                  '("\\.r$" . R-mode)
                  '("\\.html$" . html-mode)
                              '("\\.emacs" . emacs-lisp-mode)
                    )
              auto-mode-alist)

;; --- Automatically close all parens and quotes ---
(add-to-list 'load-path "~/.emacs.d/plugins/autopair")
(require 'autopair)
(autopair-global-mode) ;; enable autopair in all buffers


; Match Triple-quoting in python
(add-hook 'python-mode-hook
          #'(lambda ()
              (setq autopair-handle-action-fns
                    (list #'autopair-default-handle-action
                          #'autopair-python-triple-quote-action))))

;; --- Add autopairing of $ in latex ---
(add-hook 'latex-mode-hook
          #'(lambda ()
              (push '(?$ . ?$)
                    (getf autopair-extra-pairs :string))))


; Show column numbers
(setq column-number-mode t)

; --- Set python indent to 4 spaces ---
;; Set indent size to 4
(setq standard-indent 4)
(setq default-tab-width 4)

;; (add-hook 'python-mode-hook '(lambda () 
;;  (setq python-indent 4)))
;; (setq-default py-indent-offset 4)
;; (setq indent-tabs-mode t
;;       tab-width 4
;;       python-indent 4)

;; Python Hook
;; (add-hook 'python-mode-hook
;;           (function (lambda ()
;;                       (setq indent-tabs-mode nil
;;                             tab-width 4))))


;; --- Remove all tabs, convert them to spaces ---
(setq indent-tabs-mode nil)


;; --- Auto complete latex ---
  • 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-17T14:09:35+00:00Added an answer on June 17, 2026 at 2:09 pm

    From C-h v default-tab-width RET

    This variable is obsolete since 23.2;
    use `tab-width’ instead.

    and for tab-width

    Documentation:
    *Distance between tab stops (for display of tab characters), in columns.
    You can customize this variable.

    When I insert

    (custom-set-variables
     '(tab-width 4))
    

    into ~/.emacs and restart emacs, it is set to 4.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.